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