Squirrel/Server/Functions/SpawnClass/Angle
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 == "setangle" ) | ||
+ | { | ||
+ | if ( text ) p_SpawnClass.Angle = text.tofloat(); | ||
+ | } | ||
+ | } | ||
</code> | </code> | ||
+ | |||
+ | This example will set the spawning angle of the spawn class that we found earlier in [[Squirrel/Server/Functions/SpawnClass/FindSpawnClass|FindSpawnClass]] to the angle specified in the text parameter. | ||
=== 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:23, 8 March 2010
This SpawnClass class member returns or sets the spawn rotation for the given spawn class.
Syntax
You can either return or set a new value using this member:
float SpawnClass.Angle
SpawnClass.Angle = float angle
Arguments
- angle - This is the new spawn rotation for the class
Example 1. Returning
function onPlayerCommand( player, cmd, text ) { if ( cmd == "getangle" ) { local ang = p_SpawnClass.Angle( ); MessagePlayer( "The spawning angle of this class is: " + ang, player ); } }
This example will return the spawning angle of the spawn class that we found earlier in FindSpawnClass.
Example 2. Setting
function onPlayerCommand( player, cmd, text ) { if ( cmd == "setangle" ) { if ( text ) p_SpawnClass.Angle = text.tofloat(); } }
This example will set the spawning angle of the spawn class that we found earlier in FindSpawnClass to the angle specified in the text parameter.
Notes
The call onPlayerCommand was used in in this example. More info about this in the corresponding page.