Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- maclist.lua
- ===================
- by Micha!
- Contact:
- --------------------
- http://www.teammuppet.eu
- Info:
- --------------------
- This lua will prevent invalid mac addresses to connect to the server
- --]]
- Modname = "maclist"
- Version = "0.2"
- -------------------------------------------------------------------------------------
- ---------------------------------CONFIG START----------------------------------------
- -------------------------------------------------------------------------------------
- Homepage = "www.clan-etc.de"
- blocknomac = true --prevent players connecting to server with an invalid mac
- --block the mac addresses written in this table
- blockmac = {
- "00-00-00-00-00-00",
- "00-00-00-00-00-01",
- "00-FF-99-49-7C-FC",
- }
- -------------------------------------------------------------------------------------
- ---------------------------------CONFIG END----------------------------------------
- -------------------------------------------------------------------------------------
- -------//---------------------Start of functions----------------------------
- function et_InitGame( levelTime, randomSeed, restart )
- et.G_Print("^z["..Modname.."^z] Version: "..Version.." Loaded\n")
- et.RegisterModname(et.Q_CleanStr(Modname).." "..Version.." "..et.FindSelf())
- end
- function et_ClientConnect( client, firstTime, isBot )
- local userinfo = et.trap_GetUserinfo(client)
- if (userinfo ~= "") and isBot == 0 then
- for k,v in pairs(blockmac) do
- local mac = tostring(et.Info_ValueForKey(userinfo,"x"))
- if tostring(v) == mac and blocknomac then
- et.G_Print(""..Modname..".lua: User "..playerName(client).." tried to connect with a blocked mac: "..mac.."\n")
- 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"
- elseif mac == nil and blocknomac then
- et.G_Print(""..Modname..".lua: User "..playerName(client).." tried to connect with an invalid mac\n")
- 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"
- end
- end
- end
- end
- function et_ClientBegin( client )
- local userinfo = et.trap_GetUserinfo(client)
- if (userinfo ~= "") and isBot1(client) ~= true then
- for k,v in pairs(blockmac) do
- local mac = tostring(et.Info_ValueForKey(userinfo,"x"))
- if tostring(v) == mac and blocknomac then
- et.G_Print(""..Modname..".lua: User "..playerName(client).." tried to connect with a blocked mac: "..mac.."\n")
- 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)
- elseif (mac == "" or mac == nil) and blocknomac then
- et.G_Print(""..Modname..".lua: User "..playerName(client).." tried to connect with an invalid mac\n")
- 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)
- end
- end
- end
- end
- -------//---------------------Start of custom functions----------------------------
- function playerName(client) -- return a player's name
- local name = et.Info_ValueForKey(et.trap_GetUserinfo(client), "name")
- if name == "" then
- return "*unknown*"
- end
- return name
- end
- function isBot1(playerID)
- if et.gentity_get(playerID,"pers.connected") == 2 and et.gentity_get(playerID,"ps.ping") == 0 then
- return true
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement