Checking if Object is at the given position
#1

I have those 2 commands

pawn Код:
dcmd_actest(playerid, params[])
{
    #pragma unused playerid
    #pragma unused params
    test = CreateObject(16442, -1194.8014, -1061.5055, 129.2188, 0, 0, 90);
}

dcmd_actest1(playerid, params[])
{
    #pragma unused playerid
    #pragma unused params
    MoveObject(test, -1191.5671, -954.3043, 129.2119, 2.0);
}
Now how can i check if the object test is at ? I know to use a timer and GetObjectPos, but how to format it.. (if its at the coordinates -1194.8014, -1061.5055, 129.2188 then do something")

Can somebody help me?

Thnx
Reply
#2

Modify a version of PlayerToPoint, Maybe like this?
pawn Код:
public ObjectToPoint(Float:radi, objectid, Float:x, Float:y, Float:z)
{
  if(IsValidObject(objectid))
  {
    new Float:oldposx, Float:oldposy, Float:oldposz;
    new Float:tempposx, Float:tempposy, Float:tempposz;
    GetObjectPos(objectid, oldposx, oldposy, oldposz);
    tempposx = (oldposx -x);
    tempposy = (oldposy -y);
    tempposz = (oldposz -z);
    if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
    {
      return 1;
    }
  }
  return 0;
}
Reply
#3

Could you give an example of how to use this?
Reply
#4

Check my last post
Reply
#5

But the thing is, im moving the object to the coordinates -1191.5671, -954.3043, 129.2119 and then i want it to do something, thats done with ObjectToPoint?
Reply
#6

Say if you wanted to check of the object is near 5.98, 6.78, 0.91, If it is then move the object else do nothing, You would do
pawn Код:
if(ObjectToPoint(2, objectid, 5.98, 6.78, 0.91))
{
  // MoveObject
}
else
{
  // It isnt near that point
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)