Squirrel/Client/Functions/Players/Health

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Example)
 
Line 11: Line 11:
  
 
<code lang="squirrel">
 
<code lang="squirrel">
function onPlayerCommand( player, cmd, text )
+
pPlayer <- FindLocalPlayer();
 +
 
 +
function onClientCommand( cmd, text )
 
{
 
{
 
if ( cmd == "health" )
 
if ( cmd == "health" )
 
{
 
{
player.Health = 100;
+
pPlayer.Health = 100;
         MessagePlayer( "[#00ff00]*System* [#ff0000]Your health is " + player.Health + ".", player);
+
         Message( "[#00ff00]*System* [#ff0000]Your health is " + pPlayer.Health + ".");
 
}
 
}
 
}
 
}
Line 25: Line 27:
 
=== Notes ===
 
=== Notes ===
  
The call [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] and [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] were used in in this example. More info about them in the corresponding page.
+
The call [[Squirrel/Client/Events/Player/onClientCommand|onClientCommand]] and [[Squirrel/Client/Functions/Messages/Message|Message]] were used in in this example. More info about them in the corresponding page.

Latest revision as of 11:07, 4 March 2015

Contents

[edit] Syntax

  1. float player.Health
  1. player.Health = float value

[edit] Arguments

  • value - What you can set the health value to.

[edit] Example

  1.  
  2. pPlayer <- FindLocalPlayer();
  3.  
  4. function onClientCommand( cmd, text )
  5. {
  6. if ( cmd == "health" )
  7. {
  8. pPlayer.Health = 100;
  9. Message( "[#00ff00]*System* [#ff0000]Your health is " + pPlayer.Health + ".");
  10. }
  11. }
  12.  

This will heal the player when He use /health.

[edit] Notes

The call onClientCommand and Message were used in in this example. More info about them in the corresponding page.

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox