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

5 replies
Goto Page
To the start Previous 1 Next To the start
Up
8Ball
User
Offline Off
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.
15.08.14 03:19:04 pm
Up
TrialAndError
User
Offline Off
Code:
1
2
3
if player(id,"deaths)>=x then
-- ur code
end
15.08.14 03:47:43 pm
Up
_oops
User
Offline Off
Code:
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
15.08.14 06:12:13 pm
Up
Rainoth
Moderator
Offline Off
Code:
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
Code:
1
parse("setdeaths "..id.." 0")
MAL • DeviantArt • For Wallpaper Engine users • Check YT for playlists... •
16.08.14 05:28:24 am
Up
MikuAuahDark
User
Offline Off
To add user Rainoth posts: or with this statement
Code:
if player(id,"deaths")%limit==0
file cs2d LuaJIT for Dedicated Server (13) JIT POWER! | Know your Lua errors! | Part of LÖVE development team since 11.3
16.08.14 07:32:21 am
Up
8Ball
User
Offline Off
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, user Rainoth and user MikuAuahDark
To the start Previous 1 Next To the start