Forum

> > CS2D > Scripts > How to open and close shops within a menu?
Forums overviewCS2D overview Scripts overviewLog in to reply

English How to open and close shops within a menu?

5 replies
To the start Previous 1 Next To the start

old Re: How to open and close shops within a menu?

Dousea
User Off Offline

Quote
Here, I give you a clue on how to make shop menu. In my code you can only put 9 items into the shop, because of CS2D menu limit. You can find a menu script that extends current menu (paging menu) in File Archive.
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
local items = {
	-- {[item-type], [price]}
	{51, 50},
	{52, 25}
}

function serveractionhook(id, action)
	if (action == 2) then
		local content = ""
		
		for index, item in ipairs(items) do
			content = content .. itemtype(item[1], "name") .. "|$" .. item[2] .. (index == #items and "" or ",")
		end
		
		menu(id, "Shop Menu," .. content)
	end
end

function menuhook(id, title, button)
	if (title == "Shop Menu") then
		if (button >= 1 and button <= 9) then
			local item = items[button]
			
			if (player(id, "money") >= item[2]) then
				parse("equip " .. id .. " " .. item[1] .. "; setmoney " .. id .. " " .. (player(id, "money") - item[2]), 0)
			else
				msg2(id, "\169255000000You have insufficient funds!")
			end
		end
	end
end

addhook("serveraction", "serveractionhook")
addhook("menu", "menuhook")

old Re: How to open and close shops within a menu?

VADemon
User Off Offline

Quote
If you expect someone to make a script for you, why don't you at least invest some time into writing a proper explanation and feature set?

user Blockertk has written
anyone knows how to Add open close shops from f3 menu please help me

I don't even understand what you want. Nuff said.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview