Forum

> > CS2D > Scripts > [SOLVED]Menu For live players.
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch [SOLVED]Menu For live players.

7 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt [SOLVED]Menu For live players.

Raaj Nadar
User Off Offline

Zitieren
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.
1× editiert, zuletzt 14.11.14 10:39:49

alt Re: [SOLVED]Menu For live players.

Raaj Nadar
User Off Offline

Zitieren
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.

alt Re: [SOLVED]Menu For live players.

Dousea
User Off Offline

Zitieren
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)

alt Re: [SOLVED]Menu For live players.

Alistaire
User Off Offline

Zitieren
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.
3× editiert, zuletzt 12.11.14 17:07:09

alt Worked.

Raaj Nadar
User Off Offline

Zitieren
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.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht