Squirrel/Server/Functions/Blips/FindBlip

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Example 2. Player specific)
 
Line 10: Line 10:
 
* '''id''' - The ID of the blip to be found
 
* '''id''' - The ID of the blip to be found
 
* '''plr''' - If the blip you want to find is owned by a specific client, use this to specify the owner. If you don't use this argument the blip will be returned from the global blip pool
 
* '''plr''' - If the blip you want to find is owned by a specific client, use this to specify the owner. If you don't use this argument the blip will be returned from the global blip pool
 
  
 
== Example 1. Non-player specific ==
 
== Example 1. Non-player specific ==
 +
 +
This example command will look for a global blip id asked by the player and print a message if it exists then someone types '/find'.
 +
 
<code lang="squirrel">
 
<code lang="squirrel">
 
function onPlayerCommand( pPlayer, szCommand, szText )
 
function onPlayerCommand( pPlayer, szCommand, szText )
 
{
 
{
if ( szCommand == "find" )
+
    if ( szCommand == "find" )
{
+
    {
local pBlip;
+
          local pBlip = null;
if ( szText ) pBlip = FindBlip( szText.tointeger() );
+
          if ( szText ) pBlip = FindBlip( szText.tointeger() );
if ( pBlip ) MessagePlayer( "Found Blip ID " + szText, pPlayer );
+
          if ( pBlip ) MessagePlayer( "Found Blip ID " + szText, pPlayer );
}
+
    }
 +
   
 +
    return 1;
 
}
 
}
 
</code>
 
</code>
Line 30: Line 34:
  
 
== Example 2. Player specific ==
 
== Example 2. Player specific ==
 +
 +
This example command will look for a local blip ID asked by the player and print a message if it exists then someone types '/findlocal'.
  
 
<code lang="squirrel">
 
<code lang="squirrel">
 
function onPlayerCommand( pPlayer, szCommand, szText )
 
function onPlayerCommand( pPlayer, szCommand, szText )
 
{
 
{
if ( szCommand == "find2" )
+
    if ( szCommand == "findlocal" )
{
+
    {
local pBlip;
+
          local pBlip = null;
if ( szText ) pBlip = FindBlip( szText.tointeger(), pPlayer );
+
          if ( szText ) pBlip = FindBlip( szText.tointeger(), pPlayer );
if ( pBlip ) MessagePlayer( "Found Blip ID " + szText, pPlayer );
+
          if ( pBlip ) MessagePlayer( "Found Blip ID " + szText, pPlayer );
}
+
    }
 +
   
 +
    return 1;
 
}
 
}
 
</code>
 
</code>

Latest revision as of 00:04, 29 September 2010

Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events

This function finds a blip from an ID and returns a pointer to it. If there is no such blip, null will be returned.

[edit] Syntax

  1. Blip FindBlip( int id [, Player plr ] )

[edit] Arguments

  • id - The ID of the blip to be found
  • plr - If the blip you want to find is owned by a specific client, use this to specify the owner. If you don't use this argument the blip will be returned from the global blip pool

[edit] Example 1. Non-player specific

This example command will look for a global blip id asked by the player and print a message if it exists then someone types '/find'.

  1.  
  2. function onPlayerCommand( pPlayer, szCommand, szText )
  3. {
  4. if ( szCommand == "find" )
  5. {
  6. local pBlip = null;
  7. if ( szText ) pBlip = FindBlip( szText.tointeger() );
  8. if ( pBlip ) MessagePlayer( "Found Blip ID " + szText, pPlayer );
  9. }
  10. return 1;
  11. }
  12.  

[edit] Notes

The function MessagePlayer and event onPlayerCommand were used in in this example. More info about them in the corresponding pages.

[edit] Example 2. Player specific

This example command will look for a local blip ID asked by the player and print a message if it exists then someone types '/findlocal'.

  1.  
  2. function onPlayerCommand( pPlayer, szCommand, szText )
  3. {
  4. if ( szCommand == "findlocal" )
  5. {
  6. local pBlip = null;
  7. if ( szText ) pBlip = FindBlip( szText.tointeger(), pPlayer );
  8. if ( pBlip ) MessagePlayer( "Found Blip ID " + szText, pPlayer );
  9. }
  10. return 1;
  11. }
  12.  

[edit] Notes

The function MessagePlayer and event onPlayerCommand were used in in this example. More info about them in the corresponding pages.

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox