Forum

> > CS2D > Scripts > i need player menu team
Forums overviewCS2D overview Scripts overviewLog in to reply

English i need player menu team

7 replies
To the start Previous 1 Next To the start

old i need player menu team

cELL
User Off Offline

Quote
Hi everyone. i need help, What I need is that when i open my admin menu And I click the button 1 that I open the list of players and that next to the name of the player is his team

Something like that I need:IMG:https://i67.tinypic.com/v3qgex.jpg


Here the code
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
Admins = {1234}

addhook("serveraction","adminaction")
function adminaction(id,b)
if b == 1 then
for _, usgn in ipairs(Admins) do
if player(id,'usgn') == usgn then
menu(id,"Menu Admin,Kill")
return 1
end
end
end
end

function k(pl)
parse("killplayer "..pl)
end

function exist(a)
if player(a,"exists") then
return player(a,"name")
else
return "None"
end
end

addhook("menu","adminmenu")
function adminmenu(id,t,b)
if t=="Menu Admin" then
if b==1 then
menu(id,"Kill Page 1@b,"..exist(1)..","..exist(2)..","..exist(3)..","..exist(4)..","..exist(5)..","..exist(6)..","..exist(7)..","..exist(8)..",Next")
end
elseif t=="Kill Page 1" then
if b==1 then
k(1)
elseif b==2 then
k(2)
elseif b==3 then
k(3)
elseif b==4 then
k(4)
elseif b==5 then
k(5)
elseif b==6 then
k(6)
elseif b==7 then
k(7)
elseif b==8 then
k(8)
elseif b==9 then 
menu(id,"Kill Page 2@b,"..exist(9)..","..exist(10)..","..exist(11)..","..exist(12)..","..exist(13)..","..exist(14)..","..exist(15)..","..exist(16)..",Next")
end
elseif t=="Kill Page 2" then
if b==1 then
k(9)
elseif b==2 then
k(10)
elseif b==3 then
k(11)
elseif b==4 then
k(12)
elseif b==5 then
k(13)
elseif b==6 then
k(14)
elseif b==7 then
k(15)
elseif b==8 then
k(16)
elseif b==9 then 
menu(id,"Kill Page 3@b,"..exist(17)..","..exist(18)..","..exist(19)..","..exist(20)..","..exist(21)..","..exist(22)..","..exist(23)..","..exist(24)..",Next")
end
elseif t=="Kill Page 3" then
if b==1 then
k(17)
elseif b==2 then
k(18)
elseif b==3 then
k(19)
elseif b==4 then
k(20)
elseif b==5 then
k(21)
elseif b==6 then
k(22)
elseif b==7 then
k(23)
elseif b==8 then
k(24)
elseif b==9 then 
menu(id,"Kill Page 4@b,"..exist(25)..","..exist(26)..","..exist(27)..","..exist(28)..","..exist(29)..","..exist(30)..","..exist(31)..","..exist(32))
end
elseif t=="Kill Page 4" then
if b==1 then
k(25)
elseif b==2 then
k(26)
elseif b==3 then
k(27)
elseif b==4 then
k(28)
elseif b==5 then
k(29)
elseif b==6 then
k(30)
elseif b==7 then
k(31)
elseif b==8 then
k(32)
end
end
end

Please Help me

old Re: i need player menu team

Bowlinghead
User Off Offline

Quote
Untested code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function serveractionHook(id,b)
	-- if player admin and pressed button what so ever

	myMenuString = "Kill Player" -- headline
	for key, playerid in ipairs(player(0,"table")) do -- go through each player
		myMenuString += ","..player(playerid,"name").."|"..Team2String(playerid) -- add player entry in menu
	end
	menu(id, myMenuString) -- show menu
end

function Team2String(pid)
	if (player(pid,"team") == 1) then
		return "TT"
	else
		return "CT"
	end
end
This is just an example how to print all player names into a menu string

cs2d lua cmd menu
cs2d lua cmd player
cs2d lua hook serveraction
cs2d lua hook menu

old Re: i need player menu team

GeoB99
Moderator Off Offline

Quote
@user Bowlinghead: The 6 line will trigger an error because of
+=
being a unknown syntax not recognised by Lua.
The Code >

I shortened the code by comparing the buttons at 29 line instead of checking everyone of them manually so it'd make our lives easier. Hopefully it should work.

old Re: i need player menu team

cELL
User Off Offline

Quote
@user GeoB99: Still does not work, That's how it looks

IMG:https://i63.tinypic.com/30vjeqx.jpg


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
local Administrators = {156362} -- Your U.S.G.N. ID must be inside the curly braces

function ServerActionMenu(id, action)
   if ( action == 1 ) then
      for _, USGNID in ipairs( Administrators ) do
         if ( player(id, 'usgn') == USGNID ) then
            menu(id, 'Admin Menu, Kill Page')
         end
      end
   end
end

function KillPlayerID(id)
   parse('killplayer ' .. id)
end

function PlayerTeam(id)
   if ( player(id, 'team') == 1 ) then
      return 'TT'
   else
      return 'CT'
   end
end

function MenuHook(id, title, button)
   if ( title == 'Admin Menu' ) then
      for key, IDvalue in ipairs( player(0, 'tableliving') ) do
         menu(id, 'Kill Page,' .. player(IDvalue, 'name') .. '|' .. PlayerTeam(IDvalue) .. ',' .. player(IDvalue, 'name') .. '|' .. PlayerTeam(IDvalue) .. ',Next') -- Do the same thing by adding new players entry
         if ( button >= 1 and button <= 8 ) then
         elseif ( button == 9 ) then
            -- Another menu...
         end
      end
   end
end

addhook('serveraction', 'ServerActionMenu')
addhook('menu', 'MenuHook')

HELP ME PLEASE

old Re: i need player menu team

Rainoth
Moderator Off Offline

Quote
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
adm = {
hooks = {"menu","serveraction"},
teams = {TT,CT}
}

for k,v in pairs (adm.hooks) do
	addhook(v, "_"..v)
end

function _serveraction(id)
	menu(id,"Main Menu","Player list")
end

function _menu(id,t,b)
	if t == "Main Menu" then
		if b == 1 then
			local menuString = "Player List"
			local i = 0
			for k,v in pairs (player(0,"table")) do
			menuString = menuString .. "," .. player(v,"name").."|"..adm.teams[player(v,"team")]
			end
			menu(id,menustring)
		end
	end
end

This is how you'd handle creating the menus. Now you just need to use search function and use the code you find to make things like "Next page" and "Previous page" because I'm not going to write the same shit again for the 4th time.

Good luck

old Re: i need player menu team

Ajmin
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Change your exist function in your code to this:

function exist(a)
	if player(a,"exists") then 
		if player(a,"team")==1 then --If player is Terrorist
			return ""..player(a,"name").."|T" 
		elseif player(a,"team")==2 then --if player is counter Ter
			return ""..player(a,"name").."|CT" 
		elseif player(a,"team")==0 then --if player is Spectator
			return ""..player(a,"name").."|SPEC" 
		end
	
	else
		return "None"
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview