Forum

> > CS2D > Scripts > Trigger function examplee
Forums overviewCS2D overview Scripts overviewLog in to reply

English Trigger function examplee

5 replies
To the start Previous 1 Next To the start

old Re: Trigger function examplee

RAVENOUS
BANNED Off Offline

Quote
Go into your info.txt file and search the "use()" hook.

Then easily place a trigger_use somewhere, notice its x- and y-coords. Then check the use() hook if you're standing on it's tile.

Done. If you still need an example then you should try things yourself.

old Re: Trigger function examplee

Starkkz
Moderator Off Offline

Quote
Not really tobey, it's not necessary the "trigger_use" entity. You just need to do something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
addhook("use","onUse")
function onUse(id,event,x,y)
	local x = x or player(id,"tilex")
	local y = y or player(id,"tiley")
	-- Events are 5
	if event == 1 then
		-- Hostage follow
	elseif event == 2 then
		-- Hostage stop
	elseif event == 3 then
		-- Defuse Bomb
	elseif event == 100 then
		-- Trigger Use
	elseif event == 150 then
		-- Dynamic Object
	else
		-- Press "E" without any wanted point
	end
end

In the case of "else", it's called when you didn't want to do anything, just it's called because the player pressed the "E"

1
2
3
4
5
6
7
8
addhook("use","onUse")
function onUse(id,event,x,y)
	local x = x or player(id,"tilex")
	local y = y or player(id,"tiley")
	if x == tile X and y == tile Y then
		-- Do your action
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview