1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
local meta = FindMetaTable("Player")
local Banlist = {}
local insert = table.insert
if (SERVER) then
hook.Add("InitPostEntity","InitBanlist",function()
if (!sql.TableExists("Banlist")) then
local Dat = {
"id INTEGER PRIMARY KEY",
"steamid TEXT",
"time INT",
"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_sethp string_playername number_health
--Spawn health is 100
concommand.Add("mas_sethp", 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:SetHealth(arg[2])
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_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_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_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
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)
break
end
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
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)
break
end
end
end
end)
else
end
|