Has the issue of detecting if a play quits the game before it is over been solved?
From what I understand, the "Player Leaves" event ONLY works in the case of victory, defeat or a tie (basically the game is over). But what about the cases when the player leaves the game in the middle? Quitting from the menu, using Ctrl + F4, or a simple disconnect/lag drop.
I've heard of two potential semi-solutions. One is to have a trigger continuously running (like every 1 sec), and checking if any player status == Left The Game. Aside from having a continuously running trigger (when you shouldn't need it), how do you remove a player from being checked after he's been already confirmed as leaving the game? The trigger would then just keep firing.
The other thing I've heard is detecting the menu buttons being pressed for quitting. This works for quitting via menus, but what about Ctrl + F4 or disconnect/lag drop?
Does anyone have a proper solution for all of this?
I do the hackish solution of checking every 4-5 secs... but you need a global boolean variable (array), something like "Player Has Already Left", by default all values set to False. Then periodically check, by looping through each player and checking if their status == left the game && player has already left == false, and if so THEN do necessary leave game stuff for that player, and of course set player has already left for said player to True.
Ahh OneTwoSC beat me to it! Here's a similar way though:
For the periodical trigger idea, add all user controlled players to a variable at game init, Player Group type. In your trigger, pick all players in the player group variable to check if they left. Then when a player leaves, remove the player from the player group. It'll only check players still in the game.
I can't imagine there isn't a way to detect if a player left regardless, it seems like such a commonly used event that they'd have it in there.
Simpler way than a huge 14 player boolean array is just a player group. Add all active players to it at the start, remove them from the group if your check notices they left.
Have the trigger only check players that are still in the player group.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Has the issue of detecting if a play quits the game before it is over been solved?
From what I understand, the "Player Leaves" event ONLY works in the case of victory, defeat or a tie (basically the game is over). But what about the cases when the player leaves the game in the middle? Quitting from the menu, using Ctrl + F4, or a simple disconnect/lag drop.
I've heard of two potential semi-solutions. One is to have a trigger continuously running (like every 1 sec), and checking if any player status == Left The Game. Aside from having a continuously running trigger (when you shouldn't need it), how do you remove a player from being checked after he's been already confirmed as leaving the game? The trigger would then just keep firing.
The other thing I've heard is detecting the menu buttons being pressed for quitting. This works for quitting via menus, but what about Ctrl + F4 or disconnect/lag drop?
Does anyone have a proper solution for all of this?
@ZarafFaraz: Go
Welcome to my pain :D
I do the hackish solution of checking every 4-5 secs... but you need a global boolean variable (array), something like "Player Has Already Left", by default all values set to False. Then periodically check, by looping through each player and checking if their status == left the game && player has already left == false, and if so THEN do necessary leave game stuff for that player, and of course set player has already left for said player to True.
Ahh OneTwoSC beat me to it! Here's a similar way though:
For the periodical trigger idea, add all user controlled players to a variable at game init, Player Group type. In your trigger, pick all players in the player group variable to check if they left. Then when a player leaves, remove the player from the player group. It'll only check players still in the game.
I can't imagine there isn't a way to detect if a player left regardless, it seems like such a commonly used event that they'd have it in there.
You can also make a trigger which occurs every 0.33 real time sec. With this:
- If Then Else Comparison Value 1: Status Of Player Player: 1 Operator: == Value 2: Left The Game
And if he left the game, put a boolean so the If Then Else doesn't happen again, and output whatever you want to do if the player left the game.
You can remove the player being checked by putting it in a trigger and then disabling the trigger when he leaves.
Simpler way than a huge 14 player boolean array is just a player group. Add all active players to it at the start, remove them from the group if your check notices they left.
Have the trigger only check players that are still in the player group.