Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------------------------------------------
- ------------------ Anti-Aimbot Script v4.0 for Phasor 2.0 ------------------
- ------------- Thanks to people who helped me test this script --------------
- ----------------- Creator: Skylace Website: bud.boards.net -----------------
- ----------------------- Xfire: it300 Steam: Devieth ------------------------
- ----------------------------------------------------------------------------
- -- At what aimbot score should we take an action on the player?
- -- I recommend anywhere from 1500 to 5000.
- max_score = 2000
- -- What action to take when a player has been detected as a bot?
- action = "kick"
- -- Time to ban a player (in minutes.)
- ban_time = "1440"
- -- Minimum stop angle to be considerd a snap.
- snap_stop_angle = 10
- -- Rate in which to reduce a players aimbot score (in seconds.)
- aimbot_score_depletion_rate = 1.5
- -- Scpre removed when aimbot_score_depletion_rate is called.
- aimbot_score_depletion = 3
- -- Message that is sent to admins when an action has been called on a player.
- notify_admins = false
- -- Should the script create a Antibot.log file?
- logging_enabled = true
- ----------------------------------------------------------------------------
- -- DO NOT TOUCH ANYTHING BELOW THIS POINT UNLESS YOU KNOW WHAT YOUR DOING --
- ----------------------------------------------------------------------------
- player_score = {}
- spawning = {}
- loc = {}
- camera_table = {}
- function GetRequiredVersion()
- return 200
- end
- function OnPlayerJoin(player)
- camera_table[player] = nil
- player_score[player] = 0
- end
- function OnPlayerLeave(player)
- camera_table[player] = nil
- player_score[player] = 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(player, command, password)
- local response = nil
- t = tokenizecmdstring(command)
- count = #t
- if t[1] == "sv_getscore" then
- response = 0
- if rresolveplayer(t[2]) then
- sendconsoletext(player, math.floor(tonumber(player_score[rresolveplayer(t[2])])))
- else
- sendconsoletext(player, "Invalid Player!")
- end
- elseif t[1] == "sv_getscores" or t[1] == "sv_aimbot_scores" then
- resonse = 0
- sendconsoletext(player, "Name | Score")
- for i = 0,15 do
- if getplayer(i) then
- sendconsoletext(player, getname(i) .. " | " .. math.floor(tonumber(player_score[i])))
- end
- end
- elseif t[1] == "sv_aimbot_ban" then
- resonse = 0
- if t[2] ~= nil then
- if tonumber(t[1]) ~= nil then
- maxt_score = tonumber(t[1])
- else
- sendconsoletext(player, "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(player, "Invalid action! Use ban, kick, or none.")
- end
- if tonumber(t[3]) ~= nil then
- ban_time = tonumber(t[3])
- else
- sendconsoletext(player, "Invalid time! Ban time is in minutes")
- end
- else
- sendconsoletext(player, "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(player)
- camera_table[player] = nil
- spawning[player] = true
- registertimer(1500, "removegrace", player)
- end
- function removegrace(id, count, player)
- spawning[player] = false
- end
- function takeaction(player)
- 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(player), gethash(player), getip(player), getping(player), player_score[player], action)
- WriteLog(log_file, Line)
- if notify_admins then
- for i=0,15 do
- if isadmin(i) then
- privatesay(i, "Name: " .. getname(player) .. " - Action taken: " .. action .. " - Aimbot Score:" .. tonumber(player_score[player]))
- end
- end
- end
- local player_id = resolveplayer(player)
- if action == "ban" then
- if ban_time then
- svcmd("sv_ban " .. player_id .. " " .. ban_time .. "m")
- else
- svcmd("sv_ban " .. player_id)
- end
- player_score[player] = 0
- say(getname(player) .. " has been banned from the server for aimbotting!")
- elseif action == "kick" then
- svcmd("sv_kick " .. player_id)
- player_score[player] = 0
- say(getname(player) .. " has been kicked from the server for aimbotting!")
- elseif action == "none" or action == "warn" then
- say(getname(player) .. " may very possibly be aimbotting! Id: " .. player_id)
- end
- end
- function OnClientUpdate(player)
- checkforteleport(player)
- local stop_angle = getstopangle(player)
- if stop_angle ~= nil then else stop_angle = 0 end
- if not spawning[player] then
- if stop_angle > snap_stop_angle then
- local hitting, at_teammate, distance = Intersect(player)
- if distance ~= nil then else distance = 1 end
- if hitting and not at_teammate then
- --say("detected " .. getname(player) .. " - ".. stop_angle .. " - ".. distance)
- if tonumber(player_score[player]) then
- player_score[player] = tonumber(player_score[player]) + (stop_angle * 0.125 * distance)
- if tonumber(player_score[player]) > max_score then
- takeaction(player)
- end
- else
- player_score[player] = (stop_angle * 0.125 * distance)
- end
- end
- end
- end
- end
- function checkforteleport(player)
- if x ~= loc[player][1] or y ~= loc[player][2] or z ~= loc[player][3] then
- if loc[player][1] == nil then
- loc[player][1] = x
- loc[player][2] = y
- loc[player][3] = z
- elseif m_object then
- distance = math.sqrt((loc[player][1] - x)^2 + (loc[player][2] - y)^2 + (loc[player][3] - z)^2)
- local result = true
- if distance >= 10 then result = OnPlayerTeleport(player) end
- if result == 0 or not result then
- --movobjectcoords(m_objectId, loc[player][1], loc[player][2], loc[player][3])
- loc[player][1] = x
- loc[player][2] = y
- loc[player][3] = z
- else
- loc[player][1] = x
- loc[player][2] = y
- loc[player][3] = z
- end
- end
- end
- end
- function OnPlayerTeleport(player)
- spawning[player] = true
- registertimer(500, "removegrace", player)
- end
- function getstopangle(player)
- local m_objectId = getplayerobjectid(player)
- local m_object = getobject(m_objectId)
- local camera_x = readfloat(m_object + 0x230)
- local camera_y = readfloat(m_object + 0x234)
- local camera_z = readfloat(m_object + 0x238)
- if camera_table[player] == nil then
- camera_table[player] = {camera_x, camera_y, camera_z}
- return
- end
- local last_camera_x = camera_table[player][1]
- local last_camera_y = camera_table[player][2]
- local last_camera_z = camera_table[player][3]
- camera_table[player] = {camera_x, camera_y, camera_z}
- if last_camera_x == 0 and
- last_camera_y == 0 and
- last_camera_z == 0 then
- return
- end
- local movement = math.sqrt(
- (camera_x - last_camera_x) ^ 2 +
- (camera_y - last_camera_y) ^ 2 +
- (camera_z - last_camera_z) ^ 2)
- local angle = math.acos((2 - movement ^ 2) / 2)
- stop_angle = angle * 180 / math.pi
- return stop_angle
- end
- function Intersect(player)
- local player_objid = getplayerobjectid(player)
- if (player_objid ~= nil) then
- local m_object = getobject(player_objid)
- local vx = readfloat(m_object + 0x230)
- local vy = readfloat(m_object + 0x234)
- local vz = readfloat(m_object + 0x238)
- local px, py, pz = getobjectcoords(player_objid)
- local bipd_id = readdword(m_object)
- local bipd_tag = gettagaddress(bipd_id)
- local bipd_data = readdword(bipd_tag + 0x14)
- local standing_height = readfloat(bipd_data + 0x400)
- local crouch_height = readfloat(bipd_data + 0x404)
- local crouch_state = readfloat(m_object + 0x50c)
- if (crouch_state == 0) then
- pz = pz + standing_height
- else
- pz = pz + (crouch_height * crouch_state)
- end
- local hit,x,y,z,objid = halointersect(1000, px, py, pz, vx, vy, vz, player_objid)
- while hit == true do
- for i = 0,15 do
- if getplayer(i) ~= nil then
- local player2_objid = getplayerobjectid(i)
- if objid == player2_objid then
- hitting = true
- distance = math.sqrt((x - px) ^ 2 + (y - py) ^ 2 + (z - pz) ^ 2)
- --say(getname(player) .. " is aiming at " .. getname(i))
- if getteam(player) == getteam(i) then
- at_teamate = true
- else
- at_teamate = false
- end
- else
- hitting = false
- end
- end
- end
- break
- end
- end
- return hitting, at_teammate, distance
- end
- function math.round(number, place)
- return math.floor(number * ( 10 ^ (place or 0) ) + 0.5) / ( 10 ^ (place or 0) )
- end
- function checkState(state, location_z)
- if state == 2 then
- return location_z + 0.6
- elseif state == 3 then
- return location_z + 0.3
- end
- return nil
- end
- 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
- function getping(player)
- local m_player = getplayer(player)
- if m_player then return readword(m_player + 0xDC) end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement