Interaction with objects
#4

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:
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
        }
    }
}
Reply


Messages In This Thread
Interaction with objects - by Laurentziu - 12.03.2015, 07:33
Re: Interaction with objects - by oliverrud - 12.03.2015, 07:36
Re: Interaction with objects - by Laurentziu - 12.03.2015, 07:40
Re: Interaction with objects - by CalvinC - 12.03.2015, 08:00
Re: Interaction with objects - by Laurentziu - 12.03.2015, 08:05
Re: Interaction with objects - by CalvinC - 12.03.2015, 08:09
Re: Interaction with objects - by Laurentziu - 12.03.2015, 08:13
Re: Interaction with objects - by Ph0eniX - 12.03.2015, 08:19
Re: Interaction with objects - by CalvinC - 12.03.2015, 08:27
Re: Interaction with objects - by Laurentziu - 12.03.2015, 08:44

Forum Jump:


Users browsing this thread: 1 Guest(s)