Advertisement
it300

Anti-Lagspawn

Feb 20th, 2017
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.94 KB | None | 0 0
  1. -- Anti-lagspawn
  2. -- SAPP Compatability: 9.8+
  3. -- Script by: Skylace aka Devieth
  4.  
  5. api_version = "1.10.0.0"
  6. stand_ticks = {}
  7. ce, client_machineinfo_size = 0x40, 0xEC
  8.  
  9. function OnScriptLoad()
  10.     safe_write(true) safe_read(true)
  11.     if halo_type == "PC" then ce, client_machineinfo_size = 0x0, 0x60 end
  12.     register_callback(cb['EVENT_PRESPAWN'], "OnPrespawn")
  13.     register_callback(cb['EVENT_TICK'], "OnEventTick")
  14. end
  15.  
  16. function OnPrespawn(PlayerIndex)
  17.     stand_ticks[tonumber(PlayerIndex)] = 15
  18. end
  19.  
  20. function OnEventTick()
  21.     for i = 1,16 do
  22.         if player_alive(i) then
  23.             if read_bit(get_dynamic_player(i) + 0x208, 0) == 1 and read_bit(get_dynamic_player(i) + 0x10, 1) == 0 then
  24.                 if stand_ticks[i] then
  25.                     if stand_ticks[i] > 0 then
  26.                         stand_ticks[i] = stand_ticks[i] - 1
  27.                         if stand_ticks[i] > 2 then
  28.                             force_stand(i)
  29.                         else
  30.                             allow_crouch(i)
  31.                         end
  32.                     end
  33.                 else stand_ticks[i] = 0 end
  34.             end
  35.         end
  36.     end
  37. end
  38.  
  39. function force_stand(PlayerIndex) -- Does not sync with client
  40.     local client_machineinfo = get_client_magineinfo(PlayerIndex)
  41.     if client_machineinfo ~= nil then
  42.         write_bit(client_machineinfo + 0x24, 0, 0)
  43.     end
  44. end
  45.  
  46. function allow_crouch(PlayerIndex)
  47.     if read_bit(get_dynamic_player(PlayerIndex) + 0x208, 0) then
  48.         local client_machineinfo = get_client_magineinfo(PlayerIndex)
  49.         if client_machineinfo ~= nil then
  50.             write_bit(client_machineinfo + 0x24, 0, 1)
  51.         end
  52.     end
  53.     timer(33, "is_standing", PlayerIndex)
  54. end
  55.  
  56. function is_standing(PlayerIndex)
  57.     if not read_bit(get_dynamic_player(PlayerIndex) + 0x208, 0) then
  58.         force_stand(PlayerIndex)
  59.     end
  60. end
  61.  
  62. function get_client_magineinfo(PlayerIndex)
  63.     local network_struct = read_dword(sig_scan("F3ABA1????????BA????????C740??????????E8????????668B0D") + 3)
  64.     local client_machineinfo = network_struct + 0x3B8 + ce + to_real_index(PlayerIndex) * client_machineinfo_size
  65.     if client_machineinfo then
  66.     return client_machineinfo else return nil
  67.     end
  68. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement