Advertisement
it300

Anti-Aimbot v3.5 - Phasor 2.0

Oct 21st, 2014
545
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.06 KB | None | 0 0
  1. --[[Phasor Anti-Aimbot Script v3.5]]--
  2. --[[Creators: Wizard & Skylace]]--
  3. --[[Converted for phasor v2 thanks to the help of AelitePrime]]--
  4. --[[Xfires: th3w1zard3, it300, and eliteprime14789x]]--
  5. --[[Websites: http://www.halopcservers.com & http://phasorscripts.wordpress.com/ ]]--
  6. --[[Thanks to others who helped test the script]]--
  7.  
  8. max_score = 100                                 --Score needed before an action is taken on the player.(Recomended it to be between 100 and 200)
  9. score_timeout = 2.5                             --Time needed for a player to loose a specified amount of points. (In seconds)
  10. points_reduced = 1                              --Points that will be lost when the timeout has been reached.
  11. max_ping = 500                                  --Max Ping the server will look at to see if a player is aimbotting.
  12. warnings_needed = 1                             --warnings needed before an action is taken.
  13. default_action = "kick"                         --Action the server will take if a player is cought. (Use notify, kick, or ban)
  14. default_ban_time = 0                            --How long the player will be banned. 0 = indefinite.
  15. logwarnings = true                              --Logs snaps and warnings to AimbotBans.log.
  16. notify_player = false                           --Should the player be notified that they have been suspected of aimbotting.
  17. notify_admins = true                            --Should admins be notified that a player has been suspected of aimbotting.
  18. notify_server = true                            --Should the server be notified that a player has been suspected of aimbotting. (Means everyone)
  19. same_team_detect = true                         --Should it check if they are on he same team? (Recomended)
  20. snap_max_angle = 180                            --Max snap angle detectable. (180 Recomended)
  21. snap_min_angle = 4                              --Min snap angle detectable. (5 Recomended)
  22. snap_stop_angle = 3                         --I recomend anywhere from 2.5 to 4.5
  23. degrees_subtracted = 0.015                      --Degrees removed after the specified distance_variable.
  24. distance_variable = 4.5                         --Distance needed to subtract the amount of degrees above.
  25.  
  26. --[[This is the table of what degree snaps will give the amount of score. It is used like so...
  27. score_snap_angle =  {{Degree, Degree, Score Added},
  28.     {50, 90, 50}, {90, 120, 60}
  29. }
  30. ]]--
  31.  
  32. score_snap_angle =  {
  33.     {4, 8, 10}, {9, 14, 15},
  34.     {15, 20, 17}, {21, 26, 19},
  35.     {25, 32, 21}, {33, 38, 23},
  36.     {39, 44, 25}, {45, 50, 27},
  37.     {51, 56, 29}, {57, 62, 31},
  38.     {63, 68, 33}, {69, 74, 33},
  39.     {75, 80, 27}, {81, 86, 25},
  40.     {85, 92, 23}, {92, 98, 21},
  41.     {99, 180, 19}
  42. }
  43.  
  44. --[[Do not change anything below this point]]--
  45. camera_table = {}
  46. watch_table = {}
  47. snap_table = {}
  48. warning_table = {}
  49. snap_angle = {}
  50. player_score = {}
  51. isSpawning = {}
  52. actionTaken = {}
  53. loc = {}
  54.  
  55. function GetRequiredVersion()
  56.     return 200
  57. end
  58.  
  59. --[[Called when a player has been suspected of aimbotting. This is called before the player has been tallied for snapping.
  60. The return value determines if the player should be tallied. Returning true tallies the player, returning false doesn't]]--
  61.  
  62. function OnAimbotDetection(player)
  63.     return (not isSpawning[player] )
  64. end
  65.  
  66. function OnScriptLoad(process, game, persistent)
  67.     if game == "PC" then
  68.         network_server_globals = 0x69B934
  69.     else
  70.         network_server_globals = 0x61FB64
  71.     end
  72.     for i = 0,15 do
  73.         loc[i] = {}
  74.         player_score[i] = 0
  75.     end
  76.     log_file = getprofilepath() .. "\\logs\\Antibot.log"
  77.     registertimer(score_timeout * 1000, "ScoreTimeoutTimer", points_reduced)
  78. end
  79.  
  80. function OnServerCommand(player, command, password)
  81.     local response = nil
  82.     t = tokenizecmdstring(command)
  83.     count = #t
  84.     if password == readstring(network_server_globals + 0x128) then
  85.         if t[1] == "sv_getscore" then
  86.             response = 0
  87.             if rresolveplayer(t[2]) then
  88.                 sendconsoletext(player, tostring(player_score[rresolveplayer(t[2])]))
  89.             else
  90.                 sendconsoletext(player, "Invalid Player!")
  91.             end
  92.         elseif t[1] == "sv_getscores" then
  93.             resonse = 0
  94.             sendconsoletext(player, "Name  |  Score")
  95.             for i = 0,15 do
  96.                 if getplayer(i) then
  97.                     sendconsoletext(player, getname(i) .. "  |  " .. player_score[i])
  98.                 end
  99.             end
  100.         elseif t[1] == "sv_scorelimit" then
  101.             response = false
  102.             if tonumber(t[2]) then
  103.                 if t[2] > 75 then
  104.                     max_score = (t[2])
  105.                 else
  106.                     sendconsoletext(player, "Hey, you don't want to go below 75 trust me.")
  107.                 end
  108.             else
  109.                 sendconsoletext(player, "Invalid Syntax! sv_scorelimit [number]")
  110.             end
  111.         elseif t[1] == "sv_aimbot_action" or cmd == "sv_aimbot_ban" then
  112.             response = false
  113.             if t[2] then
  114.                 if t[2] == "notify" or t[2] == "kick" then
  115.                     if not t[3] then
  116.                         default_action = t[2]
  117.                     else
  118.                         sendconsoletext(player, "Cannot set ban time with action as kick or notify!")
  119.                     end
  120.                 elseif t[2] == "ban" then
  121.                     if t[3] then
  122.                         default_ban_time = t[3]
  123.                     else
  124.                         sendconsoletext(player, "BAN SYNTAX = sv_aimbot_action ban [time(1m, 1d, 1m, or 1y)]")
  125.                     end
  126.                 else
  127.                     sendconsoletext(player, "Invalid action!")
  128.                 end
  129.             else
  130.                 sendconsoletext(player, "Invalid Syntax! sv_aimbot_action [action(notify, ban, or kick)]")
  131.             end
  132.         end
  133.     end
  134.     return response
  135. end
  136.  
  137. function OnPlayerJoin(player)
  138.     snap_angle[player] = 0
  139.     warning_table[player] = 0
  140.     player_score[player] = 0
  141. end
  142.  
  143. function OnPlayerLeave(player)
  144.     camera_table[player] = nil
  145.     watch_table[player] = nil
  146.     snap_angle[player] = nil
  147.     warning_table[player] = nil
  148.     player_score[player] = 0
  149.     actionTaken[player] = nil
  150. end
  151.  
  152. function OnPlayerKill(killer, victim, mode)
  153.     camera_table[victim] = nil
  154.     watch_table[victim] = nil
  155.     snap_angle[victim] = 0
  156. end
  157.  
  158. function OnPlayerSpawn(player)
  159.     camera_table[player] = nil
  160.     watch_table[player] = nil
  161.     snap_angle[player] = 0
  162.     isSpawning[player] = true
  163.     registertimer(500, "playerIsSpawning", player)
  164. end
  165.  
  166. function OnPlayerSpawnEnd(player)
  167.     camera_table[player] = nil
  168.     watch_table[player] = nil
  169.     snap_angle[player] = 0
  170. end
  171.  
  172. function OnClientUpdate(player)
  173.  
  174.     local m_objectId = getplayerobjectid( player )
  175.     local m_object = getobject( m_objectId )
  176.     local x,y,z = getobjectcoords( m_objectId )
  177.  
  178.     local distance
  179.     if x ~= loc[player][1] or y ~= loc[player][2] or z ~= loc[player][3] then
  180.         if loc[player][1] == nil then
  181.             loc[player][1] = x
  182.             loc[player][2] = y
  183.             loc[player][3] = z
  184.         elseif m_object then
  185.             distance = math.sqrt((loc[player][1] - x)^2 + (loc[player][2] - y)^2 + (loc[player][3] - z)^2)
  186.             local result = true
  187.             if distance >= 10 then result = OnPlayerTeleport( player ) end
  188.             if result == 0 or not result then
  189.                 movobjectcoords(m_objectId, loc[player][1], loc[player][2], loc[player][3])
  190.             else
  191.                 loc[player][1] = x
  192.                 loc[player][2] = y
  193.                 loc[player][3] = z
  194.             end
  195.         end
  196.     end
  197.  
  198.     local camera_x = readfloat(m_object + 0x230)
  199.     local camera_y = readfloat(m_object + 0x234)
  200.     local camera_z = readfloat(m_object + 0x238)
  201.  
  202.     if camera_table[player] == nil then
  203.         camera_table[player] = {camera_x, camera_y, camera_z}
  204.         return
  205.     end
  206.  
  207.     local last_camera_x = camera_table[player][1]
  208.     local last_camera_y = camera_table[player][2]
  209.     local last_camera_z = camera_table[player][3]
  210.  
  211.     camera_table[player] = {camera_x, camera_y, camera_z}
  212.  
  213.     if  last_camera_x == 0 and
  214.         last_camera_y == 0 and
  215.         last_camera_z == 0 then
  216.         return
  217.     end
  218.  
  219.     local movement = math.sqrt(
  220.         (camera_x - last_camera_x) ^ 2 +
  221.         (camera_y - last_camera_y) ^ 2 +
  222.         (camera_z - last_camera_z) ^ 2)
  223.  
  224.     local angle = math.acos((2 - movement ^ 2) / 2)
  225.     angle = angle * 180 / math.pi
  226.  
  227.     if watch_table[player] ~= nil then
  228.         watch_table[player] = nil
  229.         local value = ( snap_stop_angle - ( degrees_subtracted * ( ( distance or 0 ) / distance_variable ) ) )
  230.         if angle < value and OnAimbotDetection(player) then
  231.             for i = 0, 15 do
  232.                 if IsLookingAt(player, i) then
  233.                     TallyPlayer(player)
  234.                     break
  235.                 end
  236.             end
  237.         end
  238.         return
  239.     end
  240.     if angle > snap_min_angle and angle < snap_max_angle then
  241.         watch_table[player] = true
  242.         snap_angle[player] = angle
  243.     end
  244. end
  245.  
  246. function OnPlayerTeleport( player )
  247.     isSpawning[player] = true
  248.     registertimer(600, "playerIsSpawning", player)
  249.     return true
  250. end
  251.  
  252. function playerIsSpawning(id, count, player)
  253.     isSpawning[player] = false
  254.     return false
  255. end
  256.  
  257. function ScoreTimeoutTimer(id, count, score_depletion)
  258.     for i = 0,15 do
  259.         if player_score[i] and player_score[i] ~= 0  then
  260.             player_score[i] = player_score[i] - score_depletion
  261.             if player_score[i] <= 0 then
  262.                 player_score[i] = 0
  263.             end
  264.         end
  265.     end
  266.     return true
  267. end
  268.  
  269. function TallyPlayer(player)
  270.     if getplayer(player) == nil then
  271.         return
  272.     end
  273.     if getping(player) <= max_ping then
  274.         for i = 1,#score_snap_angle do
  275.             if snap_angle[player] >= score_snap_angle[i][1] and snap_angle[player] <= score_snap_angle[i][2] then
  276.                 player_score[player] = player_score[player] + score_snap_angle[i][3]
  277.                 hprintf(tostring(getname(player)) .. " now has added " .. tostring(score_snap_angle[i][3]))
  278.                 break
  279.             end
  280.         end
  281.         if player_score[player] >= max_score then
  282.             if warning_table[player] == nil then warning_table[player] = 0 end
  283.             warning_table[player] = warning_table[player] + 1
  284.             if warning_table[player] >= warnings_needed and not actionTaken[player] then
  285.                 if default_action == "kick" then
  286.                     svcmd("sv_crash " .. resolveplayer(player))
  287.                     if notify_player then
  288.                         privatesay(player, "You have been kicked for aimbotting.")
  289.                     end
  290.                     if notify_admins then
  291.                         for i = 0, 15 do
  292.                             if getplayer(i) ~= nil and isadmin(i) then
  293.                                 privatesay(i, getname(player) .. " was kicked for aimbotting.")
  294.                             end
  295.                         end
  296.                     end
  297.                     if notify_server then
  298.                         for i = 0, 15 do
  299.                             if getplayer(i) ~= nil then
  300.                                 if not isadmin(i) then
  301.                                     privatesay(i, getname(player) .. " was kicked for aimbotting.")
  302.                                 end
  303.                             end
  304.                         end
  305.                     end
  306.                 elseif default_action == "notify" then
  307.                     if notify_player then
  308.                         privatesay(player, "You have been suspected of aimbotting.")
  309.                     end
  310.                     if notify_admins then
  311.                         for i = 0, 15 do
  312.                             if getplayer(i) ~= nil and isadmin(i) then
  313.                                 privatesay(i, getname(player) .. " is suspected of aimbotting.")
  314.                             end
  315.                         end
  316.                     end
  317.                     if notify_server then
  318.                         for i = 0, 15 do
  319.                             if getplayer(i) ~= nil then
  320.                                 if not isadmin(i) then
  321.                                     privatesay(i, getname(player) .. " is suspected of aimbotting.")
  322.                                 end
  323.                             end
  324.                         end
  325.                     end
  326.                 elseif default_action == "ban" then
  327.                     svcmd("sv_ban " .. resolveplayer(player) .. " " .. default_ban_time)
  328.                     if notify_player then
  329.                         privatesay(player, "You have been banned for aimbotting.")
  330.                     end
  331.                     if notify_admins then
  332.                         for i = 0, 15 do
  333.                             if getplayer(i) ~= nil and isadmin(i) then
  334.                                 privatesay(i, getname(player) .. " was banned for aimbotting.")
  335.                             end
  336.                         end
  337.                     end
  338.                     if notify_server then
  339.                         for i = 0, 15 do
  340.                             if getplayer(i) ~= nil then
  341.                                 if not isadmin(i) then
  342.                                     privatesay(i, getname(player) .. " was banned for aimbotting.")
  343.                                 end
  344.                             end
  345.                         end
  346.                     end
  347.                 end
  348.                 actionTaken[player] = true
  349.             end
  350.         end
  351.         if logwarnings and actionTaken[player] == true then
  352.             local name = getname(player)
  353.             if not name then say("NAME IS NIL") end
  354.             local hash = gethash(player)
  355.             if not hash then say("HASH IS NIL") end
  356.             local ip = getip(player)
  357.             if not ip then say("IP IS NIL") end
  358.             local ping = getping(player)
  359.             if not ping then say("PING IS NIL") end
  360.             local line = "(Name: %s) (Hash: %s) (IP: %s) (ping: %s). Score: %s Action: %s"
  361.             if not log_file then say("LOGFILE IS NIL") end
  362.             line = string.format(line, name, hash, ip, ping, player_score[player], default_action)
  363.             WriteLog(log_file, line)
  364.         else
  365.         end
  366.     end
  367. end
  368.  
  369. function sayExcept(message, player)
  370.     for i = 0, 15 do
  371.         if i ~= player then
  372.             privatesay(i, message)
  373.         end
  374.     end
  375. end
  376.  
  377. function getping(player)
  378.     local m_player = getplayer(player)
  379.     if m_player then return readword(m_player + 0xDC) end
  380. end
  381.  
  382. function IsLookingAt(player1, player2)
  383.  
  384.     if getplayer(player1) == nil or getplayer(player2) == nil then -- Check if player slots are in use
  385.         return
  386.     end
  387.  
  388.     local m_playerObjId1 = getplayerobjectid( player1 )
  389.     local m_playerObjId2 = getplayerobjectid( player2 )
  390.  
  391.     if m_playerObjId1 == nil or m_playerObjId2 == nil then -- Checks if players are alive
  392.         return
  393.     end
  394.  
  395.     if same_team_detect and getteam( player1 ) == getteam( player2 ) then -- Checks if players are on the same team.
  396.         return false
  397.     end
  398.  
  399.     local m_object1 = getobject( m_playerObjId1 )
  400.     local m_object2 = getobject( m_playerObjId2 )
  401.     local camera_x = math.round( readfloat(m_object1 + 0x230) , 1)
  402.     local camera_y = math.round( readfloat(m_object1 + 0x234) , 1)
  403.     local camera_z = math.round( readfloat(m_object1 + 0x238) , 1)
  404.     local location1_x = readfloat(m_object1 + 0x5C)
  405.     local location1_y = readfloat(m_object1 + 0x60)
  406.     local location1_z = checkState( readbyte(m_object1 + 0x2A7) , readfloat(m_object1 + 0x64) )
  407.     local location2_x = readfloat(m_object2 + 0x5C)
  408.     local location2_y = readfloat(m_object2 + 0x60)
  409.     local location2_z = checkState( readbyte(m_object2 + 0x2A7) , readfloat(m_object2 + 0x64) )
  410.  
  411.     if location1_z == nil  or location2_z == nil then
  412.         return
  413.     end
  414.  
  415.     local local_x = (location2_x - location1_x)
  416.     local local_y = (location2_y - location1_y)
  417.     local local_z = (location2_z - location1_z)
  418.  
  419.     local radius = math.sqrt( (local_x) ^ 2 + (local_y) ^ 2 + (local_z) ^ 2 )
  420.  
  421.     local point_x = math.round(1 / radius * local_x, 1)
  422.     local point_y = math.round(1 / radius * local_y, 1)
  423.     local point_z = math.round(1 / radius * local_z, 1)
  424.  
  425.     local isLookingAt = (camera_x == point_x and camera_y == point_y and camera_z == point_z)
  426.     return isLookingAt
  427.  
  428. end
  429.  
  430. function checkState(state, location_z)
  431.     if state == 2 then
  432.         return location_z + 0.6
  433.     elseif state == 3 then
  434.         return location_z + 0.3
  435.     end
  436.     return nil
  437. end
  438.  
  439. function sendresponse(message, player)
  440.     if player then
  441.         sendconsoletext(player, message)
  442.     else
  443.         hprintf(message)
  444.     end
  445. end
  446.  
  447. function math.round(number, place)
  448.     return math.floor(number * ( 10 ^ (place or 0) ) + 0.5) / ( 10 ^ (place or 0) )
  449. end
  450.  
  451. function WriteLog(filename, value)
  452.     local file = io.open(filename, "a")
  453.     if file then
  454.         file:write( string.format("%s\t%s\n", os.date("!%m/%d/%Y %H:%M:%S"), tostring(value) ) )
  455.         file:close()
  456.     end
  457. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement