27.03.2013, 21:07
Quote:
1. You don't need loop at all. Put vehicleid parameter in your function.
2. You need return boot status not currentvehicle. Am I right? |
pawn Код:
stock BootStatusOfNearestVehicle(playerid, Float:distance = 2.0)
{
new
Float:fPos[3],
Float:sPos[3],
currentvehicle,
engine,
lights,
alarm,
doors,
bonnet,
boot,
objective
;
GetPlayerPos(playerid, fPos[0], fPos[1], fPos[2]);
for(new v = 1; v < MAX_VEHICLES; v++)
{
GetVehiclePos(v, sPos[0], sPos[1], sPos[2]);
new Float:odist =
floatsqroot(
floatpower(floatsub(sPos[0], fPos[0]), 2.0) +
floatpower(floatsub(sPos[1], fPos[1]), 2.0) +
floatpower(floatsub(sPos[2], fPos[2]), 2.0)
)
;
if (odist < distance)
{
currentvehicle = v;
distance = odist;
}
}
GetVehicleParamsEx(currentvehicle, engine, lights, alarm, doors, bonnet, boot, objective);
if(boot == 1) SetVehicleParamsEx(currentvehicle, engine, lights, alarm, doors, bonnet, 0, objective);
else if(boot == 0) SetVehicleParamsEx(currentvehicle, engine, lights, alarm, doors, bonnet, 1, objective);
return boot;
}