Forum

> > CS2D > Scripts > Trade script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Trade script

6 replies
To the start Previous 1 Next To the start

old Trade script

Jela331
User Off Offline

Quote
Hello, Unrealsoftware.
I'm currently working on a map which is similliar to the Dead Island.
For those who have played dead island, you could trade with some survivors.
So, I'll need a script in which you press the button near the survivor and menu pops out with some weapons.
For example:

----------------------
P228 5000$
P. Ammo 3000$
S. Ammo 2500$
Molotov Cocktail 4000$
----------------------

You could also sell the survivor your weapons.
Example:

Sell:

UMP.45-10000$
Glock-5000$
Molotov cocktail-4000$

After you sell the weapon, you wont have that weapon anymore and you will get money.


I really need that script, otherwise I cannot finish the map.
Thanks.

old Re: Trade script

EP
User 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
pos = {X,Y}

function nmn(id)
	msg2(id,"©255000000You don't have enough money!@C")
end

function m(id,amount)
	parse("setmoney "..id.." "..(player(id,"money")-amount))
end

addhook("use","a")
function a(id,event,data,x,y)
     if x == pos[1] and y == pos[2] then
          menu(id,"Trade Menu,P228|5000$,P.Ammo|3000$,S.Ammo|2500$,Molotov Cocktail|4000$")
     end
end

addhook("menu","b")
function b(id,t,b)
     if t == "Trade Menu" then
          if b == 1 then
               if player(id,"money") >= 5000 then
                    parse("equip "..id.." 4")
					m(id,5000)
               else
                    nmn(id)
               end
          elseif b == 2 then
               if player(id,"money") >= 3000 then
                    parse("equip "..id.." 61")
					m(id,3000)
               else
                    nmn(id)
               end
          elseif b == 3 then
               if player(id,"money") >= 2500 then
                    parse("equip "..id.." 62")
					m(id,2500)
               else
                    nmn(id)
               end
          elseif b == 4 then
               if player(id,"money") >= 4000 then
                    parse("equip "..id.." 73")
					m(id,4000)
               else
                    nmn(id)
               end
          end
     end
end
Change positions X and Y (pixels) , added the "-" money ._.
edited 2×, last 04.03.12 04:51:43 pm

old Re: Trade script

Suprise
BANNED Off Offline

Quote
user EP has written
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
pos = {X,Y}
addhook("use","a")
function a(id,event,data,x,y)
	if x == pos[1] and y == pos[2] then
		menu(id,"Trade Menu,P228|5000$,P.Ammo|3000$,S.Ammo|2500$,Molotov Cocktail|4000$")
	end
end

addhook("menu","b")
function b(id,t,b)
	if t == "Trade Menu" then
		if b == 1 then
			if player(id,"money") >= 5000 then
				parse("equip "..id.." 4")
			else
				msg2(id,"©255000000You don't have enough money!@C")
			end
		elseif b == 2 then
			if player(id,"money") >= 3000 then
				parse("equip "..id.." 61")
			else 
				msg2(id,"©255000000You don't have enough money!@C")
			end
		elseif b == 3 then
			if player(id,"money") >= 2500 then
				parse("equip "..id.." 62")
			else 
				msg2(id,"©255000000You don't have enough money!@C")
			end
		elseif b == 4 then
			if player(id,"money") >= 4000 then
				parse("equip "..id.." 73")
			else 
				msg2(id,"©255000000You don't have enough money!@C")
			end
		end
	end
end
i did it fast xd, untested


And where's the "-" moneys?

old Re: Trade script

Jela331
User Off Offline

Quote
Okay, thanks.
It did work.

Sell script doesn't matter anyway.
Oh and, I'm planning to add more survivors to trade with, so should I write this in the script?

pos = {{X,Y},{X,Y}}

old Re: Trade script

Jela331
User Off Offline

Quote
@user Big Bang Mafia:
I cannot currently test it, I haven't added more survivors to trade with.
I'll test it at the end.

P.S.
Filbumwinter, you'll get a big credit for that.

old Re: Trade script

EP
User Off Offline

Quote
im making it now, but it will take a long/medium time, im making it for make more npcs easier, if i make it without easier functions you will not can make other npcs D:<
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview