Help with gas vehicle
#1

Код:
public CheckGas()
{
	new string[256];
	for(new i=0;i<PLAYERS;i++)
	{
    	if(IsPlayerConnected(i))
       	{
       	    if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
       	    {
	       		new vehicle = GetPlayerVehicleID(i);
	        	if(Gas[vehicle] >= 1)
		   		{
		   		    if(Gas[vehicle] > 100)
						Gas[vehicle] = 100;
		   		    if(Gas[vehicle] <= 10)
				    {
			   			PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0);
			   			if(gGas[i] == 0) {
			   				GameTextForPlayer(i,"~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~Fuel is low",5000,3);
						}
				    }
		   		    if(gGas[i] == 1) {
		   		    if(IsAPlane(vehicle) || IsABoat(vehicle) || IsAHarvest(vehicle) || IsADrugHarvest(vehicle) || IsASweeper(vehicle) || GetVehicleModel(vehicle) == 481)
		   		    {
		      			format(string, sizeof(string), "~b~~n~~n~~n~~n~~n~~n~~n~~n~~n~Fuel:~w~ N/A");
					}
					else
					{
                        format(string, sizeof(string), "~b~~n~~n~~n~~n~~n~~n~~n~~n~~n~Fuel:~w~ %d%",Gas[vehicle]);
					}
		      		GameTextForPlayer(i,string,20500,3); 
					}
					
					if(IsAPlane(vehicle) || IsABoat(vehicle) || IsAHarvest(vehicle) || IsADrugHarvest(vehicle) || IsASweeper(vehicle) || GetVehicleModel(vehicle) == 481 || engineOn[vehicle] == 0) { Gas[vehicle]++; }
	              	Gas[vehicle]--;
		   		}
	   			else
	           	{
	              	NoFuel[i] = 1;
	              	TogglePlayerControllable(i, 0);
		        	GameTextForPlayer(i,"~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~No fuel in Vehicle",1500,3);
				}
			}
    	}
	}
	return 1;
}
How do i lower the gas lowering ?
i think it's something with
Gas[vehicle]--;?
Reply
#2

Hello.

This
pawn Код:
Gas[vehicle]--;
Reduces the amount of gas in the vehicle by one.

If you want it to lower gas at a slower rate, you need to slow down the rate at which the function "CheckGas" is called.

I believe it is a timer, so search your script for
pawn Код:
SetTimer("CheckGas"
Once you have found that, you need to change the time until the timer runs out. This should be the first number in the function "SetTimer"
pawn Код:
SetTimer(Name, time(milliseconds), repeat);
Increase the "time" to make the timer end less frequently, and your fuel last longer.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)