Lua Request: After player dies 'x' times...
5 replies



15.08.14 02:42:00 pm
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.
All help greatly appreciated.
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
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
Code:
1
2
3
4
5
6
7
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
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
Code:
1
parse("setdeaths "..id.." 0")


Thanks guys, they're all awesome. Just what I requested, works wonderfully just like I expected them to.
EDIT: And thanks for letting me know,
Rainoth and
MikuAuahDark
EDIT: And thanks for letting me know,





