GangZoneCreate(2563.775634,539.454345,2645.808349,397.840759);
public IsInArea()
{
if(IsObjectInArea(Football, 2563.775634,539.454345,2645.808349,397.840759))
{
return 1;
}
else
{
DestroyObject(Football);
Football = CreateObject(1303,2606.47167969,468.07437134,1.00000000,0.00000000,0.00000000,0.00000000);
print("The ball went away!");
//SendClientMessageToAll(COLOR_RED, "== The football went out of the zone and has been respawned!");
}
return 1;
}
stock IsObjectInArea(objectid, Float:min_x, Float:min_y, Float:max_x, Float:max_y)
{
new Float:X,Float:Y,Float:Z;
GetObjectPos(objectid, X, Y, Z);
if((X <= max_x && X >= min_x) && (Y <= max_y && Y >= min_y)) return 1;
return 0;
}
Objects always return the position of where they were created, so when they move, the position won't change.
maybe that's your problem? |
when you create an object at 0.0 0.0 0.0
then you move the object (shoot at it so the football moves; or whatever other way) and then do GetObjectPos it will still return 0.0 0.0 0.0 |
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & 1) // The fire button
{
new Float:X, Float:Y, Float:Z, Float:X3, Float:Y3;
GetObjectPos(Football, X, Y, Z);
GetXYInFrontOfPlayer(playerid, X3, Y3, 10.0);
if(PlayerToPoint(5.0, playerid, X, Y, Z))
{
MoveObject(Football, X3, Y3, Z, 15);
}
}
return 1;
}
GangZoneCreate(2563.775634,539.454345,2645.808349,397.840759);
if(IsObjectInArea(Football, 2645.808349, 2563.775634, 397.840759, 539.454345))
stock IsObjectInArea(objectid, Float:max_x, Float:min_x, Float:max_y, Float:min_y)
{
new Float:X, Float:Y, Float:Z;
GetObjectPos(objectid, X, Y, Z);
if(X <= max_x && X >= min_x && Y <= max_y && Y >= min_y) return 1;
return 0;
}
I'd have to argue, I have used MoveObject in the past and it returns the position of where it is, not where it's created if that's what your saying.
For instance, I wanted a smooth camera movement, so I created an object underground, moved the object to new coordinates, and on a timer I used GetObjectPos with SetPlayerCameraPos and it worked, so it must return the current position when used with MoveObject. It is true with dynamic objects though, such as crates, boxes, balls, broken cars etc. I can't figure out the problem myself, try some tests that print the object position after using MoveObject and see if it is that, I'm sure of my theory though, unless something changed in 0.3b. Good luck |