Squirrel/Server/Functions/Blips/Pos
From Liberty Unleashed Wiki
(Difference between revisions)
(→Example 2. Setting a new value) |
|||
(One intermediate revision by one user not shown) | |||
Line 12: | Line 12: | ||
== Example 1. Returning the value == | == Example 1. Returning the value == | ||
+ | |||
+ | This example command prints the position of blip ID 0 on screen when someone types '/blippos'. | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
function onPlayerCommand( pPlayer, szCommand, szText ) | function onPlayerCommand( pPlayer, szCommand, szText ) | ||
{ | { | ||
− | + | if ( szCommand == "blippos" ) | |
− | + | { | |
− | + | local pBlip = FindBlip( 0 ); | |
− | + | local vPos = pBlip.Pos; | |
− | + | ||
+ | if ( pBlip ) MessagePlayer( "Blip ID 0 is at pos - " + vPos.x + ", " + vPos.y, pPlayer ); | ||
+ | } | ||
+ | |||
+ | return 1; | ||
} | } | ||
</code> | </code> | ||
Line 26: | Line 32: | ||
=== Notes === | === Notes === | ||
− | The | + | The functions [[Squirrel/Server/Functions/Blips/FindBlip|FindBlip]], [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and event [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in this example. More info about them in the corresponding pages. |
== Example 2. Setting a new value == | == Example 2. Setting a new value == | ||
+ | |||
+ | This example command will move blip ID 0 to player's position when they type '/setblippos'. | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
function onPlayerCommand( pPlayer, szCommand, szText ) | function onPlayerCommand( pPlayer, szCommand, szText ) | ||
{ | { | ||
− | + | if ( szCommand == "setblippos" ) | |
− | + | { | |
− | + | local pBlip = FindBlip( 0 ); | |
− | + | if ( pBlip ) pBlip.Pos = pPlayer.Pos; | |
− | + | } | |
+ | |||
+ | return 1; | ||
} | } | ||
</code> | </code> | ||
Line 43: | Line 53: | ||
=== Notes === | === Notes === | ||
− | The event [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] | + | The functions [[Squirrel/Server/Functions/Blips/FindBlip|FindBlip]], [[Squirrel/Server/Functions/Players/Pos|Player.Pos]] and event [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in this example. More info about them in the corresponding pages. |
== Related Functions == | == Related Functions == | ||
{{Squirrel/Server/Functions/Blips}} | {{Squirrel/Server/Functions/Blips}} |
Latest revision as of 23:18, 28 September 2010
This Blip class member returns or sets the position of the blip on the radar.
[edit] Syntax
You can either return or set a new value using this member:
Vector Blip.Pos
Blip.Pos = Vector newPos
[edit] Arguments
- newPos - A vector representing the new position of the blip.
[edit] Example 1. Returning the value
This example command prints the position of blip ID 0 on screen when someone types '/blippos'.
function onPlayerCommand( pPlayer, szCommand, szText ) { if ( szCommand == "blippos" ) { local pBlip = FindBlip( 0 ); local vPos = pBlip.Pos; if ( pBlip ) MessagePlayer( "Blip ID 0 is at pos - " + vPos.x + ", " + vPos.y, pPlayer ); } return 1; }
[edit] Notes
The functions FindBlip, MessagePlayer and event onPlayerCommand were used in this example. More info about them in the corresponding pages.
[edit] Example 2. Setting a new value
This example command will move blip ID 0 to player's position when they type '/setblippos'.
function onPlayerCommand( pPlayer, szCommand, szText ) { if ( szCommand == "setblippos" ) { local pBlip = FindBlip( 0 ); if ( pBlip ) pBlip.Pos = pPlayer.Pos; } return 1; }
[edit] Notes
The functions FindBlip, Player.Pos and event onPlayerCommand were used in this example. More info about them in the corresponding pages.