Squirrel/Client/Events/Player/onClientHealthChange

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with '{{Squirrel/Title|onClientHealthChange}} This is called when the clients Health changes. == Syntax == <code lang="squirrel">function onClientHealthChange( int iOldHealth, int iN…')
 
 
Line 1: Line 1:
 
{{Squirrel/Title|onClientHealthChange}}
 
{{Squirrel/Title|onClientHealthChange}}
This is called when the clients Health changes.
+
This is called when the clients health changes.
  
 
== Syntax ==
 
== Syntax ==
  
<code lang="squirrel">function onClientHealthChange( int iOldHealth, int iNewHealth )</code>
+
<code>function onClientHealthChange( int oldhp, int newhp )</code>
  
 
=== Arguments ===
 
=== Arguments ===
  
* '''iOldHealth''' - The player's Old Health Value
+
* '''oldhp''' - The player's old health
* '''iNewHealth''' - The player's New Health Value
+
* '''newhp''' - The player's new health
  
 
=== Returns ===
 
=== Returns ===
  
* '''1''' - No Effect
+
This event does not handle return values.
* '''0''' - No Effect
+
  
 
== Example ==
 
== Example ==
  
This example will Message the player when their cash changes
+
This example will message the player when their health changes
  
Create a Global for a player pointer.
 
<code lang="squirrel">pPlayer <- FindLocalPlayer();</code>
 
 
<code lang="squirrel">
 
<code lang="squirrel">
function onClientHealthChange( iOldHealth, iNewHealth ) {
+
function onClientHealthChange( oldhp, newhp )
MessagePlayer("You have: " + pPlayer.Health + "Health remaining", pPlayer );
+
{
return 1;
+
    Message( "You have: " + newhp + " health remaining" );
 +
   
 +
    return 1;
 
}
 
}
 
</code>
 
</code>
Line 31: Line 30:
 
=== Notes ===
 
=== Notes ===
  
 +
The function [[Squirrel/Client/Functions/Messages/Message|Message]] was used in this example. More info about it can be found in the corresponding page.
  
The functions [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and [[Squirrel/Server/Functions/Players/Health|Player.Health]] were used in this example. More info about them can be found in the corresponding pages.
 
 
== Related Events ==
 
== Related Events ==
  
 
{{Squirrel/Client/Events/Player}}
 
{{Squirrel/Client/Events/Player}}

Latest revision as of 19:46, 14 April 2011

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

This is called when the clients health changes.

[edit] Syntax

  1. function onClientHealthChange( int oldhp, int newhp )

[edit] Arguments

  • oldhp - The player's old health
  • newhp - The player's new health

[edit] Returns

This event does not handle return values.

[edit] Example

This example will message the player when their health changes

  1.  
  2. function onClientHealthChange( oldhp, newhp )
  3. {
  4. Message( "You have: " + newhp + " health remaining" );
  5. return 1;
  6. }
  7.  

[edit] Notes

The function Message was used in this example. More info about it can be found in the corresponding page.

[edit] Related Events

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox