Versions Compared
compared with
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Excerpt |
---|
A global event triggered when a player is defeated. |
Syntax
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
function eventPlayerDefeated(playerID) { // code to run when player dies } |
Parameters
Parameter | Type | Mandatory | Notes | API Version |
---|---|---|---|---|
playerID | Number | The ID of the player that has just been defeated. | 1.0 |
Return value
The return value is not currently processed.
Notes
The event is not triggered for players identified as spectators or vacant slots.
After the player is defeated, the event may lag behind a little - it's only triggered the next time a script tries to determine if the player is alive (and even then only when the cache invalidates). If you want to force a periodical check, set a timer as follows:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
function checkDefeatcheckPlayerStates() { void Players.living; alive; // will cause applicable events to be triggered } setTimer("checkDefeatcheckPlayerStates", 1000); // check every second |
Example
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
function eventPlayerDefeated(playerID) { console(""+Players[playerID]+" has been defeated"); // maybe now would be a good time to claim their oil? ;) } |
Div | ||||||
---|---|---|---|---|---|---|
| ||||||
Availability
Requires:
|
Div | ||||
---|---|---|---|---|
| ||||
ContentsJump to:
|
Div | ||
---|---|---|
| ||
See alsoRelated articles:
|
Div | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
Players APITopics:
|