SA-MP Forums Archive
Fuel error - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Fuel error (/showthread.php?tid=607585)



Fuel error - MrCallum - 21.05.2016

When someone comes onto the server and does /car engine to any car, it says it has no fuel:

Код:
forward SetVehicleEngine(vehicleid, playerid);
public SetVehicleEngine(vehicleid, playerid)
{
	new string[128];
	new engine,lights,alarm,doors,bonnet,boot,objective;
    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
    if(engine == VEHICLE_PARAMS_ON)
	{
		SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
		SendClientMessageEx(playerid, COLOR_WHITE, "Vehicle engine stopped successfully.");
		arr_Engine{vehicleid} = 0;
		if(IsABaitCar(vehicleid) && BaitCarActive == 1)
		{
			foreach(Player, i)
			{
				PlayerTextDrawSetString(i, Textdraw9, "  ~r~OFF");
			}
		}
	}
    else if(engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET)
	{
		new
			Float: f_vHealth;

		GetVehicleHealth(vehicleid, f_vHealth);
		if(f_vHealth < 350.0) return SendClientMessageEx(playerid, COLOR_RED, "The car won't start - it's totalled!");
	    if(VehicleFuel[vehicleid] <= 0.0) return SendClientMessageEx(playerid, COLOR_RED, "The car won't start - there's no fuel in the tank!");
		SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
		SendClientMessageEx(playerid, COLOR_WHITE, "Vehicle engine started successfully (/car engine to turn the engine off).");
		arr_Engine{vehicleid} = 1;



Re: Fuel error - luke49 - 21.05.2016

Maybe you didn't set any fuel to the vehicle when you created it?


Re: Fuel error - maximthepain - 21.05.2016

Under OnGameModeInit should be the above code:

pawn Код:
public OnGameModeInit()
{
        for(new v = 0; v < MAX_VEHICLES; v++)
    {
        if(Cars(v))
        {
            VehicleFuel[v] = 100;
        }
        if(Bikes(v))
        {
            VehicleFuel[v] = 999;
        }
    }
}
Ofc that you don't have to use those Ifs Its just a better RP situation. If you won't check Bikes then they will have fuel too. Btw you probably don't have the Cars & Bikes function so i recommand creating them.


Re: Fuel error - MrCallum - 21.05.2016

I get
Quote:

C:\Users\Administrator\Desktop\Server\gamemodes\De bt.pwn(28300) : error 017: undefined symbol "Cars"
C:\Users\Administrator\Desktop\Server\gamemodes\De bt.pwn(28304) : error 017: undefined symbol "Bikes"




Re: Fuel error - maximthepain - 21.05.2016

Quote:
Originally Posted by MrCallum
Посмотреть сообщение
I get
Well ofcurse you will get this error.
Those Cars & Bikes are an example of making system to check which vehicle needs fuel and which doesn't.
Anyway, use this to check if it works overall:
pawn Код:
public OnGameModeInit()
{
        for(new v = 0; v < MAX_VEHICLES; v++)
    {
        VehicleFuel[v] = 100;
    }
}
If you are developing RP you should check which vehicle needs fuel and which doesn't.