Advertisement
it300

Anti-Aimbot v4.0 Phasor 2.0+

Feb 25th, 2015
707
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.52 KB | None | 0 0
  1. ----------------------------------------------------------------------------
  2. ------------------ Anti-Aimbot Script v4.0 for Phasor 2.0 ------------------
  3. ------------- Thanks to people who helped me test this script --------------
  4. ----------------- Creator: Skylace Website: bud.boards.net -----------------
  5. ----------------------- Xfire: it300 Steam: Devieth ------------------------
  6. ----------------------------------------------------------------------------
  7.  
  8. -- At what aimbot score should we take an action on the player?
  9. -- I recommend anywhere from 1500 to 5000.
  10. max_score = 2000
  11.  
  12. -- What action to take when a player has been detected as a bot?
  13. action = "kick"
  14.  
  15. -- Time to ban a player (in minutes.)
  16. ban_time = "1440"
  17.  
  18. -- Minimum stop angle to be considerd a snap.
  19. snap_stop_angle = 10
  20.  
  21. -- Rate in which to reduce a players aimbot score (in seconds.)
  22. aimbot_score_depletion_rate = 1.5
  23.  
  24. -- Scpre removed when aimbot_score_depletion_rate is called.
  25. aimbot_score_depletion = 3
  26.  
  27. -- Message that is sent to admins when an action has been called on a player.
  28. notify_admins = false
  29.  
  30.  -- Should the script create a Antibot.log file?
  31. logging_enabled = true
  32.  
  33. ----------------------------------------------------------------------------
  34. -- DO NOT TOUCH ANYTHING BELOW THIS POINT UNLESS YOU KNOW WHAT YOUR DOING --
  35. ----------------------------------------------------------------------------
  36.  
  37. player_score = {}
  38. spawning = {}
  39. loc = {}
  40. camera_table = {}
  41.  
  42. function GetRequiredVersion()
  43.     return 200
  44. end
  45.  
  46. function OnPlayerJoin(player)
  47.     camera_table[player] = nil
  48.     player_score[player] = 0
  49. end
  50.  
  51. function OnPlayerLeave(player)
  52.     camera_table[player] = nil
  53.     player_score[player] = 0
  54. end
  55.  
  56. function OnScriptLoad(process, game, persistent)
  57.     for i = 0,15 do
  58.         loc[i] = {}
  59.         camera_table[i] = nil
  60.         player_score[i] = 0
  61.     end
  62.     registertimer(aimbot_score_depletion_rate * 1000, "score_depletion")
  63. end
  64.  
  65. function OnServerCommand(player, command, password)
  66.     local response = nil
  67.     t = tokenizecmdstring(command)
  68.     count = #t
  69.         if t[1] == "sv_getscore" then
  70.             response = 0
  71.             if rresolveplayer(t[2]) then
  72.                 sendconsoletext(player, math.floor(tonumber(player_score[rresolveplayer(t[2])])))
  73.             else
  74.                 sendconsoletext(player, "Invalid Player!")
  75.             end
  76.         elseif t[1] == "sv_getscores" or t[1] == "sv_aimbot_scores" then
  77.             resonse = 0
  78.             sendconsoletext(player, "Name  |  Score")
  79.             for i = 0,15 do
  80.                 if getplayer(i) then
  81.                     sendconsoletext(player, getname(i) .. "  |  " .. math.floor(tonumber(player_score[i])))
  82.                 end
  83.             end
  84.         elseif t[1] == "sv_aimbot_ban" then
  85.             resonse = 0
  86.             if t[2] ~= nil then
  87.                 if tonumber(t[1]) ~= nil then
  88.                     maxt_score = tonumber(t[1])
  89.                 else
  90.                     sendconsoletext(player, "Invalid Score! Use a number.")
  91.                 end
  92.                 if tostring(t[2]) == "ban" or tostring(t[3]) == "kick" or tostring(t[3]) == "none" then
  93.                     action = tostring(t[2])
  94.                 else
  95.                     sendconsoletext(player, "Invalid action! Use ban, kick, or none.")
  96.                 end
  97.                 if tonumber(t[3]) ~= nil then
  98.                     ban_time = tonumber(t[3])
  99.                 else
  100.                     sendconsoletext(player, "Invalid time! Ban time is in minutes")
  101.                 end
  102.             else
  103.                 sendconsoletext(player, "Invalid Syntax! sv_aimbot_ban [type] {score} {time}")
  104.             end
  105.         end
  106.     return response
  107. end
  108.  
  109. function score_depletion(id, count)
  110.     for i=0,15 do
  111.         if getplayer(i) ~= nil then
  112.             if tonumber(player_score[i]) > 0 then
  113.                 player_score[i] = tonumber(player_score[i]) - aimbot_score_depletion
  114.             elseif tonumber(player_score[i]) < 0 then
  115.                 player_score[i] = 0
  116.             end
  117.         end
  118.     end
  119.     return true
  120. end
  121.  
  122. function OnPlayerKill(killer, victim, mode)
  123.     camera_table[victim] = nil
  124. end
  125.  
  126. function OnPlayerSpawn(player)
  127.     camera_table[player] = nil
  128.     spawning[player] = true
  129.     registertimer(1500, "removegrace", player)
  130. end
  131.  
  132. function removegrace(id, count, player)
  133.     spawning[player] = false
  134. end
  135.  
  136. function takeaction(player)
  137.  
  138.     local log_file = getprofilepath() .. "\\logs\\Antibot.log"
  139.     local line = "(Name: %s) (Hash: %s) (IP: %s) (Ping: %s) (Score: %s) (Action: %s)"
  140.     local Line = string.format(line, getname(player), gethash(player), getip(player), getping(player), player_score[player], action)
  141.     WriteLog(log_file, Line)
  142.  
  143.     if notify_admins then
  144.         for i=0,15 do
  145.             if isadmin(i) then
  146.                 privatesay(i, "Name: " .. getname(player) .. " - Action taken: " .. action .. " - Aimbot Score:" .. tonumber(player_score[player]))
  147.             end
  148.         end
  149.     end
  150.     local player_id = resolveplayer(player)
  151.     if action == "ban" then
  152.         if ban_time then
  153.             svcmd("sv_ban " .. player_id .. " " .. ban_time .. "m")
  154.         else
  155.             svcmd("sv_ban " .. player_id)
  156.         end
  157.         player_score[player] = 0
  158.         say(getname(player) .. " has been banned from the server for aimbotting!")
  159.     elseif action == "kick" then
  160.         svcmd("sv_kick " .. player_id)
  161.         player_score[player] = 0
  162.         say(getname(player) .. " has been kicked from the server for aimbotting!")
  163.     elseif action == "none" or action == "warn" then
  164.         say(getname(player) .. " may very possibly be aimbotting! Id: " .. player_id)
  165.     end
  166. end
  167.  
  168. function OnClientUpdate(player)
  169.     checkforteleport(player)
  170.     local stop_angle = getstopangle(player)
  171.  
  172.     if stop_angle ~= nil then else stop_angle = 0 end
  173.     if not spawning[player] then
  174.         if stop_angle > snap_stop_angle then
  175.             local hitting, at_teammate, distance = Intersect(player)
  176.             if distance ~= nil then else distance = 1 end
  177.             if hitting and not at_teammate then
  178.                 --say("detected " .. getname(player) .. " - ".. stop_angle .. " - ".. distance)
  179.                 if tonumber(player_score[player]) then
  180.                     player_score[player] = tonumber(player_score[player]) + (stop_angle * 0.125 * distance)
  181.                     if tonumber(player_score[player]) > max_score then
  182.                         takeaction(player)
  183.                     end
  184.                 else
  185.                     player_score[player] = (stop_angle * 0.125 * distance)
  186.                 end
  187.             end
  188.         end
  189.     end
  190. end
  191.  
  192. function checkforteleport(player)
  193.     if x ~= loc[player][1] or y ~= loc[player][2] or z ~= loc[player][3] then
  194.         if loc[player][1] == nil then
  195.             loc[player][1] = x
  196.             loc[player][2] = y
  197.             loc[player][3] = z
  198.         elseif m_object then
  199.             distance = math.sqrt((loc[player][1] - x)^2 + (loc[player][2] - y)^2 + (loc[player][3] - z)^2)
  200.             local result = true
  201.             if distance >= 10 then result = OnPlayerTeleport(player) end
  202.             if result == 0 or not result then
  203.                 --movobjectcoords(m_objectId, loc[player][1], loc[player][2], loc[player][3])
  204.                 loc[player][1] = x
  205.                 loc[player][2] = y
  206.                 loc[player][3] = z
  207.             else
  208.                 loc[player][1] = x
  209.                 loc[player][2] = y
  210.                 loc[player][3] = z
  211.             end
  212.         end
  213.     end
  214. end
  215.  
  216. function OnPlayerTeleport(player)
  217.     spawning[player] = true
  218.     registertimer(500, "removegrace", player)
  219. end
  220.  
  221. function getstopangle(player)
  222.     local m_objectId = getplayerobjectid(player)
  223.     local m_object = getobject(m_objectId)
  224.  
  225.     local camera_x = readfloat(m_object + 0x230)
  226.     local camera_y = readfloat(m_object + 0x234)
  227.     local camera_z = readfloat(m_object + 0x238)
  228.  
  229.     if camera_table[player] == nil then
  230.         camera_table[player] = {camera_x, camera_y, camera_z}
  231.         return
  232.     end
  233.  
  234.     local last_camera_x = camera_table[player][1]
  235.     local last_camera_y = camera_table[player][2]
  236.     local last_camera_z = camera_table[player][3]
  237.  
  238.     camera_table[player] = {camera_x, camera_y, camera_z}
  239.  
  240.     if  last_camera_x == 0 and
  241.         last_camera_y == 0 and
  242.         last_camera_z == 0 then
  243.         return
  244.     end
  245.  
  246.     local movement = math.sqrt(
  247.         (camera_x - last_camera_x) ^ 2 +
  248.         (camera_y - last_camera_y) ^ 2 +
  249.         (camera_z - last_camera_z) ^ 2)
  250.  
  251.     local angle = math.acos((2 - movement ^ 2) / 2)
  252.     stop_angle = angle * 180 / math.pi
  253.  
  254.     return stop_angle
  255. end
  256.  
  257. function Intersect(player)
  258.     local player_objid = getplayerobjectid(player)
  259.     if (player_objid ~= nil) then
  260.         local m_object = getobject(player_objid)
  261.         local vx = readfloat(m_object + 0x230)
  262.         local vy = readfloat(m_object + 0x234)
  263.         local vz = readfloat(m_object + 0x238)
  264.         local px, py, pz = getobjectcoords(player_objid)
  265.         local bipd_id = readdword(m_object)
  266.         local bipd_tag = gettagaddress(bipd_id)
  267.         local bipd_data = readdword(bipd_tag + 0x14)
  268.         local standing_height = readfloat(bipd_data + 0x400)
  269.         local crouch_height = readfloat(bipd_data + 0x404)
  270.         local crouch_state = readfloat(m_object + 0x50c)
  271.  
  272.         if (crouch_state == 0) then
  273.             pz = pz + standing_height
  274.         else
  275.             pz = pz + (crouch_height * crouch_state)
  276.         end
  277.  
  278.         local hit,x,y,z,objid = halointersect(1000, px, py, pz, vx, vy, vz, player_objid)
  279.         while hit == true do
  280.             for i = 0,15 do
  281.                 if getplayer(i) ~= nil then
  282.                     local player2_objid = getplayerobjectid(i)
  283.                     if objid == player2_objid then
  284.                         hitting = true
  285.                         distance = math.sqrt((x - px) ^ 2 + (y - py) ^ 2 + (z - pz) ^ 2)
  286.                         --say(getname(player) .. " is aiming at " .. getname(i))
  287.                         if getteam(player) == getteam(i) then
  288.                             at_teamate = true
  289.                         else
  290.                             at_teamate = false
  291.                         end
  292.                     else
  293.                         hitting = false
  294.                     end
  295.                 end
  296.             end
  297.             break
  298.         end
  299.     end
  300.     return hitting, at_teammate, distance
  301. end
  302.  
  303. function math.round(number, place)
  304.     return math.floor(number * ( 10 ^ (place or 0) ) + 0.5) / ( 10 ^ (place or 0) )
  305. end
  306.  
  307. function checkState(state, location_z)
  308.     if state == 2 then
  309.         return location_z + 0.6
  310.     elseif state == 3 then
  311.         return location_z + 0.3
  312.     end
  313.     return nil
  314. end
  315.  
  316. function WriteLog(filename, value)
  317.     if logging_enabled then
  318.         local file = io.open(filename, "a")
  319.         if file then
  320.             file:write( string.format("%s\t%s\n", os.date("!%m/%d/%Y %H:%M:%S"), tostring(value) ) )
  321.             file:close()
  322.         end
  323.     end
  324. end
  325.  
  326. function getping(player)
  327.     local m_player = getplayer(player)
  328.     if m_player then return readword(m_player + 0xDC) end
  329. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement