Advertisement
HR_Shaft

Autokick Invalid CD Keys for Halo PC/CE and SAPP

Nov 18th, 2017
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.66 KB | None | 0 0
  1. -- Autokick Invalid CD Keys
  2. -- by H® Shaft for Halo PC/CE for SAPP
  3.  
  4. -- This will validate all joining players CD Keys and kick them -IF- their CD Key is NOT VALID.
  5. -- Note: CD Key validation only happens on public servers.
  6.  
  7. -- Message to invalidated player before they are kicked:
  8. Kick_Messages = {
  9.     "YOUR CD-KEY IS INVALID! A VALID CD-KEY REQUIRED TO PLAY HERE!",
  10.     "SU CLAVE DE CD NO ES VALIDA!",
  11.     "DEBE TENER UNA CLAVE DE CD VALIDA PARA JUGAR AQUI!"
  12. }
  13.  
  14. -- don't edit below --
  15. api_version = "1.10.0.0"
  16. ce = 0x0
  17.  
  18. function OnScriptLoad()
  19.     register_callback(cb['EVENT_JOIN'], "OnPlayerJoin")
  20. end
  21.  
  22. function OnPlayerJoin(PlayerIndex)
  23.     timer(3000, "Validate_CD", PlayerIndex)
  24. end
  25.  
  26. function Validate_CD(PlayerIndex)
  27.     local Reason = "INVALID CD-KEY"
  28.     local Name = get_var(PlayerIndex,"$name")
  29.     local valid_cd = get_var(PlayerIndex,"$valid")
  30.     local id = get_var(PlayerIndex, "$n")
  31.     if player_present(PlayerIndex) then
  32.         if (valid_cd == "0") then      
  33.             for l,message in pairs(Kick_Messages) do
  34.                 say(PlayerIndex,string.gsub(message,"$PLAYER",get_var(PlayerIndex,"$name")))                   
  35.             end
  36.             SayExcept(Name .. " is being auto-kicked for using an Invalid CD-Key.", PlayerIndex)
  37.             timer(3000, "Auto_Kick", PlayerIndex)  
  38.         end
  39.     end
  40. end
  41.  
  42. function Auto_Kick(PlayerIndex)
  43.     local Reason = "INVALID CD-KEY"
  44.     execute_command("sv_kick " .. PlayerIndex)
  45.     return false
  46. end    
  47.  
  48. function SayExcept(Message, Except)
  49.     for i=1,16 do
  50.         if i ~= tonumber(Except) then
  51.             say(i, Message)
  52.         end
  53.     end
  54. end
  55.  
  56. function OnScriptUnload() end
  57.  
  58. function OnError(Message)
  59.     print(debug.traceback())
  60. end
  61.  
  62. -- Created by H® Shaft
  63. -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement