Ideally you dont want to create the menus yourself to prevent typos.
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
113
114
115
116
117
118
119
120
-- The only menu definition we need!
menus = {
	normal = {3, 4, 5},
	alt = {1,2,3},
	vip = {1,2,3,4,5,6},
	all = {1,2,3,4,5,6,7,8},
}
--[[
	Create the strings that you need for the cs2d:menu only once
	Gets filled by generateMenus()
	Example Content:
	menusTxt = {
		normal = { "My normal Menu@b, Redline AK|rak.png, ProtoM4|prot.png, Elegant|ele.png" }
		alternative = {"My alternative Menu@b,..."},
		vip = {...},
		...
	}
]]
menusTxt = {
},
function getHeadline(groupName)
	return "My "..groupName.." Menu@b";
end
--[[
	Generate the menu txt from the menus tbl
]]
function generateMenus()
	local result
	local skin
	for groupName, groupList in pairs(menus) do
		menusTxt[groupName] = {}
		
		-- Generate menu txt per group
		result = { getHeadline(groupName) } -- headline of menu
		for skinCounter, skinId in ipairs(groupList) do
			if (skinCounter >= 9) then break; end -- todo: allow more than 9 skins per list
			skin = database[skinId] -- for each current skin id
			result[#result+1] = ","..skin.name.."|"..skin.file; -- add each skin name entry to menu
		end
		
		menusTxt[groupName] = table.concat(result)
	end
	
end
--[[
	Open Menu. Example:
		openMenu(1, "normal");
		openMenu(2, "all");
]]
function openMenu(pid, groupName)
	menu(pid, menusTxt[groupName])
end
addhook("menu","menuHook")
function menuHook(pid, t, b)
	local skinList
	local skinId
	local skin
for groupName,_ in pairs(menus) do
		
		if (getHeadline(groupName) == t) then
			msg(pid,"You selected a skin in "..getHeadline(groupName))
			if (b==9) then
				return;
			end
			
			skinList = menus[groupName]
			skinId = skinList[b]
			skin = database[skinId]
			
			applySkin(pid, skin)
			return;
		end
	 end
	
end
function applySkin(pid, skin)
	msg2(pid,"TODO Applying "..skin.name)
	msg2(pid,"TODO File: "..skin.file)
end
-- Example skin database:
database = {
[1] = { -- <-- Skin ID
name = "Golden Deagle", --<-- Skin Name
file = "gdgl.png",
},
[2] = {
name = "Watermelon Glock",
file = "wmelglock.png",
},
	 [3] = {
		name = "Redline AK",
		file = "rak.png",
	 },
	[4] = {
		name = "ProtoM4",
		file = "proto.png",
	},
	[5] = {
		name = "Elegant",
		file = "ele.png",
	},
-- ...
	 [6] = {...},
	 [7] = {...},
	 [8] = {...},
	
}
-- give player with id=1 the all menu
openMenu(1, "all")