it300

anti-speedhack

Apr 21st, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.92 KB | None | 0 0
  1. -- Anti-speedhack by Devieth
  2. -- For SAPP
  3.  
  4. api_version = "1.10.0.0"
  5. update_violation_count = {}
  6. past_update = {}
  7. reset = {}
  8.  
  9. function OnScriptLoad()
  10.     register_callback(cb['EVENT_TICK'], "OnEventTick")
  11.     register_callback(cb['EVENT_LEAVE'], "OnPlayerLeave")
  12. end
  13.  
  14. function OnScriptUnload() end
  15.  
  16. function OnPlayerLeave(PlayerIndex)
  17.     if reset[tonumber(PlayerIndex)] ~= nil then
  18.         if reset[tonumber(PlayerIndex)] > 1 then
  19.             reset[tonumber(PlayerIndex)] = nil
  20.         end
  21.     end
  22. end
  23.  
  24. function OnEventTick()
  25.     for i = 1,16 do
  26.         if player_present(i) then
  27.             if reset[i] ~= nil then
  28.                 if reset[i] >= 1 then
  29.                     for x = 2,26 do rprint(i, " ") end
  30.                     rprint(i, "|cYou have been reset!|ncff0000")
  31.                     rprint(i, "|tPossible issues:|tPlease fix in: "..math.floor(reset[i]/30))
  32.                     rprint(i, "|tPacket loss/lag.")
  33.                     rprint(i, "|tSpeed-hacking.")
  34.                     reset[i] = reset[i] - 1
  35.                 end
  36.             end
  37.             local m_player = get_player(i)
  38.             local update = read_word(m_player + 0xF4)
  39.             if past_update[i] then
  40.                 local difference = update - past_update[i]
  41.                 if difference >= 2 then
  42.                     if update_violation_count[i] ~= nil then
  43.                         update_violation_count[i] = update_violation_count[i] + 1
  44.                         if update_violation_count[i] > 5 then
  45.                             if reset[i] == nil then
  46.                                 reset[i] = 30*30
  47.                                 destroy_object(read_dword(get_player(i) + 0x34))
  48.                             else
  49.                                 if reset[i] < 1 then
  50.                                     say_all("Autokick: "..get_var(i,"$name").. " was kicked due to lag or speed-hack.")
  51.                                     execute_command("sv_kick "..i)
  52.                                 end
  53.                             end
  54.                             update_violation_count[i] = 0
  55.                         end
  56.                     else
  57.                         update_violation_count[i] = 1
  58.                     end
  59.                 end
  60.             end
  61.             if update_violation_count[i] ~= nil then
  62.                 if update_violation_count[i] > 0 then
  63.                     if update == 32 or update == 63 then
  64.                         update_violation_count[i] = update_violation_count[i] - 1
  65.                     end
  66.                 end
  67.             end
  68.             past_update[i] = update
  69.         end
  70.     end
  71. end
Add Comment
Please, Sign In to add comment