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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
-- Script by TopNotch, PM for suggestions or bug reports
-- INITIAL (do not touch this) --
pl = {}
-- CONFIG --
owner = {95753} -- Owner has GM tag, but has an !rcon command. I added this since rcon is very powerful (crashing server etc).
gamemaster = {7844} --Put your USGN here
mod = {} -- Moderator USGN here
mod_wallhack = true--Set this to false if you don't want Moderators to use wallhack
color = { -- You can change this, or add some extra colors. Note: the last color mustn't have "," behind it! "\169" is a copyright icon.
	"\169255220000", -- CS2D (yellow) 1
	"\169255255255", -- white 2
	"\169255000000", -- red 3
	"\169000255000", -- green 4
	"\169000000255", -- blue 5
	"\169220220220", -- light grey 6
	"\169064179162", -- PM - light blue 7
	"\169255025000", -- T 8
	"\169050150255", -- CT 9
	"\169100100100" -- pretty dark grey - tag 10
},
-- HOOKS --
addhook("join","_join")
addhook("say","_say")
addhook("serveraction","_serveraction")
addhook("clientdata","_clientdata")
addhook("menu","_menu")
addhook("startround","_startround")
-- VADemon for http://unrealsoftware.de/forum_posts.php?post=393540
function TN_setupNewTempMod(id)
	pl[id] = {}
	pl[id].lvl = 5
	pl[id].status = "Moderator"
	pl[id].name = player(id,"name")
	pl[id].usgn = player(id,"usgn")
	pl[id].ip = player(id,"ip")
	pl[id].muted = false
	
	pl[id].tag = "[M]"
	pl[id].has_tag = true
end
-- FUNCS --
function _join(id) -- No need to change anything here
	pl[id] = {}
	pl[id].lvl = 1
	pl[id].status = "Player"
	pl[id].name = player(id,"name")
	pl[id].usgn = player(id,"usgn")
	pl[id].ip = player(id,"ip")
	pl[id].muted = false
	for _, usgn in ipairs(owner) do
		if player(id,"usgn")==usgn then
			pl[id].lvl = 15
			pl[id].status = "Owner"
			pl[id].tag = "[GM]" --Same tag
			pl[id].has_tag = true
		end
	end
	for _, usgn in ipairs(gamemaster) do
		if player(id,"usgn")==usgn then
			pl[id].lvl = 10
			pl[id].status = "Game Master"
			pl[id].tag = "[GM]"
			pl[id].has_tag = true
		end
	end
	for _, usgn in ipairs(mod) do
		if player(id,"usgn")==usgn then
			pl[id].lvl = 5
			pl[id].status = "Moderator"
			pl[id].tag = "[M]"
			pl[id].has_tag = true
		end
	end
	welcome(id)
end
function welcome(id)
	msg2(id,color[2].."Welcome, "..pl[id].name)
	if pl[id].usgn==0 then
		msg2(id,color[3].."You are not logged in!")
		msg2(id,color[3].."Please register and login into a USGN account!")
	elseif pl[id].lvl >= 5 then
		msg2(id,color[2].."You are logged in as "..color[4]..""..pl[id].usgn)
		msg2(id,color[2].."Your rank is "..color[4]..""..pl[id].status)
	end
end
function reload()
	msg(color[2].."Updating server scripts (mapchange) in: @C")
	timer(1000,"parse","sv_msg 5@C")
	timer(2000,"parse","sv_msg 4@C")
	timer(3000,"parse","sv_msg 3@C")
	timer(4000,"parse","sv_msg 2@C")
	timer(5000,"parse","sv_msg 1@C")
	timer(6000,"parse","map "..game("sv_map"))
end
function error(id,txt,error)
	if error==1 then
		msg2(id,color[3].."Command: "..txt)
		msg2(id,color[3].."Error: Insufficient privilege")
	elseif error==2 then
		msg2(id,color[3].."Command: "..txt)
		msg2(id,color[3].."Error: No player found with ID "..t)
	elseif error==3 then
		msg2(id,color[3].."Command: "..txt)
		msg2(id,color[3].."Error: You cannot ban bots")
	elseif error==4 then
		msg2(id,color[3].."Error: You are muted, you cannot talk")
	elseif error==5 then
		msg2(id,color[3].."Command: "..txt)
		msg2(id,color[3].."Error: Value is too high. 1-10 allowed")
	elseif error==6 then
		msg2(id,color[3].."Command: "..txt)
		msg2(id,color[3].."Error: Your score is already nullified")
	elseif error==7 then
		msg2(id,color[3].."Command: "..txt)
		msg2(id,color[3].."Error: Value is too high. 1-60 allowed")
	end
end
function _say(id,txt)
	if pl[id].muted == true then
		error(id,txt,4)
		return 1
	end
	if txt:sub(1,5)=="!kick" then
		if pl[id].lvl >= 5 then
			t = tonumber(txt:sub(7,8))
			local r = txt:sub(9)
			if not player(t,"exists") then error(id,txt,2) return 1 end
			parse('kick '..t..' "'..r)
			msg(color[2]..""..pl[id].name..""..color[1].." kicked "..color[2]..""..pl[t].name.." (Reason: "..r..")")
			return 1
		else
			error(id,txt,1)
			return 1
		end
	end
	if txt:sub(1,6)=="!banip" then
		if pl[id].lvl >= 5 then
			t = tonumber(txt:sub(8,9))
			r = txt:sub(10)
			if not player(t,"exists") then error(id,txt,2) return 1 end
			if player(t,"bot")==true then error(id,txt,3) return 1 end
			parse('banip '..player(t,"ip")..' 0 "'..r)
			msg(color[2]..""..pl[id].name..""..color[1].." banned (IP) "..color[2]..""..pl[t].name.." (Reason: "..r..")")
			return 1
		else
			error(id,txt,1)
			return 1
		end
	end
	if txt:sub(1,8)=="!banusgn" then
		if pl[id].lvl >= 5 then
			t = tonumber(txt:sub(10,11))
			r = txt:sub(12)
			if not player(t,"exists") then error(id,txt,2) return 1 end
			if player(t,"bot")==true then error(id,txt,3) return 1 end
			parse('banusgn '..player(t,"usgn")..' 0 "'..r)
			msg(color[2]..""..pl[id].name..""..color[1].." banned (USGN) "..color[2]..""..pl[t].name.." (Reason: "..r..")")
			return 1
		else
			error(id,txt,1)
			return 1
		end
	end
	if txt:sub(1,8)=="!tempban" then
		if pl[id].lvl >= 5 then
			t = tonumber(txt:sub(10,11))
			duration = txt:sub(12,14)
			r = txt:sub(15)
			if not player(t,"exists") then error(id,txt,2) return 1 end
			if player(t,"bot")==true then error(id,txt,3) return 1 end
			if tonumber(duration) > 60 then error(id,txt,7) return 1 end
				msg(color[2]..""..pl[id].name..""..color[1].." temp. banned "..color[2]..""..pl[t].name.." for "..color[1]..""..duration.." minutes "..color[2].."(Reason: "..r..")")
				if player(t,"usgn")==0 then
					msg2(id,color[4].."Info: "..color[2]..""..player(t,"name").." was not logged in to USGN.")
					msg2(id,color[4].."Info: "..color[2].."Temporarily banned his IP ("..player(t,"ip")..")")
					parse('banip '..player(t,"ip")..' '..duration..' "'..r)
					return 1
				else
					parse('banusgn '..player(t,"usgn")..' '..duration..' "'..r)
					return 1
				end
		else
			error(id,txt,1)
			return 1
		end
	end
	if txt:sub(1,5)=="!mute" then
		if pl[id].lvl >= 5 then
			t = tonumber(txt:sub(7,8))
			reason = txt:sub(9)
			if pl[t].muted==false then
				pl[t].muted=true
				msg2(id,color[2]..""..pl[id].name..""..color[1].." muted "..color[2]..""..pl[t].name.." (Reason: "..reason)
				return 1
			else
				pl[t].muted=false
				msg2(id,color[2]..""..pl[id].name..""..color[1].." unmuted "..color[2]..""..pl[t].name)
				return 1
			end
		else
			error(id,txt,1)
			return 1
		end
	end
	if txt:sub(1,5)=="!kill" then
		if pl[id].lvl >= 5 then
			t = tonumber(txt:sub(7,8))
			if not player(t,"exists") then error(id,txt,2) return 1 end
			parse("killplayer "..t)
			msg(color[2]..""..pl[id].name..""..color[1].." command-killed "..color[2]..""..pl[t].name)
			return 1
		else
			error(id,txt,1)
			return 1
		end
	end
	if txt:sub(1,5)=="!slap" then
		if pl[id].lvl >= 5 then
			t = tonumber(txt:sub(7,8))
			if not player(t,"exists") then error(id,txt,2) return 1 end
			msg(color[2]..""..pl[id].name..""..color[1].." slapped "..color[2]..""..pl[t].name)
			parse("slap "..t)
			return 1
		else
			error(id,txt,1)
			return 1
		end
	end
	if txt:sub(1,6)=="!unban" then
		if pl[id].lvl >= 10 then
			mask = txt:sub(8)
			parse("unban "..mask)
			msg2(id,color[4].."Info:"..color[2].." Successfully unbanned "..color[1]..""..mask)
			return 1
		else
			error(id,txt,1)
			return 1
		end
	end
	if txt:sub(1,6)=="!strip" then
		if pl[id].lvl >= 5 then
			t = tonumber(txt:sub(8,9))
			if not player(t,"exists") then error(id,txt,2) return 1 end
			msg(color[2]..""..pl[id].name..""..color[1].." stripped "..color[2]..""..pl[t].name)
			parse("strip "..t)
			return 1
		else
			error(id,txt,1)
			return 1
		end
	end
	if txt:sub(1,6)=="!speed" then
		if pl[id].lvl >= 10 then
			t = tonumber(txt:sub(8,9))
			speed = tonumber(txt:sub(10,12))
			parse("speedmod "..t.." "..speed)
			msg(color[2]..""..pl[id].name..""..color[1].." speedmod ("..speed..") "..color[2]..""..pl[t].name)
			return 1
		else
			error(id,txt,1)
			return 1
		end
	end
	if txt:sub(1,6)=="!equip" then
		if pl[id].lvl >= 5 then
			t = tonumber(txt:sub(8,9))
			item = tonumber(txt:sub(10,12))
			parse("equip "..t.." "..item)
			msg2(t,color[2]..""..pl[id].name.." gave you item #"..item)
			return 1
		else
			error(id,txt,1)
			return 1
		end
	end			
	if txt:sub(1,5)=="!info" then
		if pl[id].lvl >= 5 then
			t = tonumber(txt:sub(7,8))
			if not player(t,"exists") then error(id,txt,2) return 1 end
			msg2(id,color[2].."Name: "..pl[t].name)
			msg2(id,color[2].."USGN: "..pl[t].usgn)
			msg2(id,color[2].."IP: "..pl[t].ip)
			return 1
		else
			error(id,txt,1)
			return 1
		end
	end
	if txt:sub(1,4)=="!map" then
		if pl[id].lvl >= 10 then
			map = txt:sub(6)
			msg(color[2]..""..pl[id].name.." changed the map to "..color[1]..""..map)
			timer(2000,"parse","map "..map)
			return 1
		else
			error(id,txt,1)
			return 1
		end
	end
	if txt=="!tag" then
		if pl[id].lvl >= 5 then
			if pl[id].has_tag == true then
				pl[id].has_tag = false
				msg2(id,color[2].."Tag: "..color[3].."OFF")
				return 1
			else
				pl[id].has_tag = true
				msg2(id,color[2].."Tag: "..color[4].."ON")
				return 1
			end
		else
			error(id,txt,1)
			return 1
		end
	end
	if txt:sub(1,8)=="!restart" then --!restart 99
		if pl[id].lvl >= 5 then
			local t = tonumber(txt:sub(10,11))
			if t <=10 then
				msg2(id,color[2]..""..pl[id].name.." called a "..color[1].."round restart "..color[2].."in "..color[1]..""..t.." "..color[2].."seconds")
				parse("restartround "..t)
				return 1
			else
				error(id,txt,5)
				return 1
			end
		else
			error(id,txt,1)
			return 1
		end
	end
	if txt=="!reload" then
		if pl[id].lvl >= 10 then
			msg(color[2]..""..pl[id].name..""..color[1].." reloaded"..color[1].." the server.")
			reload()
			return 1
		else
			error(id,txt,1)
			return 1
		end
	end
	if txt:sub(1,5)=="!rcon" then
		if pl[id].lvl >= 15 then
			local cmd = txt:sub(7)
			parse(cmd)
			msg2(id,color[4].."Successfully parsed "..color[1]..""..cmd)
			msg(color[2]..""..pl[id].name..""..color[1].." parsed"..color[1].." "..cmd)
			return 1
		else
			error(id,txt,1)
			return 1
		end
	end
	if txt:sub(1,3)=="!pm" then
		local t = tonumber(txt:sub(5,6))
		local message = txt:sub(7)
		if not player(t,"exists") then error(id,txt,2) return 1 end
		msg2(id,color[7].."You whisper "..pl[t].name..": "..message)
		msg2(t,color[7]..""..pl[id].name.." whispers you: "..message)
		parse("sv_sound2 "..t.." alert.wav")
		return 1
	end
	if txt=="!resetscore" then
		if player(id,"deaths") > 0 or player(id,"score") > 0 then
			parse("setscore "..id.." 0")
			parse("setdeaths "..id.." 0")
			msg2(id,color[4].."Info: "..color[2].."You nullified your score")
			return 1
		else
			error(id,txt,6)
			return 1
		end
	end
	if txt:sub(1,8)=="!tempmod" then
		if pl[id].lvl >= 15 then
			local targetID = tonumber(txt:sub(10))
			if type(targetID) == "number" and targetID > 0 and targetID < 33 and player(targetID, "exists") then
				TN_setupNewTempMod(targetID)
				msg(color[2]..""..pl[id].name.." made "..color[5] .. pl[targetID].name.. color[2].." a new temporary moderator!")
				return 1
			end
		else
			error(id,txt,1)
			return 1
		end
	end
	if txt=="!help" then
	msg2(id,color[4].."Info: "..color[2].."Please open up your console to see the commands.")
	msg2(id,color[2].."!help")
	msg2(id,color[2].."!pm <id>")
	msg2(id,color[2].."!resetscore")
		if pl[id].lvl >= 5 then
			msg2(id,color[2].."!kick <id> <reason>")
			msg2(id,color[2].."!banip <id> <reason>")
			msg2(id,color[2].."!banusgn <id> <reason>")
			msg2(id,color[2].."!tempban <id> <duration (1-1440 minutes)> <reason>")
			msg2(id,color[2].."!mute <id> <reason>")
			msg2(id,color[2].."!kill <id>")
			msg2(id,color[2].."!slap <id>")
			msg2(id,color[2].."!strip <id>")
			msg2(id,color[2].."!equip <id>")
			msg2(id,color[2].."!info <id>")
			msg2(id,color[2].."!tag")
			msg2(id,color[2].."!restart <time>")
		end
		if pl[id].lvl==10 then
			msg2(id,color[2].."!unban <mask>")
			msg2(id,color[2].."!speed <id> <speed 1-100>")
			msg2(id,color[2].."!map <map>")
			msg2(id,color[2].."!reload")
		end
		if pl[id].lvl==15 then
			msg2(id,color[2].."!rcon <cmd>")
			msg2(id,color[2].."!tempmod <id>")
		end
		return 1
	end
	if pl[id].lvl >= 5 and pl[id].has_tag == true then
		if player(id,"team")==1 then
			msg(color[10]..""..pl[id].tag.." "..color[8]..""..pl[id].name..": "..color[1]..""..txt) -- tag
			return 1
		elseif player(id,"team")==2 then
			msg(color[10]..""..pl[id].tag.." "..color[9]..""..pl[id].name..": "..color[1]..""..txt)
			return 1
		end
	end
end
function _serveraction(id,act)
	if act==3 then
		if pl[id].lvl>=5 and mod_wallhack == true then
			reqcld(id,2)
			parse("setpos "..id.." "..wallhack_x.." "..wallhack_y)
		end
	end
end
function _clientdata(id,mode,data1,data2)
	if mode==2 then
		wallhack_x = data1
		wallhack_y = data2
	end
end
function _startround(id)
	if sv_gamemode==0 and mp_startmoney==16000 then
		for i = 1,32 do
			parse("setmoney "..i.." 16000")
		end
	end
end