Fuel not working
#1

Hello guys.

I recently downloaded a speedometer and edited it a bit and added fuel meter.

In a command its working, but the speedometer is just showing 00.00.

Let me show you the code where it works.

Код:
	else if(strcmp(params, "status", true) == 0)
	{
		if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
		{
			new vehicleid = GetPlayerVehicleID(playerid);
			new engine,lights,alarm,doors,bonnet,boot,objective,enginestatus[4],lightstatus[4], string[48];
			GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
			if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_RED,"This vehicle doesn't need fuel.");
			if(engine != VEHICLE_PARAMS_ON) format(enginestatus, sizeof(enginestatus), "OFF");
			else format(enginestatus, sizeof(enginestatus), "ON");
			if(lights != VEHICLE_PARAMS_ON) format(lightstatus, sizeof(lightstatus), "OFF");
			else format(lightstatus, sizeof(lightstatus), "ON");
			format(string, sizeof(string), "Engine: %s | Lights: %s | Fuel: %.2f.",enginestatus,lightstatus,VehicleFuel[vehicleid]);
			SendClientMessageEx(playerid, COLOR_WHITE, string);
		}
	}
And here's the speedometer

Код:
public CheckStatus()
{
	for(new i=0; i<MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if(IsPlayerInAnyVehicle(i))
			{
				if(TextDrawsShown[i] == false)
				{
				    TextDrawShowForPlayer(i, Text:Black0);
				    TextDrawShowForPlayer(i, Text:Black1);
				    TextDrawShowForPlayer(i, Text:Black2);
				    TextDrawShowForPlayer(i, Text:Black3);
				    TextDrawShowForPlayer(i, Text:LightBlack);
				    TextDrawsShown[i] = true;
				}
			    new String[128];
			    new vehicleid = GetPlayerVehicleID(i);
		        new Float:X, Float:Y, Float:Z, Float:Speed;
                GetVehicleVelocity(GetPlayerVehicleID(i), X, Y, Z);
                Speed = floatmul(floatsqroot(floatadd(floatadd(floatpower(X, 2), floatpower(Y, 2)),  floatpower(Z, 2))), 100.0);
				format(String,sizeof(String),"~b~Speed: ~w~%ikm/h~n~~b~Fuel: ~w~%.2f.", floatround(floatdiv(Speed, 1.609344), floatround_floor), floatround(Speed, floatround_floor), VehicleFuel[vehicleid]);
				if(VHSCreated[i] == true)
				{
					TextDrawDestroy(VHS[i]);
				}
				VHS[i] = TextDrawCreate(545.000000,387.000000,String);
				TextDrawAlignment(VHS[i],0);
				TextDrawBackgroundColor(VHS[i],0x000000ff);
				TextDrawFont(VHS[i],1);
				TextDrawLetterSize(VHS[i],0.299999,1.000000);
				TextDrawColor(VHS[i],0xffffffff);
				TextDrawSetOutline(VHS[i],1);
				TextDrawSetProportional(VHS[i],1);
				TextDrawSetShadow(VHS[i],1);
            	TextDrawShowForPlayer(i, VHS[i]);
            	VHSCreated[i] = true;
			}
			else
			{
			    if(TextDrawsShown[i] == true)
			    {
					TextDrawHideForPlayer(i, Text:Black0);
					TextDrawHideForPlayer(i, Text:Black1);
					TextDrawHideForPlayer(i, Text:Black2);
					TextDrawHideForPlayer(i, Text:Black3);
					TextDrawHideForPlayer(i, Text:LightBlack);
				    TextDrawsShown[i] = false;
				}
				TextDrawHideForPlayer(i, Text:VHS[i]);
			}
		}
	}
}
Whats the error?
Reply
#2

Is the client message displaying the fuel properly (not as 0.0)?

Код:
format(string, sizeof(string), "Engine: %s | Lights: %s | Fuel: %.2f.",enginestatus,lightstatus,VehicleFuel[vehicleid]);
			SendClientMessageEx(playerid, COLOR_WHITE, string);
Reply
#3

Quote:
Originally Posted by Divergent
Посмотреть сообщение
Is the client message displaying the fuel properly (not as 0.0)?

Код:
format(string, sizeof(string), "Engine: %s | Lights: %s | Fuel: %.2f.",enginestatus,lightstatus,VehicleFuel[vehicleid]);
			SendClientMessageEx(playerid, COLOR_WHITE, string);
Well the command shows the fuel properly for example: 98.93 but the speedometer shows: 00.00
Reply
#4

BUMP.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)