12.03.2015, 08:00
Use GetObjectPos to get the position of an object ID.
To check if a player is near the object, you could run a repeating 1-sec timer in OnGameModeInit that would look something like this:
To check if a player is near the object, you could run a repeating 1-sec timer in OnGameModeInit that would look something like this:
pawn Код:
forward MyTimer();
public MyTimer()
{
new Float:x, Float:y, Float:z; // Declares 3 floats, we're gonna store the XYZ coordinates of the object in these
GetObjectPos(objectid, x, y, z); // Stores the object id's coordinates in the XYZ floats, change "objectid" to what you want
foreach(new i : Player) // Loops through all players, and defines them as "i"
{
if(IsPlayerInRangeOfPoint(i, 5, x, y, z)) // If "i" is in range of those coordinates
// The range is here "5", change to what you want the max distance to be
{
// Do whatever you want here when the player is close enough
}
}
}