SA-MP Forums Archive
Possible?? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Possible?? (/showthread.php?tid=245939)



Possible?? - aircombat - 02.04.2011

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


Re: Possible?? - armyoftwo - 02.04.2011

Yes.

- Use GetObjectPos to get object pos.
- Calculate the distance


Re: Possible?? - coole210 - 02.04.2011

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


AW: Possible?? - Nero_3D - 02.04.2011

use GetObjectPos and IsPlayerInRangeOfPoint


Re: Possible?? - aircombat - 02.04.2011

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


AW: Re: Possible?? - Nero_3D - 02.04.2011

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


Re: Possible?? - ~Yoshi - 02.04.2011

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!");



Re: Possible?? - aircombat - 02.04.2011

Thanks Guys