Beitrag zum Thread verschoben.
Ziel:
Aus einer ganz normalen Liter anzeige eine Anzeige mit nach Komma stellen erstellen.
if((newstate == PLAYER_STATE_DRIVER) || (newstate == PLAYER_STATE_PASSENGER))
{
new vid = GetPlayerVehicleID(playerid);
new string[128], modelid = GetVehicleModel(GetPlayerVehicleID(playerid)), idx = modelid-400;
format(string, sizeof(string), "%d/%dLiter", vehData[vid][e_fuel],vehDefaultData[idx][e_maxFuel]);
PlayerTextDrawSetString(playerid, textdraw[5][playerid], string);
}
forward Tank();
public Tank()
{
new vehicleid,tmp_engine,tmp_lights,tmp_alarm,tmp_doors,tmp_bonnet,tmp_boot,tmp_objective,string[128],idx;
for(new i=0; i<MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i) || !IsPlayerInAnyVehicle(i)) continue;
vehicleid = GetPlayerVehicleID(i);
GetVehicleParamsEx(vehicleid, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
if(tmp_engine == 1)
{
if(vehData[vehicleid][e_fuel] < 1)
{
tmp_engine = 0;
SetVehicleParamsEx(vehicleid, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
}
else
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
vehData[vehicleid][e_fuel]--;
}
idx = GetVehicleModel(vehicleid)-400;
if(idx < 0) continue;
format(string, sizeof(string), "%0.2f/%dLiter", vehData[vehicleid][e_fuel],vehDefaultData[idx][e_maxFuel]);
PlayerTextDrawSetString(i, textdraw[5][i], string);
}
}
}
for(new i=0; i<MAX_VEHICLES; i++)
{
if(IsAnyDriverInVehicle(i)) continue;
GetVehicleParamsEx(i, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
if(tmp_engine == 1)
{
if(vehData[i][e_fuel] < 1)
{
tmp_engine = 0;
SetVehicleParamsEx(i, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
}
else
{
vehData[i][e_fuel]--;
}
}
}
return 1;
}
Alles anzeigen