I need to use the function GetNearestObjectToLocation and I'm not sure how to use it, as the object it returns appears to be a one-dimensional array of one or more objects. Here is the code description:
object [] GetNearestObjectToLocation (
location lLocation,
int nObjectType = OBJECT_TYPE_ALL,
int nNumberOfObjects = 1
)
My question is how do I actually create this object? Can someone give me an example of the line of code I would use. If it wasn't an array I would do this:
object oNPC = GetNearestObjectToLocation(stEvent.lTarget, OBJECT_TYPE_CREATURE);
I only want the first creature it finds, and obviously my code is incorrect. I just don't know how to declare the array.
Using an object array (object [])
Débuté par
Miserere
, nov. 20 2009 05:45
#1
Posté 20 novembre 2009 - 05:45
#2
Posté 20 novembre 2009 - 05:58
object[] oNPCList = GetNearestObjectToLocation(stEvent.lTarget, OBJECT_TYPE_CREATURE);
if ( GetArraySize(oNPCList) > 0 )
{
object oNPC = oNPCList[0];
/* do something with oNPC here */
}
if ( GetArraySize(oNPCList) > 0 )
{
object oNPC = oNPCList[0];
/* do something with oNPC here */
}
#3
Posté 20 novembre 2009 - 08:34
Thanks, I'll give that a go.





Retour en haut






