Spoiler
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
function init_array(length,mode) 	local array={} 	for i=1,length do 		array[i]=mode end 	return array end function table.copy(t, lookup_table) 	if (t == nil) then return nil end 	local copy = {} 	setmetatable(copy, getmetatable(t)) 	for i,v in pairs(t) do 		if type(v) ~= "table" then 			copy[i] = v 		else 			lookup_table = lookup_table or {} 			lookup_table[t] = copy 			if lookup_table[v] then 				copy[i] = lookup_table[v] 			else 				copy[i] = table.copy(v, lookup_table) 			end 		end 	end 	return copy end _menu=menu menu={} menu.data={ 	["@main_menu"]={ 		title="Menu Principal"; 		button={ 			{name="Inventário",func="menu.inv_show(v_me)"}; 			{name="Loja",target="@shop"}; 		} 	}; 	["@shop"]={ 		title="Loja@b"; 		button={ 			{name="Menu Principal";caption="Voltar";target="@main_menu"}; 		} 	}; 	["@buy"]={ 		title="Deseja comprar esse item?"; 		button={ 			{name="Loja";caption="Voltar";target="@shop"}; 			{name="Comprar";func="menu.inv_buy(v_me,USER[v_me].sel)"}; 			{name="Ver descrição",func="menu.inv_shopdesc(v_me,USER[v_me].sel)"}; 		} 	}; 	["@equip"]={ 		title="Test"; 		button={ 			{name="Menu Principal",caption="Voltar",target="@main_menu"}; 			{name="Usar",func="menu.inv_use(v_me,USER[v_me].sel)"}; 			{name="Vender",func="menu.inv_sell(v_me,USER[v_me].sel)"}; 			{name="Ver descrição",func="menu.inv_desc(v_me,USER[v_me].sel)"}; 			{name="Jogar fora",func="menu.inv_remove(v_me,USER[v_me].sel)"}; 		} 	}; } menu.itemdata={ {name="Poção de HP [250]",price=120,desc="Esta poção recupera totalmente sua saude.",func="heal_p(v_me,250)"}; {name="Poção de HP [100]",price=50,desc="Esta poção recupera sua saude.",func="heal_p(v_me,100)"}; {name="Poção de HP [50]",price=30,desc="Esta poção recupera um pouco sua saude.",func="heal_p(v_me,50)"}; {name="Poção de HP [20]",price=10,desc="Esta poção recupera um pouquinho sua saude.",func="heal_p(v_me,20)"}; } for index,value in ipairs(menu.itemdata) do menu.data["@shop"].button[index+1]={name=menu.itemdata[index].name;caption=menu.itemdata[index].price.." créditos";func="USER[v_me].sel=(v_slot-1)";target="@buy"} end USERDATA={ 	menu_page=""; 	menu_name=""; 	sel=""; 	inv={}; } USER=init_array(32,USERDATA) USER_ITEMS=init_array(32,{}) function menu.get(name,page,button) 	local data={} 	if type(name) == "table" then 		data = name 	else 		data = menu.data[name] 	end 	 	local slot=7*(page-1)+button 	local item=data.button[slot] 	--print(item.name) 	return item,slot end function menu.show(uid,name,page) 	local menu_page = page or 1 	local menu_name = name 	local data = {} 	 	if type(name) == "table" then 		data = name 	else 		data = menu.data[name] 	end	 	if data then 		local title = data.title 		local content = data.title 		local button = data.button or {} 		local length = math.ceil(#button/ 7) 			 		if #button > 9 then 			if menu_page < 1 then 				menu_page = length 			elseif menu_page > length then 				menu_page = 1 			end 				 			for	i = 7 * menu_page - 6, 7 * menu_page do 				if button[i] then 					content = content ..','..button[i].name 					if button[i].caption then 						content = content.."|"..button[i].caption 					end	 				else 					content = content ..',' 				end 			end 			 			if menu_page == length 			then content = content ..',(Proximo)' 			else content = content ..',>> Proximo >>|Pagina '..menu_page+1 			end 	 			if menu_page == 1 			then content = content ..',(Anterior)' 			else content = content ..',<< Anterior <<|Pagina '..menu_page-1 			end	 		else 			for slot,button in ipairs(button) do 				content = content..","..button.name 				if button.caption then 					content = content.."|"..button.caption 				end 			end 		end 	 		USER[uid].menu_name = menu_name 		USER[uid].menu_page = menu_page 		_menu(uid,content) 	end end addhook("menu","menu.hook") function menu.hook(uid,title,button) 	if button==0 then return end 	 	local menu_name = USER[uid].menu_name 	local menu_page = USER[uid].menu_page 	local menu_button = 0 	 	if type(menu_name) == "table" then 		menu_button = #menu_name.button 	else 		menu_button = #menu.data[menu_name].button 	end 	 	if menu_button > 9 then 		if button==9 then menu.show(uid,menu_name,menu_page-1) return end 		if button==8 then menu.show(uid,menu_name,menu_page+1) return end 	end 	 	local item,slot=menu.get(menu_name,menu_page,button) 	v_me=uid 	v_slot=slot 		 	if item.func then loadstring(item.func)() end 	if item.target then 		menu.show(uid,item.target) 	end	 end addhook("serveraction","menu.input") function menu.input(uid,action) 	if action==3 then 		menu.show(uid,"@main_menu") 	end end function menu.inv_remove(uid,item_slot) 	local items=table.copy(USER_ITEMS[uid]) 	for slot,item in ipairs(items) do 		if item_slot == slot then 			table.remove(items,slot) 			USER_ITEMS[uid]=items 			break 		end 	end end function menu.inv_buy(uid,item_id) 	local item=menu.itemdata[item_id] 	if player(uid,"money") >= item.price then 		msg2(uid,"Você adquiriu "..item.name.."!") 		menu.inv_add(uid,item_id) 		parse("setmoney "..uid.." "..(player(uid,"money")-item.price)) 	else 		msg2(uid,"Você não tem dinheiro suficiente para comprar "..item.name..".") 	end end function menu.inv_shopdesc(uid,item_id) 	local item=menu.itemdata[item_id] 	msg2(uid,item.name..": "..item.desc) end function menu.inv_desc(uid,item_slot) 	local item_id=USER_ITEMS[uid][item_slot] 	local item=menu.itemdata[item_id] 	msg2(uid,item.name..": "..item.desc) end function menu.inv_use(uid,item_slot) 	local item_id=USER_ITEMS[uid][item_slot] 	loadstring(menu.itemdata[item_id].func)() 	menu.inv_remove(uid,item_slot) end function menu.inv_sell(uid,item_slot) 	local item_id=USER_ITEMS[uid][item_slot] 	local item=menu.itemdata[item_id] 	parse("setmoney "..uid.." "..(player(uid,"money")+math.floor(item.price/2))) 	 	msg2(uid,item.name.." vendido por "..item.price.." de cash.") 	menu.inv_remove(uid,item_slot) end function menu.inv_add(uid,item_id) 	local item_id=item_id or 1 	local items=table.copy(USER_ITEMS[uid]) 	 	table.insert(items,item_id) 		 	if #USER_ITEMS[uid] <= 14 then 		USER_ITEMS[uid] = items 	else 		msg2(uid,"Desculpe, o seu inventório está cheio.") 	end end function menu.inv_show(uid) 	local data=USER_ITEMS[uid] 	local newdata={title="Inventório";button={{name="Menu Principal",caption="Voltar",target="@main_menu"}}} 	for slot,item_id in pairs(data) do 		newdata.button[slot+1] = {name=(menu.itemdata[item_id].name),func="USER[v_me].sel=(v_slot-1)",target="@equip"} 	end 	menu.show(uid,newdata) end function menu.inv_addname(uid,_name) 	for item_id,data in ipairs(menu.itemdata) do 		if menu.itemdata[item_id].name:lower()==_name:lower() then 			menu.inv_add(uid,item_id) 			return 		end	 	end	 	return error("Erro, esse item não existe.") end function heal_p(uid,amount) 	parse("sethealth "..uid.." "..player(uid,"health")+amount) 	msg2(uid,"Você foi curado em "..amount.." pontos") end
Spoiler
See those lines:
This is where you are going to add information about itens.
price
The price of the item (enough said)
name
The name of the item (enough said too)
desc
The description of the item (too obvious)
func
The function that will be executed when you use that item. "v_me" is the global variable that represents your own ID. Inside the "", you write as if you were doing lua scripts normally. It is called string.load, you can check this function in the beginning of the script.
And some functions about items:
menu.inv_add(id,item_id)
Add an item to player by Item ID
menu.inv_addname(id,name)
Add an item to player by name
menu.inv_buy(id,item_id)
Buy an item to player by Item ID
menu.inv_remove(id,item_id)
Remove an item from player by Item ID
menu.inv_shopdesc(id,item_id)
Show a description of Item ID to player.
menu.inv_desc(id,item_slot)
Show a description of the slot inventory of the player.
menu.inv_use(id,item_slot)
Use an item from slot inventory of the player.
menu.inv_sell(id,item_slot)
Sells an item from slot inventory of the player for the half price it was bought.
menu.inv_show(id)
Show the player's inventory.
There is a very advanced menu function in the script too, if you guys want me to explain that, dont PM me. Just ask it here.
And I'm sorry if the script is in portuguese, I don't have interest in translating it.
Quote
menu.itemdata={
{
name="Poção de HP [250]",
price=120,
desc="Esta poção recupera totalmente sua saude.",
func="heal_p(v_me,250)"
};
{
name="Poção de HP [100]",
price=50,
desc="Esta poção recupera sua saude.",
func="heal_p(v_me,100)"
};
{
name="Poção de HP [50]",
price=30,
desc="Esta poção recupera um pouco sua saude.",
func="heal_p(v_me,50)"
};
{
name="Poção de HP [20]",
price=10,
desc="Esta poção recupera um pouquinho sua saude.",
func="heal_p(v_me,20)"
};
}
{
name="Poção de HP [250]",
price=120,
desc="Esta poção recupera totalmente sua saude.",
func="heal_p(v_me,250)"
};
{
name="Poção de HP [100]",
price=50,
desc="Esta poção recupera sua saude.",
func="heal_p(v_me,100)"
};
{
name="Poção de HP [50]",
price=30,
desc="Esta poção recupera um pouco sua saude.",
func="heal_p(v_me,50)"
};
{
name="Poção de HP [20]",
price=10,
desc="Esta poção recupera um pouquinho sua saude.",
func="heal_p(v_me,20)"
};
}
This is where you are going to add information about itens.
price
The price of the item (enough said)
name
The name of the item (enough said too)
desc
The description of the item (too obvious)
func
The function that will be executed when you use that item. "v_me" is the global variable that represents your own ID. Inside the "", you write as if you were doing lua scripts normally. It is called string.load, you can check this function in the beginning of the script.
And some functions about items:
menu.inv_add(id,item_id)
Add an item to player by Item ID
menu.inv_addname(id,name)
Add an item to player by name
menu.inv_buy(id,item_id)
Buy an item to player by Item ID
menu.inv_remove(id,item_id)
Remove an item from player by Item ID
menu.inv_shopdesc(id,item_id)
Show a description of Item ID to player.
menu.inv_desc(id,item_slot)
Show a description of the slot inventory of the player.
menu.inv_use(id,item_slot)
Use an item from slot inventory of the player.
menu.inv_sell(id,item_slot)
Sells an item from slot inventory of the player for the half price it was bought.
menu.inv_show(id)
Show the player's inventory.
There is a very advanced menu function in the script too, if you guys want me to explain that, dont PM me. Just ask it here.
And I'm sorry if the script is in portuguese, I don't have interest in translating it.
Approved by GeoB99
Download
3 kb, 427 Downloads