Squirrel/Server/Functions/SpawnClass/Colour
From Liberty Unleashed Wiki
(Difference between revisions)
(→Example 1. Returning) |
|||
Line 1: | Line 1: | ||
+ | {{DISPLAYTITLE:SpawnClass.Colour}} | ||
__NOTOC__ | __NOTOC__ | ||
This ''SpawnClass'' class member returns or sets the ID of the pre-defined colour (check content.xml) for the given spawn class. | This ''SpawnClass'' class member returns or sets the ID of the pre-defined colour (check content.xml) for the given spawn class. | ||
Line 12: | Line 13: | ||
== Example 1. Returning == | == Example 1. Returning == | ||
+ | |||
+ | This example will return the colour of the spawn class, that we found earlier in [[Squirrel/Server/Functions/SpawnClass/FindSpawnClass|FindSpawnClass]]. | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
Line 24: | Line 27: | ||
</code> | </code> | ||
− | + | === Notes === | |
+ | |||
+ | The call [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] was used in in this example. More info about this in the corresponding page. | ||
== Example 2. Setting == | == Example 2. Setting == | ||
+ | |||
+ | This example will set the colour of the spawn class, that we found earlier in [[Squirrel/Server/Functions/SpawnClass/FindSpawnClass|FindSpawnClass]], to predefined colour 2. | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
Line 37: | Line 44: | ||
} | } | ||
</code> | </code> | ||
− | |||
− | |||
=== Notes === | === Notes === |
Latest revision as of 12:04, 12 March 2010
This SpawnClass class member returns or sets the ID of the pre-defined colour (check content.xml) for the given spawn class.
[edit] Syntax
You can either return or set a new value using this member:
int SpawnClass.Colour
SpawnClass.Colour = int colourID
[edit] Arguments
- colourID - This is the ID of the colour defined in content.xml
[edit] Example 1. Returning
This example will return the colour of the spawn class, that we found earlier in FindSpawnClass.
function onPlayerCommand( player, cmd, text ) { if ( cmd == "colour" ) { local col = p_SpawnClass.Colour; MessagePlayer( "The spawn class colour is currently: " + col, player ); } }
[edit] Notes
The call onPlayerCommand was used in in this example. More info about this in the corresponding page.
[edit] Example 2. Setting
This example will set the colour of the spawn class, that we found earlier in FindSpawnClass, to predefined colour 2.
function onPlayerCommand( player, cmd, text ) { if ( cmd == "setcolour" ) { p_SpawnClass.Colour = 2; } }
[edit] Notes
The call onPlayerCommand was used in in this example. More info about this in the corresponding page.