Possible??
#1

Is it possible to create a function like : "IsPlayerAtObject(playerid,objectid)"
Reply
#2

Yes.

- Use GetObjectPos to get object pos.
- Calculate the distance
Reply
#3

I believe there's a function that can check if you are close to an x,y,z co-ordinate.

IsPlayerToPoint or IsPlayerInArea.. not sure
Reply
#4

use GetObjectPos and IsPlayerInRangeOfPoint
Reply
#5

armyof2 and nero ty guys , coole i know that but i meant to check if the player is near an object
Reply
#6

Quote:
Originally Posted by aircombat
Посмотреть сообщение
armyof2 and nero ty guys , coole i know that but i meant to check if the player is
near an object
Example
pawn Код:
new
    Float: oX,
    Float: oY,
    Float: oZ;
GetObjectPos(objectid, oX, oY, oZ);
if(IsPlayerInRangeOfPoint(playerid, 5.0, oX, oY, oZ))
{
    //Player is in 5.0 range of the object
}
The only problem is the size of the object, so with a big object you will never get 5 gta-sa metre close to the center
Reply
#7

As a stock:
pawn Код:
stock IsPlayerNearObject(playerid, objectid)
{
    new Float:X, Float:Y, Float:Z;
    GetObjectPos(objectid, X, Y, Z);
    if(IsPlayerInRangeOfPoint(playerid, 10.0, X, Y, Z)) return 1;
    return 0;
}
//
if(IsPlayerNearObject(playerid, 61)) print("Player Is Near Object!");
Reply
#8

Thanks Guys
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)