Squirrel/Server/Functions/SpawnClass/Skin
From Liberty Unleashed Wiki
(Difference between revisions)
(→Example 1. Returning) |
(→Example 2. Setting) |
||
Line 28: | Line 28: | ||
== Example 2. Setting == | == Example 2. Setting == | ||
− | |||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | + | function onPlayerCommand( player, cmd, text ) | |
+ | { | ||
+ | if ( cmd == "setskin" ) | ||
+ | { | ||
+ | local skin; | ||
+ | if ( text ) skin = text.tointeger(); | ||
+ | if ( skin ) p_SpawnClass.Skin = skin; | ||
+ | } | ||
+ | } | ||
</code> | </code> | ||
+ | |||
+ | This example will set the skin of the spawn class, that we found earlier in [[Squirrel/Server/Functions/SpawnClass/FindSpawnClass|FindSpawnClass]]. | ||
=== Notes === | === Notes === | ||
− | + | The call [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] was used in in this example. More info about this in the corresponding page. | |
== Related Functions == | == Related Functions == | ||
{{Squirrel/Server/Functions/SpawnClass}} | {{Squirrel/Server/Functions/SpawnClass}} |
Revision as of 17:47, 8 March 2010
This SpawnClass class member returns or sets the skin selected for the given spawn class.
Syntax
You can either return or set a new value using this member:
int SpawnClass.Skin
SpawnClass.Skin = int skin
Arguments
- skin - The new skin for the spawn class
Example 1. Returning
function onPlayerCommand( player, cmd, text ) { if ( cmd == "getskin" ) { local skin = p_SpawnClass.Skin; MessagePlayer( "The current spawn class skin is: " + skin, player ); } }
This example will return the skin of the spawn class, that we found earlier in FindSpawnClass.
Example 2. Setting
function onPlayerCommand( player, cmd, text ) { if ( cmd == "setskin" ) { local skin; if ( text ) skin = text.tointeger(); if ( skin ) p_SpawnClass.Skin = skin; } }
This example will set the skin of the spawn class, that we found earlier in FindSpawnClass.
Notes
The call onPlayerCommand was used in in this example. More info about this in the corresponding page.