22.12.2011, 11:55
I was just wondering can an object be moved if it has been attached to a vehicle? I have some code that attaches SAM sites to a truck, and when vehicle horn is pressed two hydra flares are attached to the SAMs and then moved towards a player that is in an air vehicle. I would just "GetObjectPos" on the SAMs and just create the object there and move them but "GetObjectPos" seems to be very inaccurate, so wont work. (spawning the flares way behind the truck).
Heres a snippet
If someone has a half decent workaround please let me know.
Heres a snippet
pawn Код:
if(!gAATData[iTruckIdx][e_bMissileFired_1])
{
new
iTargetVehicleid,
Float:fpX, Float:fpY, Float:fpZ;
GetPlayerPos(gAATData[iTruckIdx][e_iDriverID], fpX, fpY, fpZ);
foreach(Player, playerid)
{
iTargetVehicleid = GetPlayerVehicleID(playerid);
if((IsAnAirplane(iTargetVehicleid) || IsAHelicopter(iTargetVehicleid)) && IsPlayerInRangeOfPoint(playerid, MISSILE_TARGET_RANGE, fpX, fpY, fpZ))
{
gAATData[iTruckIdx][e_iMissileID_1] = CreateObject(354, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 200);
AttachObjectToVehicle(gAATData[iTruckIdx][e_iMissileID_1], gAATData[iTruckIdx][e_iAatVehicleid], 0.01, -3.85, -0.80, 0.00, 0.00, 0.00);
GetPlayerPos(playerid, fpX, fpY, fpZ);
//move object
MoveObject(gAATData[iTruckIdx][e_iMissileID_1], fpX, fpY, fpZ, MISSILE_SPEED);//not moving
gAATData[iTruckIdx][e_iMissileTimer_1] = SetTimerEx("SVEH_MissileUpdate", 1000, true, "iii", playerid, gAATData[iTruckIdx][e_iMissileID_1], iTruckIdx);
gAATData[iTruckIdx][e_iMTimerActive_1] = true;
gAATData[iTruckIdx][e_bMissileFired_1] = true;
return;
}
}
}