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
-- Hooks # Start ------------------------------------
addhook("leave","crb_leave")		
addhook("serveraction","crb_sa")	
addhook("menu","crb_menu")		
addhook("spawn","crb_spawn")		
addhook("hit","crb_hit")			
addhook("say","crb_say")			
-- Hooks # End --------------------------------------
-- Defines # Start --------------------
c = '©'
function initArray(m) -- Creating arrays
	local array = {}
	for i = 1, m do
		array[i] = 0
	end
	return array
end
teams = {'team1','team2','team3','team4','team5','team6','team7','team8'} -- ... team n
teams_chatcolor = {"255255255","000255000","000000255","255255000","255000255","000255255","000000000","100100100"}
player_team = initArray(32)
function csplit(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
-- Defines # End ----------------------
-- Function # Start --------------------
function crb_hit(id,src)
	if (player_team[id] == player_team[src]) then
		return 1		
	end
end
function crb_spawn(id)
	if (tonumber(player_team[id]) == 0) then
		menu(id,"Select Nick Team,1,2,3,4,5,6,7,8,Never Display")	
	end
end
function crb_menu(id,t,b)
	if (t == 'Select Nick Team') then
		if (b < 9) then
			player_team[id] = b		
			msg2(id,c..'255255255Your Nick Team Is : '..c..'000255000'..teams[b])
		else
			msg2(id,c..'255255255You Dont Have Nick Team ! Press F2 To Select One !')
			player_team[id] = -1 -- prevent displaying team select menu	
		end
	end
end
function crb_sa(id,key)
	if (key == 1) then -- On pressing F2
		menu(id,"Select Nick Team,1,2,3,4,5,6,7,8,Never Display")		
	end
end
function crb_leave(id)
	player_team[id] = 0 -- reset team to zero for next player
end
function crb_say(id,text)
	txt = csplit(text)
	if (txt[1] == '!selteam' and txt[2]) then
			player_team[id] = tonumber(txt[2]) -- e.g : !team 1
			if (tonumber(txt[2]) <= #teams and tonumber(txt[2]) > 0) then
			msg2(id,c..'255255255Your Nick Team Is : '..c..'000255000'..teams[tonumber(txt[2])])
			else
			msg2(id,c..'255000000Wrong Team Number !!!')	
			end
	 return 1
	end
if (txt[1] == '!team' and txt[2]) then
	if (player_team[id] > 0) then
	 	local playerlist=player(0,"table")
			for _,p in pairs(playerlist) do
			 if (player_team[p] == player_team[id]) then
			 		msg2(p,c..'255128000 '..player(id,'name')..' (Team Message)'..c..teams_chatcolor[player_team[id]]..' : '..string.sub(text, 6, #text))
			 end
			end
		else
			msg2(id,c..'255255255You Dont Have Nick Team ! Press F2 To Select One !')	
	end
	return 1
end
end
-- Function # End ----------------------
-- Lua by _3yrus - 2017
-- Version 1.0.0