Squirrel/Server/Events/Player/onPlayerKill

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
 +
{{Squirrel/Title|onPlayerKill}}
 +
This event is called when a player kills another player.
 +
 
== Syntax ==
 
== Syntax ==
  
<code>function onPlayerKill( pPlayer, pKiller, iWeapon, iBodyPart )</code>
+
<code>function onPlayerKill( Player pPlayer, Player pKiller, int iWeapon, int iBodyPart )</code>
  
== Parameters ==
+
=== Arguments ===
  
* '''pPlayer''' - The killed player pointer
+
* '''pPlayer''' - The pointer of the player who killed
* '''pKiller''' - The killer player pointer
+
* '''pKiller''' - The pointer of the player who was killed
* '''iWeapon''' - The ID of the weapon used to kill the player
+
* '''iWeapon''' - The ID of the weapon used to kill the player - check list [[Squirrel/Server/Constants#Weapons.2FDeath_Reasons|here]]
* '''iBodyPart''' - The part of the body which was hit
+
* '''iBodyPart''' - The part of the body which was hit - check list [[Squirrel/Server/Constants#Body_Parts|here]]
 +
 
 +
=== Returns ===
 +
 
 +
This event does not handle return values.
  
 
== Example ==
 
== Example ==
  
This will message the main chat when a player kills another player with an onfoot weapon.
+
This will message the chatbox when a player kills another player.
  
 
<code lang="squirrel">
 
<code lang="squirrel">
 
function onPlayerKill( killer, player, reason, bodypart )
 
function onPlayerKill( killer, player, reason, bodypart )
 
{
 
{
     Message( "StatServ: " + killer.Name + " killed " + player.Name " (" +GetWeaponName( reason )+ ")" );
+
     Message( "* " + killer.Name + " killed " + player.Name " (" + GetWeaponName( reason ) + ")" );
 
}
 
}
 
</code>
 
</code>
Line 23: Line 30:
 
=== Notes ===
 
=== Notes ===
  
The functions [[Squirrel/Server/Functions/Messages/Message|Message]], [[Squirrel/Server/Functions/Players/Name|player.Name]] and [[Squirrel/Server/Functions/Misc/GetWeaponName|GetWeaponName]] were used in in this example. More info about them can be found in the corresponding pages.
+
The functions [[Squirrel/Server/Functions/Messages/Message|Message]], [[Squirrel/Server/Functions/Players/Name|Player.Name]] and [[Squirrel/Server/Functions/Weapons/GetWeaponName|GetWeaponName]] were used in this example. More info about them can be found in the corresponding pages.
 
+
  
 
== Related Functions ==
 
== Related Functions ==
  
 
{{Squirrel/Server/Events/Player}}
 
{{Squirrel/Server/Events/Player}}

Revision as of 19:35, 22 December 2010

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

This event is called when a player kills another player.

Syntax

  1. function onPlayerKill( Player pPlayer, Player pKiller, int iWeapon, int iBodyPart )

Arguments

  • pPlayer - The pointer of the player who killed
  • pKiller - The pointer of the player who was killed
  • iWeapon - The ID of the weapon used to kill the player - check list here
  • iBodyPart - The part of the body which was hit - check list here

Returns

This event does not handle return values.

Example

This will message the chatbox when a player kills another player.

  1.  
  2. function onPlayerKill( killer, player, reason, bodypart )
  3. {
  4. Message( "* " + killer.Name + " killed " + player.Name " (" + GetWeaponName( reason ) + ")" );
  5. }
  6.  

Notes

The functions Message, Player.Name and GetWeaponName were used in this example. More info about them can be found in the corresponding pages.

Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox