Object Help!
#1

ok this is what I want to do with a certain object.

Код:
if(GetObjectPos(elevator) == 0.0.0 );(for example)
{
DestroyObject(elevator);
}
So if the object is at location 0.0.0 destroy the object.

How do I do it ? Can some one give me the correct code.
Reply
#2

Use the floats like
pawn Код:
new Float:x, Float:y, Float:z;
 GetObjectPos(elevator,x, y, z);
Then for the check
pawn Код:
if(GetObjectPos(elevator,x, y, z))
{
//bla bla
}
Reply
#3

Код:
new Float:x, Float:y, Float:z;
if(GetObjectPos(elevator,x, y, z) == 1567.4233398438, -1634.6782226563, 18.896639823914);
Ok this is what I have ^ , But these are the error I get.

Код:
warning 206: redundant test: constant expression is non-zero
error 036: empty statement
both of those errors and warnings are on the same line:
Код:
if(GetObjectPos(elevator,x, y, z) == 1567.4233398438, -1634.6782226563, 18.896639823914);
Reply
#4

anyone?? Help please!
Reply
#5

Quote:
Originally Posted by DaRk_RaiN
Посмотреть сообщение
Then for the check
pawn Код:
if(GetObjectPos(elevator,x, y, z))
{
//bla bla
}
What kind of stupid response is this? This just checks if the object exists. Not if it is one specified position. The right way to do it is:
pawn Код:
new Float:x, Float:y, Float:z;
GetObjectPos(elevator,x, y, z);

if(x == 1567.4233398438 && y == -1634.6782226563 && z = 18.896639823914)
{
    // do stuff
}
Although floats are not very accurate values due to the way they are being saved, so even if the location is off by 0.0001, this statement will return false. So to circumvent this, you might use GetDistanceBetweenPoints.

pawn Код:
stock Float:GetDistanceBetweenPoints(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2)
{
    x1 -= x2;
    y1 -= y2;
    z1 -= z2;
    return floatsqroot((x1 * x1) + (y1 * y1) + (z1 * z1));
}
pawn Код:
new Float:x, Float:y, Float:z;
GetObjectPos(elevator,x, y, z);

if(GetDistanceBetweenPoints(x, y, z, 1567.4233398438, -1634.6782226563, 18.896639823914) < 3.0)
{
    // do stuff
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)