Advertisement
it300

Anti-Aimbot v3.5 - Phasor 0583

Oct 21st, 2014
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.66 KB | None | 0 0
  1. --[[Phasor Anti-Aimbot Script v3.5]]--
  2. --[[Creators: Wizard & Skylace]]--
  3. --[[Xfires: th3w1zard3, and it300]]--
  4. --[[Website: http://bud.boards.net ]]--
  5. --[[Thanks to others who helped test the script]]--
  6.  
  7. max_score = 100             --Score needed before action is taken on the player.(Recomended it to be between 100 and 200)
  8. score_timeout = 2.5         --Time needed for a player to loose a specified amount of points. (In seconds)
  9. points_reduced = 1          --Points that will be lost when the timeout has been reached.
  10. max_ping = 500              --Max Ping the server will look at to see if a player is aimbotting.
  11. warnings_needed = 1         --warnings needed before an action is taken.
  12. default_action = "kick" --Action the server will take if a player is cought. (Use notify, kick, or ban)
  13. default_ban_time = 0        --How long the player will be banned. 0 = indefinite.
  14. logwarnings = true          --Logs snaps and warnings to Antibot.log.
  15. notify_player = false       --Should the player be notified that they have been suspected of aimbotting.
  16. notify_admins = true        --Should admins be notified that a player has been suspected of aimbotting.
  17. notify_server = true        --Should the server be notified that a player has been suspected of aimbotting. (Means everyone)
  18. same_team_detect = true     --Should it check if they are on he same team? (Recomended)
  19. snap_max_angle = 180        --Max snap angle detectable. (180 Recomended)
  20. snap_min_angle = 5          --Min snap angle detectable. (5 Recomended)
  21. snap_stop_angle = 3     --I recomend anywhere from 2.5 to 4.5
  22. degrees_subtracted = 0.015  --Degrees removed after the specified distance_variable.
  23. distance_variable = 4.5     --Distance needed to subtract the amount of degrees above.
  24.  
  25. --[[This is the table of what degree snaps will give the amount of score. It is used like so...
  26. score_snap_angle =  {{Degree, Degree, Score Added},
  27.                     {50, 90, 50},
  28.                     {90, 120, 60}
  29. }
  30.  
  31. ]]--
  32.  
  33. score_snap_angle =  {
  34.     {4, 8, 10},
  35.     {9, 14, 15},
  36.     {15, 20, 17},
  37.     {21, 26, 19},
  38.     {25, 32, 21},
  39.     {33, 38, 23},
  40.     {39, 44, 25},
  41.     {45, 50, 27},
  42.     {51, 56, 29},
  43.     {57, 62, 31},
  44.     {63, 68, 33},
  45.     {69, 74, 33},
  46.     {75, 80, 27},
  47.     {81, 86, 25},
  48.     {85, 92, 23},
  49.     {92, 98, 21},
  50.     {99, 180, 19}
  51. }
  52.  
  53. --[[Do not change anything below this point]]--
  54. camera_table = {}
  55. watch_table = {}
  56. snap_table = {}
  57. warning_table = {}
  58. snap_angle = {}
  59. player_score = {}
  60. isSpawning = {}
  61. actionTaken = {}
  62. loc = {}
  63.  
  64. --[[Called when a player has been suspected of aimbotting. This is called before the player has been tallied for snapping.
  65. The return value determines if the player should be tallied. Returning true tallies the player, returning false doesn't]]--
  66. function OnAimbotDetection(player)
  67.     if isSpawning[player] then
  68.         return false
  69.     end
  70.     return true
  71. end
  72.  
  73. function GetRequiredVersion()
  74.     return 10057
  75. end
  76.  
  77. function OnScriptLoad(process)
  78.     hprintf("Antibot Loaded")
  79.     for i = 0,15 do
  80.         loc[i] = {}
  81.     end
  82.     profile_path = getprofilepath()
  83.     log_file = profile_path .. "\\logs\\Antibot.log"
  84.     registertimer(score_timeout * 1000, "ScoreTimeoutTimer", points_reduced)
  85. end
  86.  
  87. function ScoreTimeoutTimer(id, count, score_depletion)
  88.     for i = 0,15 do
  89.         if player_score[i] then
  90.             if player_score[i] ~= 0 then
  91.                 player_score[i] = player_score[i] - score_depletion
  92.                 if player_score[i] <= 0 then
  93.                     player_score[i] = 0
  94.                 end
  95.             end
  96.         end
  97.     end
  98.     return 1
  99. end
  100.  
  101. function OnScriptUnload()
  102. end
  103.  
  104. function OnNewGame(map)
  105. end
  106.  
  107. function OnGameEnd(mode)
  108. end
  109.  
  110. function OnServerChat(player, mode, msg)
  111.     return 1
  112. end
  113.  
  114. function OnServerCommand(player, command)
  115.     local response = 1
  116.     local count = getcmdtokencount(command)
  117.     local cmd = getcmdtoken(command, 0)
  118.     local hash = gethash(player)
  119.     t = {}
  120.  
  121.     for i=1,count do
  122.         local word = getcmdtoken(command, i - 1)
  123.         word = string.lower(word)
  124.         table.insert(t, word)
  125.     end
  126.  
  127.         if t[1] == "sv_getscore" then
  128.             response = 0
  129.             if rresolveplayer(t[2]) then
  130.                 hprintf(tostring(player_score[rresolveplayer(t[2])]), player)
  131.             else
  132.                 hprintf("Invalid Player!", player)
  133.             end
  134.         elseif t[1] == "sv_getscores" then
  135.             resonse = 0
  136.             hprintf("Name  |  Score", player)
  137.             for i = 0,15 do
  138.                 if getplayer(i) then
  139.                     hprintf(getname(i) .. "  |  " .. player_score[i], player)
  140.                 end
  141.             end
  142.         elseif t[1] == "sv_scorelimit" then
  143.             response = false
  144.             if tonumber(t[2]) then
  145.                 if t[2] > 75 then
  146.                     max_score = (t[2])
  147.                 else
  148.                     hprintf("Hey, you don't want to go below 75 trust me.", player)
  149.                 end
  150.             else
  151.                 hprintf("Invalid Syntax! sv_scorelimit [number]", player)
  152.             end
  153.         elseif t[1] == "sv_aimbot_action" or cmd == "sv_aimbot_ban" then
  154.             response = false
  155.             if t[2] then
  156.                 if t[2] == "notify" or t[2] == "kick" then
  157.                     if not t[3] then
  158.                         default_action = t[2]
  159.                     else
  160.                         hprintf("Cannot set ban time with action as kick or notify!", player)
  161.                     end
  162.                 elseif t[2] == "ban" then
  163.                     if t[3] then
  164.                         default_ban_time = t[3]
  165.                     else
  166.                         hprintf("BAN SYNTAX = sv_aimbot_action ban [time(1m, 1d, 1m, or 1y)]", player)
  167.                     end
  168.                 else
  169.                     hprintf("Invalid action!", player)
  170.                 end
  171.             else
  172.                 hprintf("Invalid Syntax! sv_aimbot_action [action(notify, ban, or kick)]", player)
  173.             end
  174.         end
  175.  
  176.     return response
  177. end
  178.  
  179. function OnTeamDecision(team)
  180.     return team
  181. end
  182.  
  183. function OnPlayerJoin(player, team)
  184.     snap_angle[player] = 0
  185.     warning_table[player] = 0
  186.     player_score[player] = 0
  187. end
  188.  
  189. function OnPlayerLeave(player, team)
  190.     camera_table[player] = nil
  191.     watch_table[player] = nil
  192.     snap_angle[player] = nil
  193.     warning_table[player] = nil
  194.     player_score[player] = 0
  195.     actionTaken[player] = nil
  196. end
  197.  
  198. function OnPlayerKill(killer, victim, mode)
  199.     camera_table[victim] = nil
  200.     watch_table[victim] = nil
  201.     snap_angle[victim] = 0
  202. end
  203.  
  204. function OnKillMultiplier(player, multiplier)
  205. end
  206.  
  207. function OnPlayerSpawn(player, object)
  208.     camera_table[player] = nil
  209.     watch_table[player] = nil
  210.     snap_angle[player] = 0
  211.     isSpawning[player] = registertimer(500, "playerIsSpawning", player)
  212. end
  213.  
  214. function OnPlayerSpawnEnd(player, object)
  215.     camera_table[player] = nil
  216.     watch_table[player] = nil
  217.     snap_angle[player] = 0
  218. end
  219.  
  220. function playerIsSpawning(id, count, player)
  221.     isSpawning[player] = nil
  222.     return 0
  223. end
  224.  
  225. function OnTeamChange(relevant, player, team, change)
  226.     return 1
  227. end
  228.  
  229. function OnClientUpdate(player, object)
  230.  
  231.     local m_player = getplayer(player)
  232.  
  233.     if m_player == nil then
  234.         return
  235.     end
  236.  
  237.     local m_objectId = readdword(m_player, 0x34)
  238.     local m_object = getobject(m_objectId)
  239.  
  240.     if m_object == nil then
  241.         return
  242.     end
  243.  
  244.     local x,y,z = getobjectcoords(m_objectId)
  245.     local distance
  246.     if x ~= loc[player][1] or y ~= loc[player][2] or z ~= loc[player][3] then
  247.         if loc[player][1] == nil then
  248.             loc[player][1] = x
  249.             loc[player][2] = y
  250.             loc[player][3] = z
  251.         elseif m_object then
  252.             distance = math.sqrt((loc[player][1] - x)^2 + (loc[player][2] - y)^2 + (loc[player][3] - z)^2)
  253.             local result = OnPositionUpdate(player, m_objectId, x, y, z, loc[player][1], loc[player][2], loc[player][3], distance)
  254.             if distance >= 10 then
  255.                 result = OnPlayerTeleport(player, m_objectId, x, y, z, loc[player][1], loc[player][2], loc[player][3], distance)
  256.             end
  257.             if result == 0 or not result then
  258.                 movobjcoords(m_objectId, loc[player][1], loc[player][2], loc[player][3])
  259.             else
  260.                 loc[player][1] = x
  261.                 loc[player][2] = y
  262.                 loc[player][3] = z
  263.             end
  264.         end
  265.     end
  266.  
  267.     local camera_x = readfloat(m_object, 0x230)
  268.     local camera_y = readfloat(m_object, 0x234)
  269.     local camera_z = readfloat(m_object, 0x238)
  270.  
  271.     if camera_table[player] == nil then
  272.         camera_table[player] = {camera_x, camera_y, camera_z}
  273.         return
  274.     end
  275.  
  276.     local last_camera_x = camera_table[player][1]
  277.     local last_camera_y = camera_table[player][2]
  278.     local last_camera_z = camera_table[player][3]
  279.  
  280.     camera_table[player] = {camera_x, camera_y, camera_z}
  281.  
  282.     if last_camera_x == 0 and
  283.         last_camera_y == 0 and
  284.         last_camera_z == 0 then
  285.         return
  286.     end
  287.  
  288.     local movement = math.sqrt(
  289.         (camera_x - last_camera_x) ^ 2 +
  290.         (camera_y - last_camera_y) ^ 2 +
  291.         (camera_z - last_camera_z) ^ 2)
  292.  
  293.     local angle = math.acos((2 - movement ^ 2) / 2)
  294.     angle = angle * 180 / math.pi
  295.  
  296.     if watch_table[player] ~= nil then
  297.         watch_table[player] = nil
  298.         if angle < (snap_stop_angle-(degrees_subtracted*((distance or 0)/distance_variable))) then
  299.             for i = 0, 15 do
  300.                 if IsLookingAt(player, i) then
  301.                     if OnAimbotDetection(player) then
  302.                         TallyPlayer(player)
  303.                         break
  304.                     end
  305.                     return
  306.                 end
  307.             end
  308.         end
  309.         return
  310.     end
  311.     if angle > snap_min_angle and angle < snap_max_angle then
  312.         watch_table[player] = true
  313.         snap_angle[player] = angle
  314.     end
  315. end
  316.  
  317. function OnPositionUpdate(player, m_objectId, x, y, z, x2, y2, z2, distance)
  318.     return true
  319. end
  320.  
  321. function OnPlayerTeleport(player, m_objectId, x, y, z, x2, y2, z2, distance)
  322.     isSpawning[player] = registertimer(600, "playerIsSpawning", player)
  323.     return true
  324. end
  325.  
  326. function OnObjectInteraction(player, object, tag_type, tag_name)
  327.     return 1
  328. end
  329.  
  330. function OnWeaponReload(player, weapon)
  331.     return 1
  332. end
  333.  
  334. function OnVehicleEntry(relevant, player, vehicle, tag_name, seat)
  335.     return 1
  336. end
  337.  
  338. function OnVehicleEject(player, forced)
  339.     return 1
  340. end
  341.  
  342. function OnDamageLookup(receiver, causer, tag_data, tag_name)
  343. end
  344.  
  345. function OnWeaponAssignment(player, object, count, tag_name)
  346.     return 0
  347. end
  348.  
  349. function OnObjectCreation(object, owner, tag_name)
  350. end
  351.  
  352. function TallyPlayer(player)
  353.     local player_ping = getping(player)
  354.     if player_ping <= max_ping then
  355.         if getplayer(player) == nil then
  356.             return
  357.         end
  358.         for i = 1,#score_snap_angle do
  359.             if snap_angle[player] >= score_snap_angle[i][1] and snap_angle[player] <= score_snap_angle[i][2] then
  360.                 player_score[player] = player_score[player] + score_snap_angle[i][3]
  361.                 hprintf(tostring(getname(player)) .. " now has added " .. tostring(score_snap_angle[i][3]))
  362.                 break
  363.             end
  364.         end
  365.         if player_score[player] >= max_score then
  366.             if warning_table[player] == nil then
  367.                 warning_table[player] = 0
  368.             end
  369.             warning_table[player] = warning_table[player] + 1
  370.             if warning_table[player] >= warnings_needed then
  371.                 if not actionTaken[player] then
  372.                     if default_action == "kick" then
  373.                         svcmd("sv_kick " .. resolveplayer(player))
  374.                         if notify_player then
  375.                             privatesay(player, "You have been kicked for aimbotting.")
  376.                         end
  377.                         if notify_admins then
  378.                             for i = 0, 15 do
  379.                                 if getplayer(i) ~= nil and isadmin(i) then
  380.                                     privatesay(i, getname(player) .. " was kicked for aimbotting.")
  381.                                 end
  382.                             end
  383.                         end
  384.                         if notify_server then
  385.                             for i = 0, 15 do
  386.                                 if getplayer(i) ~= nil then
  387.                                     if not isadmin(i) then
  388.                                         privatesay(i, getname(player) .. " was kicked for aimbotting.")
  389.                                     end
  390.                                 end
  391.                             end
  392.                         end
  393.                     elseif default_action == "notify" then
  394.                         if notify_player then
  395.                             privatesay(player, "You have been suspected of aimbotting.")
  396.                         end
  397.                         if notify_admins then
  398.                             for i = 0, 15 do
  399.                                 if getplayer(i) ~= nil and isadmin(i) then
  400.                                     privatesay(i, getname(player) .. " is suspected of aimbotting.")
  401.                                 end
  402.                             end
  403.                         end
  404.                         if notify_server then
  405.                             for i = 0, 15 do
  406.                                 if getplayer(i) ~= nil then
  407.                                     if not isadmin(i) then
  408.                                         privatesay(i, getname(player) .. " is suspected of aimbotting.")
  409.                                     end
  410.                                 end
  411.                             end
  412.                         end
  413.                     elseif default_action == "ban" then
  414.                         svcmd("sv_ban " .. resolveplayer(player) .. " " .. default_ban_time)
  415.                         if notify_player then
  416.                             privatesay(player, "You have been banned for aimbotting.")
  417.                         end
  418.                         if notify_admins then
  419.                             for i = 0, 15 do
  420.                                 if getplayer(i) ~= nil and isadmin(i) then
  421.                                     privatesay(i, getname(player) .. " was banned for aimbotting.")
  422.                                 end
  423.                             end
  424.                         end
  425.                         if notify_server then
  426.                             for i = 0, 15 do
  427.                                 if getplayer(i) ~= nil then
  428.                                     if not isadmin(i) then
  429.                                         privatesay(i, getname(player) .. " was banned for aimbotting.")
  430.                                     end
  431.                                 end
  432.                             end
  433.                         end
  434.                     end
  435.                     actionTaken[player] = true
  436.                 end
  437.             end
  438.         end
  439.         if logwarnings and actionTaken[player] == true then
  440.             local hash = gethash(player)
  441.             if not hash then say("HASH IS NIL") end
  442.             local ip = getip(player)
  443.             if not ip then say("IP IS NIL") end
  444.             local ping = getping(player)
  445.             if not ping then say("PING IS NIL") end
  446.             local name = getname(player)
  447.             if not name then say("NAME IS NIL") end
  448.             local line = "%s (%s) was banned. (Hash: %s) (IP: %s) (ping: %s). Score: %s Action: %s"
  449.             if not log_file then say("LOGFILE IS NIL") end
  450.             line = string.format(line, name, hash, ip, ping, player_score[player], default_action)
  451.             WriteLog(log_file, line)
  452.         else
  453.         end
  454.     end
  455. end
  456.  
  457. function WriteLog(filename, value)
  458.     local file = io.open(filename, "a")
  459.     if file then
  460.         local timestamp = os.date("!%m/%d/%Y %H:%M:%S")
  461.         local line = string.format("%s\t%s\n", timestamp, tostring(value))
  462.         file:write(line)
  463.         file:close()
  464.     else
  465.         hprintf("LOG FILE IS NIL")
  466.     end
  467. end
  468.  
  469. function getping(player)
  470.     local m_player = getplayer(player)
  471.  
  472.     if not m_player then
  473.         return
  474.     end
  475.  
  476.     local ping = readword(m_player, 0xDC)
  477.  
  478.     return ping
  479. end
  480.  
  481. function IsLookingAt(player1, player2)
  482.     local m_player1 = getplayer(player1)
  483.     local m_player2 = getplayer(player2)
  484.  
  485.     if same_team_detect then
  486.         local team1 = readbyte(m_player1, 0x20)
  487.         local team2 = readbyte(m_player2, 0x20)
  488.         if team1 == team2 then
  489.             return false
  490.         end
  491.     end
  492.  
  493.     if m_player1 == nil or m_player2 == nil then
  494.         return
  495.     end
  496.  
  497.     local object1 = readdword(m_player1, 0x34)
  498.     local object2 = readdword(m_player2, 0x34)
  499.     local m_object1 = getobject(object1)
  500.     local m_object2 = getobject(object2)
  501.  
  502.     if m_object1 == nil or m_object2 == nil then
  503.         return
  504.     end
  505.  
  506.     local camera_x = readfloat(m_object1, 0x230)
  507.     local camera_y = readfloat(m_object1, 0x234)
  508.     local camera_z = readfloat(m_object1, 0x238)
  509.     local location1_x = readfloat(m_object1, 0x5C)
  510.     local location1_y = readfloat(m_object1, 0x60)
  511.     local location1_z = readfloat(m_object1, 0x64)
  512.     local location2_x = readfloat(m_object2, 0x5C)
  513.     local location2_y = readfloat(m_object2, 0x60)
  514.     local location2_z = readfloat(m_object2, 0x64)
  515.     local state1 = readbyte(m_object1, 0x2A7)
  516.     local state2 = readbyte(m_object2, 0x2A7)
  517.  
  518.     if state1 == 2 then
  519.         location1_z = location1_z + 0.6
  520.     elseif state1 == 3 then
  521.         location1_z = location1_z + 0.3
  522.     else
  523.         return
  524.     end
  525.     if state2 == 2 then
  526.         location2_z = location2_z + 0.6
  527.     elseif state2 == 3 then
  528.         location2_z = location2_z + 0.3
  529.     else
  530.         return
  531.     end
  532.  
  533.     local radius = math.sqrt(
  534.         (location2_x - location1_x) ^ 2 +
  535.         (location2_y - location1_y) ^ 2 +
  536.         (location2_z - location1_z) ^ 2)
  537.     local local_x = location2_x - location1_x
  538.     local local_y = location2_y - location1_y
  539.     local local_z = location2_z - location1_z
  540.     local point_x = 1 / radius * local_x
  541.     local point_y = 1 / radius * local_y
  542.     local point_z = 1 / radius * local_z
  543.  
  544.     if math.round(camera_x, 1) == math.round(point_x, 1) and
  545.         math.round(camera_y, 1) == math.round(point_y, 1) and
  546.         math.round(camera_z, 1) == math.round(point_z, 1) then
  547.         return true
  548.     end
  549.     return false
  550. end
  551.  
  552. function getip(player)
  553.     local m_player = getplayer(player)
  554.     local IP_Address = ""
  555.     if m_player then
  556.         local machine_struct = getmachinestruct(player)
  557.         local machine_network = readdword(readdword(machine_struct, 0x0), 0x0)
  558.         local a = readbyte(machine_network, 0)
  559.         local b = readbyte(machine_network, 1)
  560.         local c = readbyte(machine_network, 2)
  561.         local d = readbyte(machine_network, 3)
  562.         if b then
  563.             IP_Address = string.format("%i.%i.%i.%i", a, b, c, d)
  564.         end
  565.     end
  566.     return IP_Address
  567. end
  568.  
  569. function math.round(number, place)
  570.     local mult = 10 ^ (place or 0)
  571.  
  572.     return math.floor(number * mult + 0.5) / mult
  573. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement