Squirrel/Server/Functions/Pickups/FindPickup
From Liberty Unleashed Wiki
(Difference between revisions)
(New page: __NOTOC__ This function finds a pickup from an ID and returns the pointer. If no pickup is found, ''null'' will be returned. == Syntax == <code>Pickup FindPickup( int id )</code> == Arg...) |
(→Example) |
||
Line 10: | Line 10: | ||
* '''id''' - The ID of the pickup to be found | * '''id''' - The ID of the pickup to be found | ||
− | |||
− | |||
− | |||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | + | function onPlayerCommand( player, cmd, text ) | |
+ | { | ||
+ | if ( cmd == "findpickup" ) | ||
+ | { | ||
+ | local pup; | ||
+ | if ( text ) pup = FindPickup( text.tointeger() ); | ||
+ | |||
+ | if ( pup ) MessagePlayer( "Succesfully found pickup id: " + text + "!", player ); | ||
+ | else MessagePlayer( "Unable to find an pickup with id: " + text + "!", player ); | ||
+ | } | ||
+ | } | ||
</code> | </code> | ||
+ | This command will try to find the specified pickup id. | ||
=== 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/Pickups}} | {{Squirrel/Server/Functions/Pickups}} |
Revision as of 03:11, 8 March 2010
This function finds a pickup from an ID and returns the pointer. If no pickup is found, null will be returned.
Syntax
Pickup FindPickup( int id )
Arguments
- id - The ID of the pickup to be found
function onPlayerCommand( player, cmd, text ) { if ( cmd == "findpickup" ) { local pup; if ( text ) pup = FindPickup( text.tointeger() ); if ( pup ) MessagePlayer( "Succesfully found pickup id: " + text + "!", player ); else MessagePlayer( "Unable to find an pickup with id: " + text + "!", player ); } }
This command will try to find the specified pickup id.
Notes
The call onPlayerCommand was used in in this example. More info about this in the corresponding page.