Advertisement
jay1110

maclist.lua

Oct 7th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.56 KB | None | 0 0
  1. --[[
  2.     maclist.lua
  3.     ===================
  4.     by Micha!
  5.    
  6.     Contact:
  7.     --------------------
  8.     http://www.teammuppet.eu
  9.    
  10.     Info:
  11.     --------------------
  12.     This lua will prevent invalid mac addresses to connect to the server
  13. --]]
  14.  
  15. Modname = "maclist"
  16. Version = "0.2"
  17.  
  18. -------------------------------------------------------------------------------------
  19. ---------------------------------CONFIG START----------------------------------------
  20. -------------------------------------------------------------------------------------
  21.  
  22. Homepage = "www.clan-etc.de"
  23.  
  24. blocknomac = true       --prevent players connecting to server with an invalid mac
  25.  
  26.                         --block the mac addresses written in this table
  27. blockmac = {
  28.     "00-00-00-00-00-00",
  29.     "00-00-00-00-00-01",
  30.     "00-FF-99-49-7C-FC",
  31. }
  32.  
  33. -------------------------------------------------------------------------------------
  34. ---------------------------------CONFIG END----------------------------------------
  35. -------------------------------------------------------------------------------------
  36.  
  37. -------//---------------------Start of functions----------------------------
  38. function et_InitGame( levelTime, randomSeed, restart )
  39.     et.G_Print("^z["..Modname.."^z] Version: "..Version.." Loaded\n")
  40.     et.RegisterModname(et.Q_CleanStr(Modname).."   "..Version.."   "..et.FindSelf())
  41. end
  42.  
  43.  
  44. function et_ClientConnect( client, firstTime, isBot )
  45.     local userinfo = et.trap_GetUserinfo(client)    
  46.     if (userinfo ~= "") and isBot == 0 then
  47.         for k,v in pairs(blockmac) do
  48.             local mac = tostring(et.Info_ValueForKey(userinfo,"x"))
  49.             if tostring(v) == mac and blocknomac then
  50.                 et.G_Print(""..Modname..".lua: User "..playerName(client).." tried to connect with a blocked mac: "..mac.."\n")
  51.                 return "\n^f'^/"..et.trap_Cvar_Get("sv_hostname").."^f'\n\n^7ERROR Code \n^f'^7 1 ^f'\n^7. \n\n^7Visit "..Homepage.." to report \n^7your problem.\n^7"
  52.             elseif mac == nil and blocknomac then
  53.                 et.G_Print(""..Modname..".lua: User "..playerName(client).." tried to connect with an invalid mac\n")
  54.                 return "\n^f'^/"..et.trap_Cvar_Get("sv_hostname").."^f'\n\n^7ERROR Code \n^f'^7 2 ^f'\n^7. \n\n^7Visit "..Homepage.." to report \n^7your problem.\n^7"
  55.             end
  56.         end
  57.     end
  58. end
  59.  
  60. function et_ClientBegin( client )
  61.     local userinfo = et.trap_GetUserinfo(client)    
  62.     if (userinfo ~= "") and isBot1(client) ~= true then
  63.         for k,v in pairs(blockmac) do
  64.             local mac = tostring(et.Info_ValueForKey(userinfo,"x"))
  65.             if tostring(v) == mac and blocknomac then
  66.                 et.G_Print(""..Modname..".lua: User "..playerName(client).." tried to connect with a blocked mac: "..mac.."\n")
  67.                  et.trap_DropClient(client, "\n^f'^/"..et.trap_Cvar_Get("sv_hostname").."^f'\n\n^7ERROR Code \n^f'^7 3 ^f'\n^7. \n\n^7Visit "..Homepage.." to report \n^7your problem.\n^7", 500)
  68.             elseif (mac == "" or mac == nil) and blocknomac then
  69.                 et.G_Print(""..Modname..".lua: User "..playerName(client).." tried to connect with an invalid mac\n")
  70.                  et.trap_DropClient(client, "\n^f'^/"..et.trap_Cvar_Get("sv_hostname").."^f'\n\n^7ERROR Code \n^f'^7 4 ^f'\n^7. \n\n^7Visit "..Homepage.." to report \n^7your problem.\n^7", 500)
  71.             end
  72.         end
  73.     end
  74. end
  75.  
  76. -------//---------------------Start of custom functions----------------------------
  77. function playerName(client) -- return a player's name
  78.   local name = et.Info_ValueForKey(et.trap_GetUserinfo(client), "name")
  79.   if name == "" then
  80.     return "*unknown*"
  81.   end
  82.   return name
  83. end
  84.  
  85. function isBot1(playerID)
  86.     if et.gentity_get(playerID,"pers.connected") == 2 and et.gentity_get(playerID,"ps.ping") == 0 then
  87.     return true
  88.     end
  89. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement