Squirrel/Server/Events/Player/onPlayerDeath

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(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:
__NOTOC__
+
{{Squirrel/Title|onPlayerDeath}}
This is called whenever a player dies, for any reason.
+
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>
  
== Parameters ==
+
=== Arguments ===
  
 
* '''player''' - The player pointer
 
* '''player''' - The player pointer
* '''reason''' - What caused the player to die
+
* '''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 when a player is killed
+
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( "StatServ:" + player.Name + " died" );
+
     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|player.Name]] was used in in this example. More info about them can be found in the corresponding pages.
+
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

Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events

This is called when a player dies, for any reason.

Syntax

  1. 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.

  1.  
  2. function onPlayerDeath( player, reason )
  3. {
  4. if ( reason == WEP_DROWNED ) Message( "* " + player.Name + " is sleeping with the fishes." );
  5. return 1;
  6. }
  7.  

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

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox