Forum

> > CS2D > Scripts > [SOLVED]Menu For live players.
Forums overviewCS2D overview Scripts overviewLog in to reply

English [SOLVED]Menu For live players.

7 replies
To the start Previous 1 Next To the start

old [SOLVED]Menu For live players.

Raaj Nadar
User Off Offline

Quote
Dear users,

Is there any way to make a menu with live playes in the server insead of making a exist string 32 times.

Any easy method to make.
Remember only live player they should be in tero or ct.

I made but it is too long.
At least give me some hints to make.

Regards,
Raaj Nadar.
edited 1×, last 14.11.14 10:39:49 am

old Re: [SOLVED]Menu For live players.

Raaj Nadar
User Off Offline

Quote
No idea i don't know how to use while or looping function.
[Remember] :- The menu should be automatically created if the first menu is filled like that till 32 any ideas for making.

old Re: [SOLVED]Menu For live players.

Dousea
User Off Offline

Quote
1
2
3
for id = 1, 32 do
	menu(id, "menu-content")
end
1
2
3
4
5
6
7
local id = 0

while (id < 32) do
	id = id + 1
	
	menu(id, "menu-content")
end
1
2
3
4
5
6
7
local id = 0

repeat
	id = id + 1
	
	menu(id, "menu-content")
until (id == 32)

old Re: [SOLVED]Menu For live players.

Alistaire
User 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
26
27
28
29
30
31
local menuTitle = "Players"
local _, menuTitleSpaces = string.gsub(menuTitle, " ", "")

addhook('menu', '_menuHook')
addhook('serveraction', '_serveractionHook')

function generatePlayerMenu(id, page)
	local playerTbl = player(0, 'tableliving')
	local page = (#playerTbl >= (page * 8) + 1) and page or 0
	local menuString = menuTitle..string.rep(" ", page)
	for i = (page * 8) + 1, (page + 1) * 8 do
		menuString = menuString..','..(playerTbl[i] and player(playerTbl[i], 'name')..'|'..playerTbl[i] or '')
	end
	menuString = menuString..',Next page'
	menu(id, menuString)
end

function _menuHook(id, title, button)
	if title:sub(1, string.len(menuTitle)) == menuTitle then
		local _, page = string.gsub(title, " ", "")
		if button == 9 then
			generatePlayerMenu(id, (page + 1) - menuTitleSpaces )
		else
			--When the player clicks on a button
		end
	end
end

function _serveractionHook(id, action)
	generatePlayerMenu(id, 0)
end

Tested.
edited 3×, last 12.11.14 05:07:09 pm

old Worked.

Raaj Nadar
User Off Offline

Quote
Thanks @user Alistaire:
Worked..

Can you tell now how to can i do for all the player's in the server.

Mean's Terro,Ct along with spec.

Thank you rock.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview