Squirrel/Server/Functions/Checkpoints/Type
From Liberty Unleashed Wiki
(Difference between revisions)
(→Example 2. Setting) |
|||
Line 1: | Line 1: | ||
− | + | {{Squirrel/Title|Checkpoint.Type}} | |
This ''Checkpoint'' class member returns or sets the type of the checkpoint. [[Squirrel/Server/Constants#Marker_Types|Checkpoint type]] means how it can be hit (on foot, using a vehicle...). Defaults to MARKER_TYPE_BOTH. | This ''Checkpoint'' class member returns or sets the type of the checkpoint. [[Squirrel/Server/Constants#Marker_Types|Checkpoint type]] means how it can be hit (on foot, using a vehicle...). Defaults to MARKER_TYPE_BOTH. | ||
== Syntax == | == Syntax == | ||
+ | |||
You can either return or set a new value using this member: | You can either return or set a new value using this member: | ||
<code>int Checkpoint.Type</code> | <code>int Checkpoint.Type</code> | ||
Line 9: | Line 10: | ||
== Arguments == | == Arguments == | ||
− | * '''type''' - This is | + | * '''type''' - This is the new [[Squirrel/Server/Constants#Marker_Types|type]]. |
== Example 1. Returning == | == Example 1. Returning == | ||
+ | |||
+ | This example will message the player with the type ID for that checkpoint. | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | function | + | function onPlayerEnterCheckpoint( player, checkpoint ) |
{ | { | ||
− | + | MessagePlayer( "The current checkpoint type for this checkpoint is: " + checkpoint.Type, player ); | |
+ | |||
+ | return 1; | ||
} | } | ||
</code> | </code> | ||
Line 22: | Line 27: | ||
=== Notes === | === Notes === | ||
− | + | The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and event [[Squirrel/Server/Events/Marker/onPlayerEnterCheckpoint|onPlayerEnterCheckpoint]] were used in this example. More info about them in the corresponding pages. | |
== Example 2. Setting == | == Example 2. Setting == | ||
+ | |||
+ | This example will change the type of checkpoint to MARKER_TYPE_VEHICLE (only vehicles can enter it) when a player enters it. | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | function | + | function onPlayerEnterCheckpoint( player, checkpoint ) |
{ | { | ||
− | + | checkpoint.Type = MARKER_TYPE_VEHICLE; | |
+ | |||
+ | return 1; | ||
} | } | ||
</code> | </code> | ||
Line 35: | Line 44: | ||
=== Notes === | === Notes === | ||
− | + | The event [[Squirrel/Server/Events/Marker/onPlayerEnterCheckpoint|onPlayerEnterCheckpoint]] was used in this example. More info about it in the corresponding page. | |
== Related Functions == | == Related Functions == | ||
{{Squirrel/Server/Functions/Checkpoints}} | {{Squirrel/Server/Functions/Checkpoints}} |
Latest revision as of 20:16, 24 September 2010
This Checkpoint class member returns or sets the type of the checkpoint. Checkpoint type means how it can be hit (on foot, using a vehicle...). Defaults to MARKER_TYPE_BOTH.
[edit] Syntax
You can either return or set a new value using this member:
int Checkpoint.Type
Checkpoint.Type = int type
[edit] Arguments
- type - This is the new type.
[edit] Example 1. Returning
This example will message the player with the type ID for that checkpoint.
function onPlayerEnterCheckpoint( player, checkpoint ) { MessagePlayer( "The current checkpoint type for this checkpoint is: " + checkpoint.Type, player ); return 1; }
[edit] Notes
The function MessagePlayer and event onPlayerEnterCheckpoint were used in this example. More info about them in the corresponding pages.
[edit] Example 2. Setting
This example will change the type of checkpoint to MARKER_TYPE_VEHICLE (only vehicles can enter it) when a player enters it.
function onPlayerEnterCheckpoint( player, checkpoint ) { checkpoint.Type = MARKER_TYPE_VEHICLE; return 1; }
[edit] Notes
The event onPlayerEnterCheckpoint was used in this example. More info about it in the corresponding page.