Near a object
#1

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?
Reply
#2

It crashes the server ... How the hell did that compile in the first place? IsPlayerInRangeOfPoint expects 5 parameters. https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint
Reply
#3

It gave me a warning about that.
Reply
#4

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])
Reply
#5

I have no idea what you mean.
Reply
#6

Quote:
Originally Posted by Oh
Посмотреть сообщение
I have no idea what you mean.
The object must have a position. Assuming that
Код:
item[i]
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))
{ 
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)