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

byengul
User Off Offline

Quote
I find the complete code with trying;

addhook("use","mod_use")
function mod_use(id,event,data,x,y)

     if x == 71 and y == 38 then
          if (player(id,"money")>=800) then
          parse ("setmoney "..id.." "..(player(id,"money")-800));
          parse("equip "..id.." "..79)
          else if(player(id,"money")<800) then
          msg2 (id,"©255000000This item costs 800$!@C");
          end end
     end

thx everyone for your helps
end

old Re: Need help about Trigger

DC
Admin Off Offline

Quote
the line
1
else if(player(id,"money")<800) then
is pointless because you already checked if the player has 800 or more $. it can only be less than 800 if the code reaches the else branch. you don't need to check the same thing again

replace the line with
1
else
that's enough to make it work.

moreover please use tabs to write your code in a clean way. it's much easier/faster to understand properly indented code:
1
2
3
4
5
6
7
8
9
10
11
addhook("use","mod_use")
function mod_use(id,event,data,x,y)
	if x == 71 and y == 38 then
		if (player(id,"money")>=800) then
			parse ("setmoney "..id.." "..(player(id,"money")-800));
			parse("equip "..id.." "..79)
		else
			msg2 (id,"©255000000This item costs 800$!@C");
		end
	end
end

old Re: Need help about Trigger

byengul
User Off Offline

Quote
ty I've 1 question again how can i make when a player kills breakable box which i've choose will drop coins or any weapon

old Re: Need help about Trigger

DC
Admin Off Offline

Quote
1
2
3
4
5
6
addhook("break","mod_break")
function mod_break(x,y)
	if x==INSERT-X-POS and y=INSERT-Y-POS then
		-- add your action here
	end
end

old Re: Need help about Trigger

Vectarrio
User Off Offline

Quote
For item you dont need lua. You can write some "trigger" mark to your entity. And add entity env_item, with option spawn item on trigger only, and with name of env_item=trigger of env_breakable.

old Re: Need help about Trigger

DC
Admin Off Offline

Quote
but you can't drop it at the position where the breakable is because there is only 1 entity allowed per tile. if you want to drop it at the same position: use Lua.

please take a look at the command references to find what you need. I don't want to explain everything in minute detail.
cs2d cmd spawnitem

old Re: Need help about Trigger

byengul
User Off Offline

Quote
it's not important but i'll need a code which i can make flamethrower gives hp
edited 1×, last 28.02.10 07:33:32 pm

old Re: Need help about Trigger

TimeQuesT
User Off Offline

Quote
1
2
3
4
5
6
addhook ("hit","hot")
function hot(id,wp)
if(wp=wpid) then
parse ("sethealth "..id.." "..(player(id,"health")+5));
end
end
that must work.try this.
To the start Previous 1 2 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview