10.10.2015, 00:36
O Velocimetro/Textdraw nгo estб desaparecendo apуs sair do veнculo
Quem puder ajudar ai agradeзo, й uma coisa boba sу que eu nгo estou conseguindo arrumar :P
PHP Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
new vehicleid = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(IsABike(vehicleid)) SetVehicleParamsEx(vehicleid,1,lights,alarm,doors,bonnet,boot,objective);
if(!IsABike(vehicleid))
{
VelocimetroUpdate[playerid] = SetTimerEx("UpdateVehicleHud", 1000, true, "i", playerid);
if(vInfo[vehicleid][vHasEngine] == true)
{
if(vInfo[vehicleid][vFuel] <= 0)
{
KillTimer(GasolinaTimer[playerid]);
SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
}
if(vInfo[vehicleid][vFuel] > 0)
{
GasolinaTimer[playerid] = SetTimerEx("GasolinaTime", 5000, true, "ii", playerid, vehicleid);
}
}
}
}
else
{
for(new i = 0; i < sizeof(CarroHUD); i++) PlayerTextDrawHide(playerid, CarroHUD[playerid][i]);
KillTimer(GasolinaTimer[playerid]);
KillTimer(VelocimetroUpdate[playerid]);
}
return 1;
}
PHP Code:
public UpdateVehicleHud(playerid)
{
new str[34];
new vehicleid = GetPlayerVehicleID(playerid);
format(str, sizeof(str), "Vehicle Health: ~g~%.0f%", GetVehicleHealthEx(vehicleid));
PlayerTextDrawSetString(playerid, CarroHUD[playerid][1], str);
if(vInfo[vehicleid][vHasEngine] == true) PlayerTextDrawSetString(playerid, CarroHUD[playerid][2], "Engine: ~g~Yes");
else if(vInfo[vehicleid][vHasEngine] == false) PlayerTextDrawSetString(playerid, CarroHUD[playerid][2], "Engine: ~r~No");
for(new i = 0; i < sizeof(CarroHUD); i++) PlayerTextDrawShow(playerid, CarroHUD[playerid][i]);
return 1;
}