Squirrel/Server/Events/Player/onPlayerDeath
From Liberty Unleashed Wiki
(Difference between revisions)
(New page: __NOTOC__ This is called whenever a player dies, for any reason. == Syntax == <code>function onPlayerDeath( player, reason )</code> == Parameters == * '''player''' - The player pointer...) |
|||
Line 1: | Line 1: | ||
− | + | {{Squirrel/Title|onPlayerDeath}} | |
− | This is called | + | This is called when a player dies, for any reason. |
== Syntax == | == Syntax == | ||
− | <code>function onPlayerDeath( player, reason )</code> | + | <code>function onPlayerDeath( Player player, int reason )</code> |
− | == | + | === Arguments === |
* '''player''' - The player pointer | * '''player''' - The player pointer | ||
− | * '''reason''' - | + | * '''reason''' - The weapon/reason which caused the player to die - check list [[Squirrel/Server/Constants#Weapons.2FDeath_Reasons|here]] |
== Example == | == Example == | ||
− | This will send a message to the main chat | + | This will send a message to the main chat if a player drowns. |
<code lang="squirrel"> | <code lang="squirrel"> | ||
function onPlayerDeath( player, reason ) | function onPlayerDeath( player, reason ) | ||
{ | { | ||
− | Message( " | + | if ( reason == WEP_DROWNED ) Message( "* " + player.Name + " is sleeping with the fishes." ); |
+ | |||
+ | return 1; | ||
} | } | ||
</code> | </code> | ||
Line 24: | Line 26: | ||
=== Notes === | === Notes === | ||
− | The functions [[Squirrel/Server/Functions/Players/Name| | + | The functions [[Squirrel/Server/Functions/Messages/Message|Message]] and [[Squirrel/Server/Functions/Players/Name|Player.Name]] were used in this example. More info about them can be found in the corresponding pages. |
== Related Events == | == Related Events == | ||
{{Squirrel/Server/Events/Player}} | {{Squirrel/Server/Events/Player}} |
Revision as of 19:02, 22 December 2010
This is called when a player dies, for any reason.
Syntax
function onPlayerDeath( Player player, int reason )
Arguments
- player - The player pointer
- reason - The weapon/reason which caused the player to die - check list here
Example
This will send a message to the main chat if a player drowns.
function onPlayerDeath( player, reason ) { if ( reason == WEP_DROWNED ) Message( "* " + player.Name + " is sleeping with the fishes." ); return 1; }
Notes
The functions Message and Player.Name were used in this example. More info about them can be found in the corresponding pages.
Related Events
- onPlayerAction
- onPlayerArmourChange
- onPlayerCashChange
- onPlayerChat
- onPlayerCommand
- onPlayerConnect
- onPlayerDeath
- onPlayerFall
- onPlayerHealthChange
- onPlayerIslandChange
- onPlayerJoin
- onPlayerKeyStateChange
- onPlayerKill
- onPlayerPart
- onPlayerScoreChange
- onPlayerSkinChange
- onPlayerSpawn
- onPlayerUpdate
- onPlayerTeamChange
- onPlayerUseDetonator
- onPlayerVirtualWorldChange
- onPlayerWeaponChange