Forum

> > CS2D > Scripts > shop x y
Forums overviewCS2D overview Scripts overviewLog in to reply

English shop x y

7 replies
To the start Previous 1 Next To the start

old shop x y

nvdie
User Off Offline

Quote
i need a script when someone go to x y area and press f4 you can buy weapons with cs2d money

________________________________________________________________________________________________________

Weapons > m3, nightvision and light armor
Prices > m3 = 10000 • nightvision = 5000 • light armor = 15000 •
________________________________________________________________________________________________________

X Y > 49 18 •
X Y 2 > 50 18 •
_____________

X Y 3 > 89 15 •
X Y 4 > 90 15 •

________________________________________________________________________________________________________

old Re: shop x y

RedizGaming
GAME BANNED Off Offline

Quote
i think this work.
Spoiler >

old Re: shop x y

RIP-HereRestsPlookerbooy
BANNED Off Offline

Quote
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
Shops = {
	{name = "Weapon Shop", menu = {{10, "M3", 10000}, {59, "Night Vision", 5000}, {79, "Light Armor", 15000}}, positions = {{1,1},{3,3},{5,5},{7,7}}}
}

addhook("serveraction","shop_serveraction")
function shop_serveraction(id,act,x,y)
	if act == 3 then
		for k, _ in pairs(Shops) do
			for v, _ in pairs(Shops[k].positions) do
				if player(id, "tilex") == Shops[k].positions[v][1] and player(id,"tiley") == Shops[k].positions[v][2] then
					local text = ""
					for n, _ in pairs(Shops[k].menu) do
						text = text..", "..Shops[k].menu[n][2].."|$"..Shops[k].menu[n][3]
					end
					menu(id, Shops[k].name..text)
				end
			end
		end
	end
end

addhook("menu","shop_menu")
function shop_menu(id,tit,but)
	for k, _ in pairs(Shops) do
		if tit == Shops[k].name then
			for v, _ in pairs(Shops[k].menu) do
				if but == v then
					if player(id,"money") >= Shops[k].menu[v][3] then
						parse('setmoney '..id..' '..player(id,'money')-Shops[k].menu[v][3])
						parse('equip '..id..' '..Shops[k].menu[v][1])
					else
						msg2(id,"Not enought money")
					end
				end
			end
		end
	end
end

Made by DC
-- TOP joke 2017, not even close
edited 1×, last 16.01.17 01:23:39 am

old Re: shop x y

RedizGaming
GAME BANNED Off Offline

Quote
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
items = {
	[1] = {
		name = "m3",
		cost = 10000,
	},
	[2] = {
		name = "Night Vision",
		cost = 5000,
	},
	[3] = {
		name = "Light Armor",
		cost = 15000,
	}
}

shop = {}
shop.location = {
	[1] = {
		x = 19,
		y = 18,
	},
	[2] = {
		x = 50,
		y = 18,
	},
	[3] = {
		x = 89,
		y = 15,
	},
	[4] = {
		x = 90,
		y = 15,
	}
}

addhook("use","shop.use")
function shop.use(id)
	if player(id,'tilex') == shop.location[1].x and player(id,'tiley') == shop.location[1].y or player(id,'tilex') == shop.location[2].x and player(id,'tiley') == shop.location[2].y or player(id,'tilex') == shop.location[3].x and player(id,'tiley') == shop.location[3].y or player(id,'tilex') == shop.location[4].x and player(id,'tiley') == shop.location[4].y then
		menu(id,'SHOP,M3|$10000,NightVision|$5000,Light Armor|$15000')
	end
end

addhook("menu","shop_menu")
function shop_menu(id,tit,but)
     if tit == "SHOP" then
          if but == 1 then
               if player(id,'money')>= items[1].cost then
                    parse('setmoney '..id..' '..player(id,'money')-items[1].cost)
                    parse('equip '..id..' 10')
               end
          end
          if but == 2 then
               if player(id,'money')>=items[2].cost then
                    parse('setmoney '..id..' '..player(id,'money')-items[2].cost)
                    parse('equip '..id..' 59')
               end
          end
          if but == 3 then
               if player(id,'money')>=items[3].cost then
                    parse('setmoney '..id..' '..player(id,'money')-items[3].cost)
                    parse('equip '..id..' 79')
               end
          end
     end
end

this works

if you dont use position in TILEs use this code

Spoiler >


EDITED

old Re: shop x y

RIP-HereRestsPlookerbooy
BANNED Off Offline

Quote
1
{name = "Weapon Shop", menu = {{10, "M3", 10000}, {59, "Night Vision", 5000}, {79, "Light Armor", 15000}}, positions = {{49,18},{50,18},{89,15},{90,15}}}

Edit it
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview