Squirrel/Server/Functions/Players/Score

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with '{{Squirrel/Title|Player.Score}} This function sets/returns the players score. == Syntax == <code>int player.Score</code> <code>player.Score = int value</code> == Arguments == …')
 
 
Line 13: Line 13:
 
== Example 1. Returning ==
 
== Example 1. Returning ==
  
{{Squirrel/NeedsExample}}
+
This will tell the player what score they have when they type '/score'
Explanation for the example
+
  
 
<code lang="squirrel">
 
<code lang="squirrel">
-- todo
+
function onPlayerCommand( pPlayer, szCommand, szText )
 +
{
 +
if ( szCommand == "score" )
 +
{
 +
MessagePlayer( "Current score - " + pPlayer.Score, pPlayer );
 +
}
 +
 +
return 1;
 +
}
 
</code>
 
</code>
  
 
== Example 2. Setting ==
 
== Example 2. Setting ==
  
{{Squirrel/NeedsExample}}
+
This will set the player's score to '2' when they '/score2'.
Explanation for the example
+
  
 
<code lang="squirrel">
 
<code lang="squirrel">
-- todo
+
function onPlayerCommand( pPlayer, szCommand, szText )
 +
{
 +
if ( szCommand == "score" )
 +
{
 +
pPlayer.Score = 2;
 +
}
 +
 +
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:06, 25 October 2010

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

This function sets/returns the players score.

[edit] Syntax

  1. int player.Score
  1. player.Score = int value

[edit] Arguments

  • value - The score to set

[edit] Example 1. Returning

This will tell the player what score they have when they type '/score'

  1.  
  2. function onPlayerCommand( pPlayer, szCommand, szText )
  3. {
  4. if ( szCommand == "score" )
  5. {
  6. MessagePlayer( "Current score - " + pPlayer.Score, pPlayer );
  7. }
  8. return 1;
  9. }
  10.  

[edit] Example 2. Setting

This will set the player's score to '2' when they '/score2'.

  1.  
  2. function onPlayerCommand( pPlayer, szCommand, szText )
  3. {
  4. if ( szCommand == "score" )
  5. {
  6. pPlayer.Score = 2;
  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