


Error message:
1
2
3
4
5
2
3
4
5
[19:59:47] VADemon: !f2 [19:59:48] LUA ERROR: sys/lua/autorun/multiserveraction.lua:98: attempt to index global 'menus' (a nil value) [19:59:48] -> sys/lua/autorun/multiserveraction.lua:98: in function <sys/lua/autorun/multiserveraction.lua:91> [19:59:48] -> in Lua hook 'menu', params: 1, 'Weapon Shop Page 1', 4 [19:59:48] ELLO!
How to reproduce:


Code: http://pastebin.com/V7EVYsQQ
Code 

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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
F2_KEY, F3_KEY, F4_KEY = 1, 2, 3 sugarStick = {} sugarStick.menus = { 	[F2_KEY] = { 		title = "Weapon Shop", 		items = { 			{"AK-47","$2500",function(id) 				if player(id,"money")>=2500 then 					parse("equip "..id.." 30") 					parse("setmoney "..id.." "..player(id,"money")-2500) 				else 					msg2(id,"You don't have enough money!") 				end 			end}, 			{"AWP","$3000",function(id) 				if player(id,"money")>=3000 then 					parse("equip "..id.." 35") 					parse("setmoney "..id.." "..player(id,"money")-3000) 				else 					msg2(id,"You don't have enough money!") 				end 			end}, 			{"M4A1","$2600",function(id) 				if player(id,"money")>=2600 then 					parse("equip "..id.." 32") 					parse("setmoney "..id.." "..player(id,"money")-2600) 				else 					msg2(id,"You don't have enough money!") 				end 			end}, 			{"Message","$100",function(id) 				if player(id,"money")>=100 then 					msg("ELLO!@C") 					parse("setmoney "..id.." "..player(id,"money")-100) 				else 					msg2(id,"You don't have enough money!") 				end 			end} 		}, 	} } --[[ function sugarStick.addMenuEntry(menuID, buttonName, buttonDescription, func) 	if sugarStick.menus[ menuID ] then 		if type(buttonName) == type(buttonDescription) and type(func) == "function" then 			sugarStick.menus[ menuID ].items[ #sugarStick.menus[ menuID ].items + 1 ] = {buttonName, buttonDescription, func} 		else 			print("©255100100[Multiserveraction] addMenuEntry parameters are wrong!") 		end 	else 		print("©255100100[Multiserveraction] addMenuEntry: menu '".. menuID .."' doesn't exist!") 	end end function sugarStick.removeMenuEntry(menuID, buttonName, buttonDescription, func) 	if sugarStick.menus[ menuID ] then 		if type(buttonName) == type(buttonDescription) and type(func) == "function" then 			table.remove 		else 			print("©255100100[Multiserveraction] removeMenuEntry parameters are wrong!") 		end 	else 		print("©255100100[Multiserveraction] removeMenuEntry: menu '".. menuID .."' doesn't exist!") 	end end sugarStick.original_addhook = addhook function addhook(hook, strfunc, priority)	-- priority used to determine a key. Constants: F2_KEY, F3_KEY, F4_KEY 	local key 	if hook == "multiserveraction" then 		if type(priority) == "number" then 			if priority == F2_KEY or priority == F3_KEY or priority == F4_KEY then 				print("©100100255[Multiserveraction] Received addhook for function ".. func .."! The serveraction key is:" .. priority) 				key = priority 			else 				print("©255100100[Multiserveraction] Received addhook for function ".. func .." but the used key is invalid!") 				print("©255100100... defaulting this script's trigger key to F2!") 				key = F2_KEY 			end			 		else 			print("©255100100[Multiserveraction] Received addhook for function ".. func .." but the key is not specified!") 			print("©255100100... defaulting this script's trigger key to F2!") 			key = F2_KEY 		end		 	elseif hook == "serveraction" then 		print("©255100100Multiserveraction is installed and some script just requested to add a 'serveraction' hook!")	 		print("©255100100... defaulting this script's trigger key to F2!") 		key = F2_KEY 	else 		sugarStick.original_addhook(hook, strfunc, priority) 		return 	end 	 	 	 end sugarStick.original_addhook("serveraction", "sugarStick.serveraction") function sugarStick.serveraction(id, actionkey) 	local items = #sugarStick.menus[ actionkey ].items	-- how many scripts registered this serveraction key? 	 	if items > 1 then 		sugarStick.unimenu(id, true, actionkey, 1) 	elseif items == 1 then 		sugarStick.menus.items[1][3]()	-- 1 = first entry, 3 = function key 	else	-- 0 items 		msg2(id, "©255100100No menu assigned with this server key!@C") 	end end]] sugarStick.spages = {{}}	-- spages [table]	- a table containing actual menu strings for each page of the menu opened by a player (2 layers - spages[id][page]) sugarStick.pmenu = {}		-- pmenu [table] 	- a table containing the last opened menu of each player (1 layer - pmenu[id]) addhook("join", "sugarStick.join") function sugarStick.join(id) 	sugarStick.spages[id] = {}	-- moved from .unimenu which was only created once for all players with a specific ID end --[[ • id - player ID to open the menu to. number • construct - construct the menu anew or use the cached version? boolean • m - menu to show. table/number/string • p - page of the menu to show. number ]] function sugarStick.unimenu(id, construct, m, p) 	if m ~= "current" then 		if construct then 			local custom, paget 			local pmenu, spages, menus = sugarStick.pmenu, sugarStick.spages, sugarStick.menus 			sugarStick.pmenu[id] = m 			 			if type(m) == "table" then 				custom = true 				paget = math.ceil(#m.items/7) 			else 				custom = false 				paget = math.ceil(#menus[m].items/7) 			end 			 			for i = 1, paget do 				if not custom then 					spages[id][i] = menus[m].title .." Page " .. i .. "@b," 				else 					spages[id][i] = m.title .. " Page " .. i .. "@b," 				end 				for ii = 1, 7 do 					local sid = ii+(7*(i-1)) 					if not custom then 						if menus[m].items[sid] then 							spages[id][i] = spages[id][i] .. menus[m].items[sid][1] .. "|" .. menus[m].items[sid][2] .. "," 						else 							spages[id][i] = spages[id][i] .. "," 						end 					else 						if m.items[sid] then 							spages[id][i] = spages[id][i] .. m.items[sid][1] .. "|" .. m.items[sid][2] .. "," 						else 							spages[id][i] = spages[id][i] .. "," 						end 					end 				end 				if i < paget then 					spages[id][i] = spages[id][i] .. "Next" 				end 				if i>1 then 					spages[id][i] = spages[id][i] .. ",Back" 				end 				 				sugarStick.pmenu, sugarStick.spages, sugarStick.menus = pmenu, spages, menus 			end 		end 	end 	menu(id,sugarStick.spages[id][p]) end addhook("menu","sugarStick.unimenuhook") function sugarStick.unimenuhook(id, menu, sel) 	local p = tonumber(menu:sub(-1)) 	if sel < 8 and sel > 0 then 		local s = sel+(7*(p-1)) 		if type(sugarStick.pmenu[id]) == "table" then 			sugarStick.pmenu[id].items[s][3](id) 		else 			sugarStick.menus[sugarStick.pmenu[id]].items[s][3](id) 		end 	else 		if sel == 8 then 			sugarStick.unimenu(id, true, "current", p+1) 		elseif sel == 9 then 			sugarStick.unimenu(id, true, "current", p-1) 		end 	end end addhook("say", "testsay") function testsay(id, txt) 	if txt == "!f2" then 		sugarStick.unimenu(1, true, F2_KEY, 1) 	end end
UPD: It's called SugarStick now.
edited 1×, last 06.09.15 03:35:28 am