Squirrel/Server/Functions/Players/WeaponAmmo

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with '{{Squirrel/Title|Player.WeaponAmmo}} This function returns the ammo of the weapon the player is currently holding. == Syntax == <code>int player.WeaponAmmo</code> == Arguments…')
 
 
Line 12: Line 12:
 
== Example ==
 
== Example ==
  
{{Squirrel/NeedsExample}}
+
This will tell the player how much ammo they currently have remaining when they type '/ammo'.
Explanation for the example
+
  
 
<code lang="squirrel">
 
<code lang="squirrel">
-- todo
+
function onPlayerCommand( pPlayer, szCommand, szText )
 +
{
 +
if ( szCommand == "ammo" )
 +
{
 +
MessagePlayer( "Your current weapon ammo is - " + pPlayer.WeaponAmmo, pPlayer );
 +
}
 +
 +
return 1;
 +
}
 
</code>
 
</code>
  
 
=== Notes ===
 
=== Notes ===
  
-- List of used functions and other notes here.
+
The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and event [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in this example. More info about them in the corresponding pages.
  
 
== Related Functions ==
 
== Related Functions ==
  
 
{{Squirrel/Server/Functions/Players}}
 
{{Squirrel/Server/Functions/Players}}

Latest revision as of 16:34, 25 October 2010

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

This function returns the ammo of the weapon the player is currently holding.

[edit] Syntax

  1. int player.WeaponAmmo

[edit] Arguments

  • none

[edit] Example

This will tell the player how much ammo they currently have remaining when they type '/ammo'.

  1.  
  2. function onPlayerCommand( pPlayer, szCommand, szText )
  3. {
  4. if ( szCommand == "ammo" )
  5. {
  6. MessagePlayer( "Your current weapon ammo is - " + pPlayer.WeaponAmmo, pPlayer );
  7. }
  8. return 1;
  9. }
  10.  

[edit] Notes

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

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox