Forum

> > CS2D > General > Need help about Trigger
Forums overviewCS2D overviewGeneral overviewLog in to reply

English Need help about Trigger

30 replies
Page
To the start Previous 1 2 Next To the start

old Re: Need help about Trigger

Starkkz
Moderator Off Offline

Quote
post this on lua thread.

and here is your code.
1
2
3
4
5
6
7
8
9
10
tile_use_x = [b]type the tile coordinates (X) [/b]
tile_use_y = [B]type the tile coordinates (Y) [/b]
wpn = [b]Item type here[/b]

addhook("use","mod_use")
function mod_use_(id,event,data,x,y)
	if x == tile_use_x and y = tile_use_y then
		parse("equip "..id.." "..wpn)
	end
end
edited 1×, last 25.02.10 06:47:01 pm

old Re: Need help about Trigger

DC
Admin Off Offline

Quote
you can. but it makes more sense to make a map related lua script which will only be loaded with your map.
just create a file in the maps folder called like your map with .lua as extension.

e.g. if your map is called crazytriggershit make a file maps/crazytriggershit.lua

also note that starkkz wrote weapon one time and wpn another time. it has to be either weapon or wpn both times + there has to be a trigger_use at that position (x and y) of the map.

old Re: Need help about Trigger

byengul
User Off Offline

Quote
how can i learn x y positions when editing map? and i need to copy always new code?
tile_use_x = type the tile coordinates (X)
tile_use_y = type the tile coordinates (Y)
weapon = Item type here

can you guyz show me with a photo please? or can you guyz help me to edit this map

old Re: Need help about Trigger

DC
Admin Off Offline

Quote
bottom left of the editor when pointing at a tile: "Tile Position X|Y ..." - these are the values you need for x and y. place an item entity and take a look at the item list (available when clicking at the entity) to see the weapon ids.

you can actually insert the values directly
1
2
3
4
5
6
7
8
9
10
11
12
13
14
addhook("use","mod_use")
function mod_use(id,event,data,x,y)

	if x == X1 and y == Y1 then
		parse("equip "..id.." "..WPN1)
	end

	if x == X2 and y == Y2 then
		parse("equip "..id.." "..WPN2)
	end

	-- and so on...

end

all you need to do is replacing X1,Y1 and WPN1 with the actual numbers (tile position + weapon id). then you can copy these 3 lines and do the same for your next weapon trigger (here X2,Y2,WPN2). you can copy these 3 lines as often as you like and insert different positions and weapon ids.

old Re: Need help about Trigger

byengul
User Off Offline

Quote
THXXX it Worked but i have 1 question how can i make decrease money when players get this items?
edited 2×, last 25.02.10 08:16:59 pm

old Re: Need help about Trigger

TimeQuesT
User Off Offline

Quote
1
parse ("setmoney "..id.." "..(player(id,"money")-xyz));
....
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("use","mod_use") 
function mod_use(id,event,data,x,y) 

     if x == X1 and y == Y1 then 
          parse("equip "..id.." "..WPN1) 
	  parse ("setmoney "..id.." "..(player(id,"money")-1500));
     end 

     if x == X2 and y == Y2 then 
          parse("equip "..id.." "..WPN2) 
	  parse ("setmoney "..id.." "..(player(id,"money")-33300));
     end 

     -- and so on... 

end

old Re: Need help about Trigger

byengul
User Off Offline

Quote
I've used parse ("setmoney "..id.." "..(player(id,"money")-1500)); code but i can buy unlimited i want to block buying if they havent got money
edited 1×, last 26.02.10 04:24:58 pm

old Re: Need help about Trigger

byengul
User Off Offline

Quote
Mmm i didn't done it >.< aww sry but i've 1 question too again how can i make auto message like "This item's Price is 2000" if their money is not enough to buy
edited 2×, last 27.02.10 11:14:16 am

old Re: Need help about Trigger

TimeQuesT
User Off Offline

Quote
1
2
3
4
5
if (player(id,"money")>=1500) then 
xyz...
else if(player(id,"money")<1500) then
msg2 (id,"©255000000this item costs 1500$!@C");
end
this displays a red text...

old Re: Need help about Trigger

TimeQuesT
User Off Offline

Quote
yes pikachu is right.
xyz is the place where you have to put your code in.
and...
the "parse ("equip"..id.."xyz");" thing must into the if...

old Re: Need help about Trigger

Cure Pikachu
User Off Offline

Quote
Schinken has written
yes pikachu is right.
xyz is the place where you have to put your code in.
and...
the "parse ("equip"..id.."xyz");" thing must into the if...

Or else you still get the item, even without money.

byengul has written
yes i need a complete code or a picture please ...

Here, try this code (I am still a beginner but here you go):

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
addhook("use","mod_use")
function mod_use(id,event,data,x,y)
	if x == 71 and y == 35 then
		if (player(id,"money")>=4500 then
			parse("setmoney "..id.." ..(player(id,"money")-4500)");
			parse("equip "..id.." ..41);
		else
			msg2(id,"©255000000This item costs $4500!@C");
		end
	elseif x == 71 and y == 38 then
		if (player(id,"money")>=800) then
			parse("setmoney "..id.." ..(player(id,"money")-800)");
			parse("equip "..id.." "..41);
		else
			msg2(id,"©255000000This item costs $800!@C");
		end
	elseif x == 71 and y == 39 then
		if (player(id,"money")>=2000) then
			parse("setmoney "..id.." ..(player(id,"money")-2000)");
			parse("equip "..id.." "..59);
		else
			msg2(id,"©255000000This item costs $2000!@C");
		end
	-- And so on...
	end
end
edited 7×, last 28.02.10 07:22:57 am

old Re: Need help about Trigger

Admir
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
addhook("use","mod_use")
function mod_use(id,event,data,x,y)
	if x == 71 and y == 35 then
		if (player(id,"money")>=4500) then
			parse("setmoney "..id.." "..player(id,"money")-4500)
			parse("equip "..id.." "..41)
		else
			msg2(id,"©255000000This item costs $4500!@C")
		end
	elseif x == 71 and y == 38 then
		if (player(id,"money")>=800) then
			parse("setmoney "..id.." "..player(id,"money")-800)
			parse("equip "..id.." "..41)
		else
			msg2(id,"©255000000This item costs $800!@C")
		end
	elseif x == 71 and y == 39 then
		if (player(id,"money")>=2000) then
			parse("setmoney "..id.." "..player(id,"money")-2000)
			parse("equip "..id.." "..59)
		else
			msg2(id,"©255000000This item costs $2000!@C")
		end
	-- And so on...
	end
end

try this 1
To the start Previous 1 2 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview