Squirrel/Server/Functions/Checkpoints/Pos
From Liberty Unleashed Wiki
(Difference between revisions)
m |
|||
Line 28: | Line 28: | ||
=== Notes === | === Notes === | ||
− | The | + | The event [[Squirrel/Server/Events/Marker/onPlayerEnterCheckpoint|onPlayerEnterCheckpoint]] was used in this example. More info about it in the corresponding page. |
== Example 2. Setting == | == Example 2. Setting == |
Latest revision as of 20:09, 24 September 2010
This Checkpoint class member returns or sets the position of the given checkpoint.
[edit] Syntax
You can either return or set a new value using this member:
Vector Checkpoint.Pos
Checkpoint.Pos = Vector vPos
[edit] Arguments
- vPos - This is the position of the checkpoint as a vector.
[edit] Example 1. Returning
This example will message the player with the current position of the checkpoint.
function onPlayerEnterCheckpoint( player, checkpoint ) { local pos = checkpoint.Pos; MessagePlayer( format( "The current position of this checkpoint is: %.2f, %.2f, %.2f", pos.x, pos.y, pos.z ), player ); return 1; }
[edit] Notes
The event onPlayerEnterCheckpoint was used in this example. More info about it in the corresponding page.
[edit] Example 2. Setting
This example will move the checkpoint 2 x coordinates away from the player when they enter the checkpoint.
function onPlayerEnterCheckpoint( player, checkpoint ) { local pos = player.Pos; checkpoint.Pos = Vector( pos.x + 2, pos.y, pos.z ); return 1; }
[edit] Notes
The function MessagePlayer and event onPlayerEnterCheckpoint were used in this example. More info about them in the corresponding pages.