Forum

> > CS2D > Scripts > All players in a menu
Forums overviewCS2D overview Scripts overviewLog in to reply

English All players in a menu

3 replies
To the start Previous 1 Next To the start

old All players in a menu

RAVENOUS
BANNED Off Offline

Quote
Heyho,

I was just asking myself how to show all players in a menu, like in HCs Admin Script / RP Scripts.

Would be pretty nice if I could get some answers,

sincerly.

old Re: All players in a menu

Yasday
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
32
33
34
35
36
37
38
39
40
41
42
43
44
pln = {}

for i = 1,32 do
	pln[i] = ""
end

function b_names()
	for id = 1,32 do
		if player(id,"exists") then
			if player(id,"name"):sub(1,1) == "|" then
				pln[id] = player(id,"name"):sub(2)
			else
				pln[id] = player(id,"name")
			end
		else
			pln[id] = ""
		end
	end
end

function pc_1(id)
	b_names()
	menu(id,[[Players 1,]]..pln[1]..[[,]]..pln[2]..[[,]]..pln[3]..[[,]]..pln[4]..[[,]]..pln[5]..[[,]]..pln[6]..[[,]]..pln[7]..[[,,Next Page]])
end

function pc_2(id)
	b_names()
	menu(id,[[Players 2,]]..pln[8]..[[,]]..pln[9]..[[,]]..pln[10]..[[,]]..pln[11]..[[,]]..pln[12]..[[,]]..pln[13]..[[,]]..pln[14]..[[,Previous Page,Next Page]])
end

function pc_3(id)
	b_names()
	menu(id,[[Players 3,]]..pln[15]..[[,]]..pln[16]..[[,]]..pln[17]..[[,]]..pln[18]..[[,]]..pln[19]..[[,]]..pln[20]..[[,]]..pln[21]..[[,Previous Page,Next Page]])
end

function pc_4(id)
	b_names()
	menu(id,[[Players 4,]]..pln[22]..[[,]]..pln[23]..[[,]]..pln[24]..[[,]]..pln[25]..[[,]]..pln[26]..[[,]]..pln[27]..[[,]]..pln[28]..[[,Previous Page,Next Page]])
end

function pc_5(id)
	b_names()
	menu(id,[[Players 5,]]..pln[29]..[[,]]..pln[30]..[[,]]..pln[31]..[[,]]..pln[32]..[[,,,,Previous Page]])
end
edited 1×, last 06.03.11 04:38:34 pm

old Re: All players in a menu

RAVENOUS
BANNED Off Offline

Quote
"You have been slained."
LUA ERROR: sys/lua/server.lua:somewhere: attempt to index global "pln" (a nil value).

1
pln[i] = ""

I don't the fuck get what this block does. oO

Edit: it should be possible to set
1
player(0,"table"): a Lua table with all player IDs
somehow into a menu, but I don't get how...

Edit²: Bump - Problem still not fixed...
edited 1×, last 08.03.11 03:10:56 pm

old Re: All players in a menu

DannyDeth
User Off Offline

Quote
It's because pln is nil. Put simply: pln is non-existent.

Make sure you copied the entire code, because this should be fine.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview