- ----------------------------------------------------------------------------
- ----------------- Anti-Aimbot Script v4.1.1 for Phasor 2.0 -----------------
- ------ Thanks to Wizard for helping add aiming though wall detection -------
- ----- and optimizing the script so that it can run faster. Also thanks -----
- -------- to all the other people who helped make & test this script --------
- --------------------- Creator(s): Skylace & Wizard -------------------------
- ----------------------------------------------------------------------------
- -- At what aimbot score should we take an action on the player?
- -- I recommend anywhere from 1500 to 5000.
- local max_score = 2000
- -- What action to take when a player has been detected as a bot?
- local action = "ban"
- -- Time to ban a player (in minutes.)
- local ban_time = "1440"
- -- Minimum stop angle to be considered a snap.
- local snap_stop_angle = 10
- -- Rate in which to reduce a players aimbot score (in seconds.)
- local aimbot_score_depletion_rate = 1.5
- -- Score removed when aimbot_score_depletion_rate is called.
- local aimbot_score_depletion = 3
- -- Message that is sent to admins when an action has been called on a player.
- local notify_admins = false
- -- Should the script create a Antibot.log file?
- local logging_enabled = true
- ----------------------------------------------------------------------------
- -- DO NOT TOUCH ANYTHING BELOW THIS POINT UNLESS YOU KNOW WHAT YOUR DOING --
- ----------------------------------------------------------------------------
- local player_score = {}
- local spawning = {}
- local loc = {}
- local camera_table = {}
- local bipd_id
- local bipd_tag
- local bipd_data
- local standing_height
- local crouch_height
- function GetRequiredVersion()
- return 200
- end
- function OnPlayerJoin(playerId)
- camera_table[playerId] = nil
- player_score[playerId] = 0
- end
- function OnPlayerLeave(playerId)
- camera_table[playerId] = nil
- player_score[playerId] = 0
- end
- function OnScriptLoad(process, game, persistent)
- for i = 0,15 do
- loc[i] = {}
- camera_table[i] = nil
- player_score[i] = 0
- end
- registertimer(aimbot_score_depletion_rate * 1000, "score_depletion")
- end
- function OnServerCommand(playerId, command, password)
- local response = nil
- t = tokenizecmdstring(command)
- count = #t
- if t[1] == "sv_getscore" then
- response = 0
- if tonumber(t[2]) ~= nil then
- sendconsoletext(playerId, math.floor(tonumber(player_score[rresolveplayer(t[2])])))
- else
- sendconsoletext(playerId, "Invalid Player!")
- end
- elseif t[1] == "sv_getscores" or t[1] == "sv_aimbot_scores" then
- response = 0
- sendconsoletext(playerId, "Name | Score")
- for i = 0,15 do
- if getplayer(i) then
- sendconsoletext(playerId, getname(i) .. " | " .. math.floor(tonumber(player_score[i])))
- end
- end
- elseif t[1] == "sv_aimbot_ban" then
- response = 0
- if t[2] ~= nil then
- if tonumber(t[1]) ~= nil then
- maxt_score = tonumber(t[1])
- else
- sendconsoletext(playerId, "Invalid Score! Use a number.")
- end
- if tostring(t[2]) == "ban" or tostring(t[3]) == "kick" or tostring(t[3]) == "none" then
- action = tostring(t[2])
- else
- sendconsoletext(playerId, "Invalid action! Use ban, kick, or none.")
- end
- if tonumber(t[3]) ~= nil then
- ban_time = tonumber(t[3])
- else
- sendconsoletext(playerId, "Invalid time! Ban time is in minutes")
- end
- else
- sendconsoletext(playerId, "Invalid Syntax! sv_aimbot_ban [type] {score} {time}")
- end
- end
- return response
- end
- function score_depletion(id, count)
- for i = 0,15 do
- if getplayer(i) ~= nil then
- if tonumber(player_score[i]) > 0 then
- player_score[i] = tonumber(player_score[i]) - aimbot_score_depletion
- elseif tonumber(player_score[i]) < 0 then
- player_score[i] = 0
- end
- end
- end
- return true
- end
- function OnPlayerKill(killer, victim, mode)
- camera_table[victim] = nil
- end
- function OnPlayerSpawn(playerId)
- if not bipd_id then
- bipd_id = readdword(getobject(getplayerobjectid(playerId)))
- bipd_tag = gettagaddress(bipd_id)
- bipd_data = readdword(bipd_tag + 0x14)
- standing_height = readfloat(bipd_data + 0x400)
- crouch_height = readfloat(bipd_data + 0x404)
- end
- camera_table[playerId] = nil
- spawning[playerId] = true
- registertimer(1500, "removegrace", playerId)
- end
- function removegrace(id, count, playerId)
- spawning[playerId] = false
- end
- local function WriteLog(filename, value)
- if logging_enabled then
- local file = io.open(filename, "a")
- if file then
- file:write( string.format("%s\t%s\n", os.date("!%m/%d/%Y %H:%M:%S"), tostring(value) ) )
- file:close()
- end
- end
- end
- local function getping(playerId)
- return readword(getplayer(playerId) + 0xDC)
- end
- local function takeaction(playerId)
- local log_file = getprofilepath() .. "\\logs\\Antibot.log"
- local line = "(Name: %s) (Hash: %s) (IP: %s) (Ping: %s) (Score: %s) (Action: %s)"
- local Line = string.format(line, getname(playerId), gethash(playerId), getip(playerId), getping(playerId), math.floor(tonumber(player_score[playerId])), action)
- WriteLog(log_file, Line)
- if notify_admins then
- for i=0,15 do
- if isadmin(i) then
- privatesay(i, "Name: " .. getname(playerId) .. " - Action taken: " .. action .. " - Aimbot Score:" .. math.floor(tonumber(player_score[playerId])))
- end
- end
- end
- local player_id = resolveplayer(playerId)
- if action == "ban" then
- if ban_time then
- svcmd("sv_ban " .. player_id .. " " .. ban_time .. "m")
- else
- svcmd("sv_ban " .. player_id)
- end
- say(getname(playerId) .. " has been banned from the server for aimbotting!")
- player_score[playerId] = 0
- elseif action == "kick" then
- svcmd("sv_kick " .. player_id)
- player_score[playerId] = 0
- say(getname(playerId) .. " has been kicked from the server for aimbotting!")
- elseif action == "none" or action == "warn" then
- say(getname(playerId) .. " may very possibly be aimbotting! Id: " .. player_id)
- end
- end
- local function OnPlayerTeleport(playerId)
- spawning[playerId] = true
- registertimer(500, "removegrace", playerId)
- end
- local function checkforteleport(playerId)
- local m_objectId = getplayerobjectid(playerId)
- local x,y,z = getobjectcoords(m_objectId)
- if x ~= loc[playerId][1] or y ~= loc[playerId][2] or z ~= loc[playerId][3] then
- if loc[playerId][1] == nil then
- loc[playerId][1] = x
- loc[playerId][2] = y
- loc[playerId][3] = z
- elseif m_object then
- distance = math.sqrt((loc[playerId][1] - x)^2 + (loc[playerId][2] - y)^2 + (loc[playerId][3] - z)^2)
- local result = true
- if distance >= 10 then result = OnPlayerTeleport(playerId) end
- if result == 0 or result == false then
- --movobjectcoords(m_objectId, loc[playerId][1], loc[playerId][2], loc[playerId][3])
- loc[playerId][1] = x
- loc[playerId][2] = y
- loc[playerId][3] = z
- else
- loc[playerId][1] = x
- loc[playerId][2] = y
- loc[playerId][3] = z
- end
- end
- end
- end
- local function getstopangle(playerId, x_aim, y_aim, z_aim)
- local m_objectId = getplayerobjectid(playerId)
- local m_object = getobject(m_objectId)
- if camera_table[playerId] == nil then
- camera_table[playerId] = {x_aim, y_aim, z_aim}
- return
- end
- local last_camera_x = camera_table[playerId][1]
- local last_camera_y = camera_table[playerId][2]
- local last_camera_z = camera_table[playerId][3]
- camera_table[playerId] = {x_aim, y_aim, z_aim}
- if last_camera_x == 0 and
- last_camera_y == 0 and
- last_camera_z == 0 then
- return
- end
- local movement = math.sqrt(
- (x_aim - last_camera_x) ^ 2 +
- (y_aim - last_camera_y) ^ 2 +
- (z_aim - last_camera_z) ^ 2)
- local angle = math.acos((2 - movement ^ 2) / 2)
- stop_angle = angle * 180 / math.pi
- return stop_angle
- end
- local function Intersect(playerId, vx, vy, vz)
- local playerObjId = getplayerobjectid(playerId)
- local m_object = getobject(playerObjId)
- if not m_object then
- return
- end
- local crouch_state = readfloat(m_object + 0x50C)
- local px, py, pz = getobjectcoords(playerObjId)
- if (crouch_state == 0) then
- pz = pz + standing_height
- else
- pz = pz + (crouch_height * crouch_state)
- end
- local hit,x,y,z,objectId = halointersect(1000, px, py, pz, vx, vy, vz, playerObjId)
- local walls = 1
- while hit == true and walls < 20 do
- local playerId2 = objectId and objectidtoplayer(objectId)
- if not playerId2 then
- walls = walls + 1
- hit,x,y,z,objectId = halointersect(1000, x, y, z, vx, vy, vz, objectId)
- else
- --say(getname(playerId) .. " is aiming at " .. getname(playerId2))
- return true, getteam(playerId) == getteam(playerId2), math.sqrt((x - px) ^ 2 + (y - py) ^ 2 + (z - pz) ^ 2), walls
- end
- end
- end
- function OnClientUpdate(playerId)
- if not bipd_id then
- return
- end
- checkforteleport(playerId)
- if spawning[playerId] then
- return
- end
- local m_objectId = getplayerobjectid(playerId)
- local m_object = getobject(m_objectId)
- local x_aim,y_aim,z_aim = readfloat(m_object + 0x230),readfloat(m_object + 0x234),readfloat(m_object + 0x238)
- local stop_angle = getstopangle(playerId, x_aim, y_aim, z_aim)
- if stop_angle ~= nil then else stop_angle = 1 end
- if stop_angle <= snap_stop_angle then
- return
- end
- local hitting, at_teammate, distance, walls = Intersect(playerId, x_aim, y_aim, z_aim)
- if distance ~= nil then else distance = 1 end
- if hitting and not at_teammate then
- if walls < 2 then score_multiplier = 0.125 else score_multiplier = 0.175 end
- if tonumber(player_score[playerId]) then
- player_score[playerId] = tonumber(player_score[playerId]) + (stop_angle * score_multiplier * distance)
- if tonumber(player_score[playerId]) > max_score then
- takeaction(playerId)
- end
- else
- player_score[playerId] = (stop_angle * score_multiplier * distance)
- end
- end
- end
Recent Pastes