GetRandomObjectByTag(string, float)
Get a random nearby object within the specified distance with the specified tag.
object GetRandomObjectByTag( string sTag, float fMaxDistance );
Parameters
sTag
The tag of the object you want to find.
fMaxDistance
This number is used to figure the nNth object to get.
Description
Get a random nearby object within the specified distance with the specified tag.
Remarks
Returns a valid object on success, OBJECT_INVALID on failure.
This uses GetNearestObjectByTag to find the object.
You can use the DISTANCE_* constants if you want for fMaxDistance.
Known Bugs
There are some quirks in how fMaxDistance is used to find the requested object. If fMaxDistance is set to DISTANCE_SHORT (3.0), then d2 is sent to GetNearestObjectByTag as the nNth parameter. If fMaxDistance is set to DISTANCE_MEDIUM (5.0), then d4 is sent. ALL other values of fMaxDistance result in d6 being sent.
Meaning, if you send in a distance of DISTANCE_TINY (1.0) you could actually end up with an object that is 6.0 distance away.
Requirements
#include "x0_i0_anims"
Version
???
Example
// Find the nearest object with the tag "CLN_BARAGG". #include "x0_i0_anims" void main() { // Looking for an object with the tag "CLN_BARAGG" at 50.0 meters away. object oThing = GetRandomObjectByTag("CLN_BARAGG", 50.0); if(TRUE == GetIsObjectValid(oThing)) { // Object found! Do what you want with it in here. } }
See Also
functions: | GetNearestObject | GetNearestObjectByTag | GetRandomObjectByType |
constants: | DISTANCE_* |
categories: | Get Data from Object Functions |
author: Baragg, editor: Mistress