29.09.2013, 02:41
I made a vehicle system, and when you hop in, everything shows up and works fine. Although the fuel meter is supposed to show the percentage of fuel in the vehicle, the vehicle fuel will be at 100, but the textdraw shows it as if it is at less than 10%. The system has a "Check Engine" light to come on at a certain time, and it works perfectly. When you get out of the vehicle and back in, the main textdraw does not show up at all, and if the vehicle damage is correct, the light will show but that is all. Another issue i'm having with this is the check engine should flash when the vehicle health gets below 70%, it does not, and the textdraw just stays stationary. Please help!
pawn Код:
public OnPlayerUpdate(playerid)
{
new vehicleID = GetPlayerVehicleID(playerid);
if(GetPlayerState(playerid) == 2)
{
if(checkengine[playerid] == 1)
{
PlayerTextDrawShow(playerid, Engine1);
PlayerTextDrawShow(playerid, Engine2);
return 1;
}
SetTimerEx("OnVehicleHealthUpdate", 500, true, "i", playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleID, engine, lights, alarm, doors, bonnet, boot, objective);
PlayerTextDrawShow(playerid, Dash0);
PlayerTextDrawShow(playerid, Dash1);
PlayerTextDrawShow(playerid, Dash2);
PlayerTextDrawShow(playerid, Dash3);
PlayerTextDrawShow(playerid, Dash4);
PlayerTextDrawShow(playerid, Dash5);
PlayerTextDrawShow(playerid, Dash6);
if(VehicleInfo[vehicleID][vFuel] >=0)
{
PlayerTextDrawSetString(playerid, Dash3, "l");
return 1;
}
if(VehicleInfo[vehicleID][vFuel] >=10)
{
PlayerTextDrawSetString(playerid, Dash3, "ll");
return 1;
}
if(VehicleInfo[vehicleID][vFuel] >=20)
{
PlayerTextDrawSetString(playerid, Dash3, "lll");
return 1;
}
if(VehicleInfo[vehicleID][vFuel] >=30)
{
PlayerTextDrawSetString(playerid, Dash3, "llll");
return 1;
}
if(VehicleInfo[vehicleID][vFuel] >=40)
{
PlayerTextDrawSetString(playerid, Dash3, "lllll");
return 1;
}
if(VehicleInfo[vehicleID][vFuel] >=50)
{
PlayerTextDrawSetString(playerid, Dash3, "llllll");
return 1;
}
if(VehicleInfo[vehicleID][vFuel] >=60)
{
PlayerTextDrawSetString(playerid, Dash3, "lllllll");
return 1;
}
if(VehicleInfo[vehicleID][vFuel] >=70)
{
PlayerTextDrawSetString(playerid, Dash3, "llllllll");
return 1;
}
if(VehicleInfo[vehicleID][vFuel] >=80)
{
PlayerTextDrawSetString(playerid, Dash3, "lllllllll");
return 1;
}
if(VehicleInfo[vehicleID][vFuel] >=90)
{
PlayerTextDrawSetString(playerid, Dash3, "llllllllll");
return 1;
}
return 1;
}
else
{
PlayerTextDrawHide(playerid, Dash0);
PlayerTextDrawHide(playerid, Dash1);
PlayerTextDrawHide(playerid, Dash2);
PlayerTextDrawHide(playerid, Dash3);
PlayerTextDrawHide(playerid, Dash4);
PlayerTextDrawHide(playerid, Dash5);
PlayerTextDrawHide(playerid, Dash6);
PlayerTextDrawHide(playerid, Engine1);
PlayerTextDrawHide(playerid, Engine2);
return 1;
}
}
pawn Код:
forward OnFuelUpdate(playerid);
public OnFuelUpdate(playerid)
{
new vehicleID = GetPlayerVehicleID(playerid);
new engine1, lights1, alarm1, doors1, bonnet1, boot1, objective1;
GetVehicleParamsEx(vehicleID, engine1, lights1, alarm1, doors1, bonnet1, boot1, objective1);
if(engine1 == 1)
{
VehicleInfo[vehicleID][vFuel] --;
return 1;
}
return 1;
}
pawn Код:
forward OnVehicleHealthUpdate(playerid);
public OnVehicleHealthUpdate(playerid)
{
new vehicleID = GetPlayerVehicleID(playerid);
new Float:health;
GetVehicleHealth(vehicleID, health);
if(health <=800)
{
if(checkengine[playerid] == 0)
{
checkengine[playerid] = 1;
return 1;
}
return 1;
}
if(health <=700)
{
if(engineflash[playerid] == 0)
{
EF[playerid] = SetTimerEx("EngineFlash1", 2000, true, "i", playerid);
PlayerTextDrawHide(playerid, Engine1);
PlayerTextDrawHide(playerid, Engine2);
engineflash[playerid] = 1;
return 1;
}
return 1;
}
if(health >800)
{
if(checkengine[playerid] == 1)
{
checkengine[playerid] = 0;
PlayerTextDrawHide(playerid, Engine1);
PlayerTextDrawHide(playerid, Engine2);
return 1;
}
if(engineflash[playerid] == 1)
{
engineflash[playerid] = 0;
KillTimer(EF[playerid]);
return 1;
}
return 1;
}
return 1;
}
pawn Код:
forward EngineFlash1(playerid);
public EngineFlash1(playerid)
{
SetTimerEx("EngineFlash2", 1000, false, "i", playerid);
return 1;
}
forward EngineFlash2(playerid);
public EngineFlash2(playerid)
{
PlayerTextDrawShow(playerid, Engine1);
PlayerTextDrawShow(playerid, Engine2);
SetTimerEx("EngineFlash3", 1000, false, "i", playerid);
return 1;
}
forward EngineFlash3(playerid);
public EngineFlash3(playerid)
{
PlayerTextDrawHide(playerid, Engine1);
PlayerTextDrawHide(playerid, Engine2);
return 1;
}