13.07.2013, 23:34
There is actually nothing wrong with that, the thing thats not working properly is that if I stealfuel for the first time it's all working fine and then the second time it's getting messed up.
Here is it tho.
Here is it tho.
pawn Код:
stock GetDistanceToCar(playerid, veh, Float: posX = 0.0, Float: posY = 0.0, Float: posZ = 0.0) {
new
Float: Floats[2][3];
if(posX == 0.0 && posY == 0.0 && posZ == 0.0) {
if(!IsPlayerInAnyVehicle(playerid)) GetPlayerPos(playerid, Floats[0][0], Floats[0][1], Floats[0][2]);
else GetVehiclePos(GetPlayerVehicleID(playerid), Floats[0][0], Floats[0][1], Floats[0][2]);
}
else {
Floats[0][0] = posX;
Floats[0][1] = posY;
Floats[0][2] = posZ;
}
GetVehiclePos(veh, Floats[1][0], Floats[1][1], Floats[1][2]);
return floatround(floatsqroot((Floats[1][0] - Floats[0][0]) * (Floats[1][0] - Floats[0][0]) + (Floats[1][1] - Floats[0][1]) * (Floats[1][1] - Floats[0][1]) + (Floats[1][2] - Floats[0][2]) * (Floats[1][2] - Floats[0][2])));
}
stock GetClosestCar(playerid, exception = INVALID_VEHICLE_ID) {
new
Float: Distance,
target = -1,
Float: vPos[3];
if(!IsPlayerInAnyVehicle(playerid)) GetPlayerPos(playerid, vPos[0], vPos[1], vPos[2]);
else GetVehiclePos(GetPlayerVehicleID(playerid), vPos[0], vPos[1], vPos[2]);
for(new v; v < MAX_VEHICLES; v++) if(GetVehicleModel(v) >= 400) {
if(v != exception && (target < 0 || Distance > GetDistanceToCar(playerid, v, vPos[0], vPos[1], vPos[2]))) {
target = v;
Distance = GetDistanceToCar(playerid, v, vPos[0], vPos[1], vPos[2]);
}
}
return target;
}