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
}