Near a object - 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)
+--- Thread: Near a object (
/showthread.php?tid=311713)
Near a object -
Oh - 17.01.2012
So I'm attempting to make a /pickup command. I have placed objects in a place.
I have tried this, and it crashes the server.
pawn Код:
for(new i; i < 31; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, item[i]))
{
I have tried this
pawn Код:
for(new i; i < 31; i++)
{
if(IsPlayerNearObject(playerid, item[i], 2))
It says you're not near anything to pickup.
Anyone help me out with this?
Re: Near a object -
Vince - 17.01.2012
It crashes the server ... How the hell did that compile in the first place? IsPlayerInRangeOfPoint expects 5 parameters.
https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint
Re: Near a object -
Oh - 17.01.2012
It gave me a warning about that.
Re: Near a object -
Babul - 18.01.2012
may we have a look at your item[] array? is it 2 dimensional and contains the x,y,z coordinate?
or is it the placeholder for the returned object ids? like
pawn Код:
item[0]=CreateObject(blabla);
if so, then you need a similar sized array, holding the coordinates:
pawn Код:
new Float:itemcoords[][3]={
{0.0000,0.0000,10.0000},
{2000.0000,2000.0000,10.0000}
}
...and
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 2.0, itemcoords[i][0], itemcoords[i][1], item[i][2])
Re: Near a object -
Oh - 18.01.2012
I have no idea what you mean.
Re: Near a object -
Tannz0rz - 18.01.2012
Quote:
Originally Posted by Oh
I have no idea what you mean.
|
The object must have a position. Assuming that
is the object's ID, first get the position of the object with GetObjectPos
Код:
new
Float:x, Float:y, Float:z;
GetObjectPos(item[i], x, y, z);
and thereafter check with IsPlayerInRangeOfPoint
Код:
if(IsPlayerInRangeOfPoint(playerid, 2.0, x, y, z))
{
}