From 58c66eed1870687ae0eefd3b050c16e8f50af27e Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Thu, 31 Dec 2015 12:53:33 -0500 Subject: Additional admin commands --- gamemode/shared/system_admin.lua | 126 +++++++++++++++++++++++++++++++-------- 1 file changed, 101 insertions(+), 25 deletions(-) (limited to 'gamemode/shared/system_admin.lua') diff --git a/gamemode/shared/system_admin.lua b/gamemode/shared/system_admin.lua index 14dfb3d..2274a7e 100644 --- a/gamemode/shared/system_admin.lua +++ b/gamemode/shared/system_admin.lua @@ -15,63 +15,136 @@ if (SERVER) then "name TEXT", "reason TEXT", } - + Msg("No banlist was found.\nCreating new banlist!\n") sql.Query("CREATE TABLE IF NOT EXISTS Banlist ("..table.concat(Dat,",")..");") else local dat = sql.Query("SELECT * FROM Banlist") - + if (dat) then for k,v in pairs(dat) do insert(Banlist,v.steamid) end end end end) - + hook.Add("CheckPassword","BlockBannedPlayers",function(SteamID64,NetworkID,ServerPassword,Password,Name) if (table.HasValue(Banlist,util.SteamIDFrom64(SteamID64))) then print(Name.." attempted to join, but was found in the banlist. Blocking access!") - + return false, "You are banned from this server!" end end) - + + --Useage: mas_goto string_playername + concommand.Add("mas_goto", function(pl,com,arg) + if (!IsValid(pl) or !pl:IsAdmin()) then return end + if(!arg[1]) then return end + for k,v in pairs(player.GetAll()) do + if(v:Name():lower():find(arg[1]:lower())) then + pl:SetPos(v:GetPos()+(v:GetUp()*72)) + break; + end + end + end) + + --Useage: mas_bring string_playername + concommand.Add("mas_bring", function(pl,com,arg) + if (!IsValid(pl) or !pl:IsAdmin()) then return end + if(!arg[1]) then return end + for k,v in pairs(player.GetAll()) do + if(v:Name():lower():find(arg[1]:lower())) then + v:SetPos(pl:GetPos()+(pl:GetUp()*72)) + break; + end + end + end) + + --Useage: mas_god string_playername + --Note: all bars will still tick up, but no dammage will be taken + concommand.Add("mas_god", function(pl,com,arg) + if (!IsValid(pl) or !pl:IsAdmin()) then return end + if(!arg[1]) then return end + for k,v in pairs(player.GetAll()) do + if(v:Name():lower():find(arg[1]:lower())) then + v:GodEnable() + end + end + end) + + --Useage: mas_vanish string_playername + concommand.Add("mas_vanish", function(pl,com,arg) + if (!IsValid(pl) or !pl:IsAdmin()) then return end + if(!arg[1]) then return end + for k,v in pairs(player.GetAll()) do + if(v:Name():lower():find(arg[1]:lower())) then + v:SetAlpha(0) + end + end + end) + + --Useage: mas_unvanish string_playername + concommand.Add("mas_unvanish", function(pl,com,arg) + if (!IsValid(pl) or !pl:IsAdmin()) then return end + if(!arg[1]) then return end + for k,v in pairs(player.GetAll()) do + if(v:Name():lower():find(arg[1]:lower())) then + v:SetAlpha(255) + end + end + end) + + --Useage: mas_ungod string_playername + concommand.Add("mas_ungod", function(pl,com,arg) + if (!IsValid(pl) or !pl:IsAdmin()) then return end + if(!arg[1]) then return end + for k,v in pairs(player.GetAll()) do + if(v:Name():lower():find(arg[1]:lower())) then + v:GodDisable() + end + end + end) + + --Useage: mas_bansteamid string_steamid number_time string_reason + --You MUST include a reason for banning + --If the time is 0, this will ban the player permenently concommand.Add("mas_bansteamid",function(pl,com,arg) if (!IsValid(pl) or !pl:IsAdmin()) then return end if (!arg[3]) then return end - + local steamid = arg[1] local time = tonumber(arg[2] or 0) local reason = table.concat(arg," ",3) - + local dat = sql.Query("SELECT * FROM Banlist WHERE steamid="..SQLStr(steamid)) - - if (!dat) then + + if (!dat) then sql.Query("INSERT INTO Banlist(steamid,time,name,reason) VALUES ("..SQLStr(steamid)..","..time..",'Unknown',"..SQLStr(reason)..")") insert(Banlist,steamid) - + for k,v in pairs(player.GetAll()) do if (v:SteamID() == steamid) then v:Kick("Banned from server: "..reason) end - + v:ChatPrint(pl:Nick().." has banned "..steamid) end - + MsgN(pl:Nick().." has banned "..steamid) else MsgN(steamid.." was already located in the database.") end end) - + + --Usgeage: mas_unbansteamid string_steamid concommand.Add("mas_unbansteamid",function(pl,com,arg) if (!IsValid(pl) or !pl:IsAdmin()) then return end if (!arg[1]) then return end - + local dat = sql.Query("DELETE * FROM Banlist WHERE steamid="..SQLStr(arg[1])) - + if (dat) then MsgN(pl:Nick().." has unbanned "..arg[1]) - + for k,v in pairs(Banlist) do if (v == arg[1]) then table.remove(Banlist,k) @@ -80,32 +153,35 @@ if (SERVER) then end end end) - + + --Usage: mas_printbannedplayers concommand.Add("mas_printbannedplayers",function(pl,com,arg) if (!IsValid(pl) or !pl:IsAdmin()) then return end - + local dat = sql.Query("SELECT * FROM Banlist") - + if (dat) then for k,v in pairs(dat) do pl:ChatPrint(v.steamid.." - "..v.name) end end end) - + + --Usage: mas_banplayer string_playername + --Note: will ban the first player that contains playername, in the order the players joined the server concommand.Add("mas_banplayer",function(pl,com,arg) if (!IsValid(pl) or !pl:IsAdmin()) then return end if (!arg[3]) then return end - + local name = arg[1] local time = tonumber(arg[2] or 0) local reason = table.concat(arg," ",3) - + for k,v in pairs(player.GetAll()) do if (v:Nick():lower():find(name:lower())) then local dat = sql.Query("SELECT * FROM Banlist WHERE steamid="..SQLStr(v:SteamID())) - - if (!dat) then + + if (!dat) then sql.Query("INSERT INTO Banlist(steamid,time,name,reason) VALUES ("..SQLStr(v:SteamID())..","..time..","..SQLStr(v:Nick())..","..SQLStr(reason)..")") insert(Banlist,v:SteamID()) v:Kick("Banned from server: "..reason) @@ -115,4 +191,4 @@ if (SERVER) then end end) else -end \ No newline at end of file +end -- cgit v1.2.3-70-g09d2