Forum

> > CS2D > Scripts > Lua Request: After player dies 'x' times...
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Request: After player dies 'x' times...

5 replies
To the start Previous 1 Next To the start

old Lua Request: After player dies 'x' times...

8Ball
User Off Offline

Quote
Basically need a lua that will 'count' the number of x player's deaths every time he dies and if his death number exceeds x deaths then a trigger (as in the map editor entity) will be activated.

All help greatly appreciated.

old Re: Lua Request: After player dies 'x' times...

_oops
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
deathc=0;
addhook("die","_die")
addhook("startround","resdeath")

function _die(id)
deathc=deathc+1
	if (deathc == x ) then -- change x to the number
	parse("trigger blahblah")
	end
end

function resdeath()
deathc=0
end

old Re: Lua Request: After player dies 'x' times...

Rainoth
Moderator Off Offline

Quote
1
2
3
4
5
6
7
limit = 10
addhook("die","_die")
function _die(id)
	if player(id,"deaths") == limit then
		parse("trigger nameoftrigger")
	end
end

Change 'limit' to how many deaths need to be completed before the trigger works. Mind that this will not reset deaths of a player so the next round when the player dies, he'll have 11 deaths and will no longer trigger. If you want it to work differently, use
1
parse("setdeaths "..id.." 0")
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview