case 0:
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
{
ShowErrorDialog(playerid, "You are not driving a vehicle.");
return 1;
}
new vehicleid = GetPlayerVehicleID(playerid);
if(IsBicycle(vehicleid))
{
ShowErrorDialog(playerid, "Your vehicle doesn't have a fuel tank!");
return 1;
}
if(Fuel[vehicleid] >= 100.0)
{
ShowErrorDialog(playerid, "Your vehicle fuel tank is full.");
isrefuelling[playerid] = 0;
return 1;
}
if(GetPlayerMoney(playerid) < FUEL_PRICE)
{
ShowErrorDialog(playerid, "You don't have enough money.");
return 1;
}
RefuelTime[playerid] = 5;
SetPVarFloat(playerid, "Fuel", Fuel[vehicleid]);
GameTextForPlayer(playerid, "~g~refueling...", 2000, 3);
isrefuelling[playerid] = 1;
}
if(RefuelTime[i] > 0 && GetPVarInt(i, "FuelStation"))
{
new vehicleid = GetPlayerVehicleID(i);
RefuelTime[i]--;
if(RefuelTime[i] == 0)
{
new stationid = GetPVarInt(i, "FuelStation");
new cost = 100 - Fuel[vehicleid] * 3;
new vid = GetPlayerVehicleID(i);
Fuel[vid] = 100.0;
if(GetPlayerState(i) != PLAYER_STATE_DRIVER || !IsPlayerInRangeOfPoint(i, 10.0, FuelStationPos[stationid][0], FuelStationPos[stationid][1], FuelStationPos[stationid][2]))
{
GivePlayerMoney(i, -cost);
format(string, sizeof(string), "~r~-$%d", cost);
GameTextForPlayer(i, string, 2000, 3);
format(string, sizeof(string), "You have paid $%d for the fuel.", cost);
isrefuelling[i] = 0;
Fuel[vid] = 100.0;
SendClientMessage(i, COLOR_WHITE, string);
SetPVarInt(i, "FuelStation", 0);
SetTimer("SpeedoUpdate",100,1);
}
}
}
And how exactly do you know it is getting set to over 100? I don't see any debug messages.
|
public SpeedoUpdate()
{
for(new i = 0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
{
new Float:x,Float:y,Float:z,string[24];
new vid = GetPlayerVehicleID(i);
TextDrawShowForPlayer(i,box[i]);
TextDrawShowForPlayer(i,speed[i]);
GetVehicleVelocity(vid,x,y,z);
format(string,sizeof(string),"Speed: %dmph\nFuel:%i",floatround(floatsqroot(((x*x)+(y*y))+(z*z))*156.666667), Fuel[vid]);
TextDrawSetString(speed[i], string);
}
if(!IsPlayerInAnyVehicle(i))
{
TextDrawHideForPlayer(i,box[i]);
TextDrawHideForPlayer(i,speed[i]);
}
}
}
Hi,
After reading over your code, I've found that you set your fuel to "100.0" which is a float. However in your textdraw code, you call the fuel as an integer which is probably why you are getting a really large number on the textdraw. I think by changing the %i to %f would simply fix the issue. Edit: nvm just a few seconds late lmao |