.:HyPeX:. Posted February 12, 2014 Share Posted February 12, 2014 (edited) Hey guys, if i want to know how many players are alive, onClientPlayerWasted will return the actual alive players after the current trigger, or before the trigger? like if the player who died was the 3rd and only two remaining, then a # on getAlivePlayers will return 3 or 2? And this applies as same to the server-side trigger? Thanks HyPeX Edited February 13, 2014 by Guest Link to comment
Anubhav Posted February 12, 2014 Share Posted February 12, 2014 https://wiki.multitheftauto.com/wiki/On ... ayerWasted -- Doesn't return's. https://wiki.multitheftauto.com/wiki/TriggerServerEvent --Returns true if the event trigger has been sent, false if invalid arguments were specified. Link to comment
.:HyPeX:. Posted February 12, 2014 Author Share Posted February 12, 2014 Please, just answer my question, i now know only this could be done server side and sent client side after ir eaded the functions, I want to know if onPlayerWasted will display the number of people left after the source died, or before it died (SUPPOSING OBIOUSLY I TRIGGER getAlivePlayers ON IT!) Link to comment
denny199 Posted February 12, 2014 Share Posted February 12, 2014 You should test that by yourself? I'm guessing that when you are using onPlayerWasted is triggered if the player dies, so that means that he is actually dead, just test it with a friend or someone else,just stop the resource play or anything else what is making you spawn, run your script, kill him and check if it's working. If you don't have anyone to test it, then just say it that you wasn't be able to test it. Link to comment
Saml1er Posted February 12, 2014 Share Posted February 12, 2014 function AlivePlayersCheck() local theTable = { } local players = getElementsByType ( "player" ) for i,v in pairs(players) do if not isPedDead(v) then theTable[#theTable+1]=v end end return theTable end addEventHandler("onPlayerWasted", getRootElement(), function () local count = #AlivePlayersCheck() or 0 -- g alive players. if count == "" then outputChatBox ( "0 players are alive " ) --trigger it else -- trigger it outputChatBox (tonumber(count) .." players are alive.") end end ) getAlivePlayers will return a table of alive player and yes if 3rd player dies then it will output the names of the 2 alive players but if nobody is alive then it will output none. Link to comment
.:HyPeX:. Posted February 13, 2014 Author Share Posted February 13, 2014 function AlivePlayersCheck() local theTable = { } local players = getElementsByType ( "player" ) for i,v in pairs(players) do if not isPedDead(v) then theTable[#theTable+1]=v end end return theTable end addEventHandler("onPlayerWasted", getRootElement(), function () local count = #AlivePlayersCheck() or 0 -- g alive players. if count == "" then outputChatBox ( "0 players are alive " ) --trigger it else -- trigger it outputChatBox (tonumber(count) .." players are alive.") end end ) getAlivePlayers will return a table of alive player and yes if 3rd player dies then it will output the names of the 2 alive players but if nobody is alive then it will output none. Yeah, that was my supposition after i readed the none thingy. But, how will it output if i do #getAlivePlayers and count is none, will it be nil? Link to comment
Moderators IIYAMA Posted February 13, 2014 Moderators Share Posted February 13, 2014 It will be 0. It will return nil when it fails doing it's job, which should not happen. But the benefit of the function a both, is that you can filter the list in every possible ways. (money,score, health, armor, vehicle,ping,location,rotation and many more...) Else just use getAlivePlayers() it is much faster then isPedDead per player. Link to comment
.:HyPeX:. Posted February 13, 2014 Author Share Posted February 13, 2014 It will be 0. It will return nil when it fails doing it's job, which should not happen.But the benefit of the function a both, is that you can filter the list in every possible ways. (money,score, health, armor, vehicle,ping,location,rotation and many more...) Else just use getAlivePlayers() it is much faster then isPedDead per player. Yes it worked with 0. But only with getAlivePlayers and im getting problems im trying to fix over here Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now