Advertisement
Guest User

server_idle_reset.lua

a guest
Apr 24th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. --Config
  2.  
  3. -- command to execute
  4. reset_command = "sv_map_reset"
  5.  
  6. -- in seconds, the amount of time to elapse for an empty server to reset
  7. time_to_reset = 15
  8.  
  9. --End of config
  10.  
  11. api_version = "1.9.0.0"
  12.  
  13. CURRENT_PLAYER_COUNT_ADDRESS = nil
  14. TIME_ELAPSED = 0
  15.  
  16. function OnScriptLoad()
  17.     local player_header_pointer = sig_scan("A1??????008B503453558B6C241C8BCD5681E1") + 0x1
  18.     local player_header = read_dword(read_dword(player_header_pointer))
  19.     CURRENT_PLAYER_COUNT_ADDRESS = player_header + 0x2E
  20.    
  21.     time_to_reset = time_to_reset * 30
  22.     register_callback(cb['EVENT_TICK'], "OnTick")
  23. end
  24.  
  25. function OnTick()
  26.     if(read_word(CURRENT_PLAYER_COUNT_ADDRESS) == 0) then
  27.         TIME_ELAPSED = TIME_ELAPSED + 1
  28.     elseif(TIME_ELAPSED ~= 0) then
  29.         TIME_ELAPSED = 0
  30.     end
  31.    
  32.     if(TIME_ELAPSED >= time_to_reset) then
  33.         execute_command_sequence(reset_command)
  34.         TIME_ELAPSED = 0
  35.     end
  36. end
  37.  
  38. function OnScriptUnload() end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement