Scripting/Squirrel/Functions/Players/Armour

From VC-MP Wiki

Jump to: navigation, search

This instance variable returns or sets player's armour.

Syntax

int player.Armour

player.Armour = newArmour


Example 1. Returning

This command gives player's armour when someone types '/c armour playername'.

function onPlayerCommand( player, cmd, text )
{
     if ( cmd == "armour" )
     {
          local plr = FindPlayer( text );
          
          if ( !plr ) MessagePlayer( "Error: Player '" + text + "' is not online.", player );
          else MessagePlayer( plr.Name + "'s armour: " + plr.Armour, player );
     }
}

Notes

The functions MessagePlayer, FindPlayer, player.Name and call onPlayerCommand were used in in this example. More info about them in corresponding pages.


Example 2. Setting

This command gives player full armour when they type '/c armme'.

function onPlayerCommand( player, cmd, text )
{
     if ( cmd == "armme" )
     {
          player.Armour = 100;
          MessagePlayer( "Your now have full body armour.", player );
     }
}

Notes

The function MessagePlayer and call onPlayerCommand were used in in this example. More info about them in corresponding pages.

Related Functions

Personal tools
squirrel scripting