Scripting/Squirrel/Functions/FindObject: Difference between revisions

From Vice City Multiplayer
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing
 
No edit summary
 
(One intermediate revision by one other user not shown)
Line 12: Line 12:
function onPlayerCommand( player, cmd, text )
function onPlayerCommand( player, cmd, text )
{
{
if(cmd == "findpickup")
if(cmd == "findobject")
{
{
local pickup = FindPickup(text.tointeger());
local obj = FindObject(text.tointeger());
if (pickup)
if (obj)
{
{
pickup.Pos = player.Pos;
obj.Pos = player.Pos;
MessagePlayer("[#00FF00]Pickup has been found and has been teleported to you!", player);
MessagePlayer("[#00FF00]Object has been found and has been teleported to you!", player);
} else {
} else {
MessagePlayer("[#FF0000]Pickup has not been found :(", player);
MessagePlayer("[#FF0000]Object has not been found :(", player);
}
}
}
}
Line 27: Line 27:
=== Notes ===
=== Notes ===
Call [[onPlayerCommand]] was used in this example. More info about it in the page.
Call [[onPlayerCommand]] was used in this example. More info about it in the page.
== Related Functions ==
{{Scripting/Squirrel/Functions/Object_Functions}}
[[Category:Scripting/Squirrel/Functions/Object_Functions]]

Latest revision as of 18:32, 30 January 2017

Syntax

FindObject(ID)

Arguments

  • int ID - The ID of the object to find

Example

function onPlayerCommand( player, cmd, text )
{
	if(cmd == "findobject")
	{
		local obj = FindObject(text.tointeger());
		if (obj)
		{
			obj.Pos = player.Pos;
			MessagePlayer("[#00FF00]Object has been found and has been teleported to you!", player);
		} else {
			MessagePlayer("[#FF0000]Object has not been found :(", player);
		}
	}
}

Notes

Call onPlayerCommand was used in this example. More info about it in the page.

Related Functions