Advertisement
HR_Shaft

IP Ban by Player Name v1.0 for SAPP

Aug 19th, 2016
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.28 KB | None | 0 0
  1. -- IP Ban by Player Name v1.0 for SAPP
  2. -- by H® Shaft 8/19/2016
  3.    
  4. -- This script will allow admins to manually enter a players name, and when player enters the server, to IP Ban them, and
  5. -- to 'optionally' crash the banned players halo game    
  6.    
  7. -- NOTE: this script looks for player names as a "string", so what does that mean?  It means, be careful!
  8. -- 1) if "ass" was listed in the table below, a players named Ass, Asshole, and Assassin would ALL be ip-banned
  9. -- 2) if "assh" is listed, a player named "asshole" or "asshat" BOTH will be ip-banned, but Assassin would NOT be ip-banned.
  10. -- 3) if "new" is listed, a player named "New001" or "Newbie" or "Brandnew" would ALL be ip-banned
  11.  
  12. function LoadNames()
  13.     -- Each name should be in "quotes", and each name separated by a comma, "Name1", "Name2", "Name3"
  14.     -- names may include Alt-Codes (custom characters) such as "Ñamê"
  15.     -- Note: if you add a name here during gameplay, save, then you should reload this script.
  16.     -- Names of players you want auto-ip-banned. Upper and Lower case is fine (UPPER/lower), or copy/paste from sapps log.     
  17.    
  18.     names_to_be_ipbanned = {"escroto", "escroto69", "escr0t0", "escr0t069"}
  19. end
  20.  
  21. -- Do you want to cause the players halo to crash? true = yes, false = no
  22. -- works with all unprotected maps which have a stock warthog (chaingun warthog)
  23. -- suggestion: If you use all stock PC/CE maps, set to true, if using custom CE maps, set to false  
  24. crash_halo = true
  25.  
  26. -- do not edit below --
  27. api_version = "1.9.0.0"
  28.  
  29. function OnScriptLoad()
  30.     register_callback(cb['EVENT_GAME_START'], "OnNewGame")
  31.     register_callback(cb['EVENT_GAME_END'], "OnGameEnd")
  32.     register_callback(cb['EVENT_PREJOIN'], "OnPlayerPrejoin")
  33.     if halo_type == "PC" then ce = 0x0 else ce = 0x40 end
  34.     network_struct = read_dword(sig_scan("F3ABA1????????BA????????C740??????????E8????????668B0D") + 3)
  35.     if get_var(0, "$gt") ~= "n/a" then 
  36.         game_started = true
  37.     end
  38. end
  39.  
  40. function OnScriptUnload() end
  41.  
  42. function OnNewGame()
  43.     game_started = true
  44. end
  45.  
  46. function OnGameEnd()
  47.     game_started = false
  48. end
  49.  
  50. function OnPlayerPrejoin(PlayerIndex)
  51.     local network_struct = read_dword(sig_scan("F3ABA1????????BA????????C740??????????E8????????668B0D") + 3)
  52.     local client_network_struct = network_struct + 0x1AA + ce + to_real_index(PlayerIndex) * 0x20
  53.     local Name = read_widestring(client_network_struct, 12)
  54.     LoadNames()
  55.     local found = false
  56.     local name = string.lower(Name)
  57.     for k,v in pairs(names_to_be_ipbanned) do
  58.         if (string.gsub(name,string.lower(v),"") == name) then
  59.             found = true
  60.         end
  61.     end
  62.     if (found == true) then
  63.         if (crash_halo == true) then
  64.             -- 3 second delay allows player to fully spawn
  65.             timer(3000, "Crash_Player", PlayerIndex)
  66.         end
  67.         -- 3.5 second delay allows crashing a player to complete before they are ip-banned
  68.         timer(3500, "AUTO_IPBAN", PlayerIndex) -- 3.5 seconds
  69.     end
  70. end
  71.  
  72. -- adds player to ipbanlist in /cg directory permanently, with reason "AUTO_IP_BAN"
  73. -- the SAPP IP banlist is located in yourservername\sapp  - named ipbans.txt
  74. function AUTO_IPBAN(PlayerIndex)
  75.     if player_present(PlayerIndex) then
  76.         execute_command("ipban " .. PlayerIndex .. " 0 " .. "AUTO_IP_BAN")
  77.     end
  78.     return false
  79. end
  80.  
  81. -- Called from OnPlayerPrejoin by a timer with a 3.5 second delay
  82. function Crash_Player(PlayerIndex)
  83.     if player_present(PlayerIndex) then
  84.         local player_object = get_dynamic_player(PlayerIndex)
  85.         if game_started then
  86.             if (player_object ~= 0) then
  87.                 local x,y,z = read_vector3d(player_object + 0x5C)
  88.                 local vehicleId = spawn_object("vehi", "vehicles\\warthog\\mp_warthog", x, y, z)
  89.                 local veh_obj = get_object_memory(vehicleId)
  90.                 if (veh_obj ~= 0) then
  91.                     for j = 0,20 do
  92.                         enter_vehicle(vehicleId, PlayerIndex, j)
  93.                         exit_vehicle(PlayerIndex)
  94.                     end
  95.                     destroy_object(vehicleId)
  96.                 end
  97.             end    
  98.         end
  99.     end
  100.     return false
  101. end
  102.  
  103. function read_widestring(address, length)
  104.     local count = 0
  105.     local byte_table = {}
  106.     for i = 1,length do
  107.         if read_byte(address + count) ~= 0 then
  108.             byte_table[i] = string.char(read_byte(address + count))
  109.         end
  110.         count = count + 2
  111.     end
  112.     return table.concat(byte_table)
  113. end
  114.  
  115. function OnError(Message)
  116.     print(debug.traceback())
  117. end
  118.  
  119. -- Created by H® Shaft
  120. -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement