edited 2×, last 13.02.11 03:02:15 pm
Forum
Scripts
Buy menu in lua?
Buy menu in lua?
24 repliesedited 1×, last 13.02.11 02:06:16 pm
a 100 times better title would be for example "Lua Buy Menu Script" or something like it. short. not generic. explaining what you actually want.
is it so hard to choose a good title?!
edit: ah finally. thanks for editing!

However, first I need to know what the button's id is, or I can't actually figure out what button is being pressed on the map
When you press button at the block, you can buy hat.
Try search it in multigame script
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
addhook("usebutton","buy_menu")
function buy_menu(id,x,y)
	if x == bX and y == bY then
		menu(id,"Buy Menu,AK47 | 3000$, M4A1 | 5000$, ETC | 1988$")
	end
end
addhook("menu","buy_menu2")
function buy_menu2(id,title,button)
	if title == "Buy Menu" then
		loadstring("buy_button"..button.."(id)") --this executes the function 'buy_button[the_buttons_id](the_persons_id) --
	end
end
function buy_button1(p-id) -- This would be for the first button, the AK47 --
	if player(p-id,"money") <= 3000 then
		parse("setmoney "..p-id.." "..(player(p-id,"money")-3000))
		parse("equip "..p-id.." 30") -- For more ids, see nest code block --
end
function buy_button2(p-id) -- This would be for the second button, the M4A1 --
	if player(p-id,"money") <= 5000 then
		parse("setmoney "..p-id.." "..(player(p-id,"money")-5000))
		parse("equip "..p-id.." 32") -- For more ids, see nest code block --
end
And here are the weapon ids, incase you dont know them:
edited 1×, last 13.02.11 02:58:48 pm
Uhh...
PartyPooPer has written
"Buy MEN in lua?"
Uhh...
Uhh...
*facepalm*
@Danny, thanks, but how can I modify the buy button/tile?
1
if x == bX and y == bY
1
if x == bX and y == bY then
And the buy button, well:
1
menu(id,"Buy Menu,AK47 | 3000$, M4A1 | 5000$, ETC | PRICE")
1
if title == "Buy Menu" then
Then what you do is you put the name of the item, and then a |, and then the price. Thats how i did it, atleast.
Then what you need to do is count the button and name the function buy_button[INSERT_BUTTON_NO_HERE] function accordingly.
It's actually pretty complex thanks to my use of 'loadstring', but you would probably see what it does easily, right?
LUA ERROR: sys/lua/zombie.lua:15: ')' expected near '-'
so what?
Everything works, yaaay!
Script is public domain
Here is the modified 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
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
addhook("menu","buy_menu2")
function buy_menu2(id,title,button)
if title == "Buy Menu" then
loadstring("buy_button"..button.."(id)") --this executes the function 'buy_button[the_buttons_id](the_persons_id) --
end
end
function buy_button1(p_id)
if player(p_id,"money") <= 5500 then
parse("setmoney "..p_id.." "..(player(p_id,"money")-5500))
parse("equip "..p_id.." 30")
end
end
function buy_button2(p_id)
if player(p_id,"money") <= 5000 then
parse("setmoney "..p_id.." "..(player(p_id,"money")-5000))
parse("equip "..p_id.." 32")
end
end
function buy_button3(p_id)
if player(p_id,"money") <= 4000 then
parse("setmoney "..p_id.." "..(player(p_id,"money")-4000))
parse("equip "..p_id.." 10")
end
end
function buy_button5(p_id)
if player(p_id,"money") <= 1000 then
parse("setmoney "..p_id.." "..(player(p_id,"money")-1000))
parse("equip "..p_id.." 3")
end
end
function buy_button7(p_id)
if player(p_id,"money") <= 10000 then
parse("setmoney "..p_id.." "..(player(p_id,"money")-10000))
parse("equip "..p_id.." 59")
end
end
1 
Offline
