Need help with my fuel system
#1

Hello,

My fuel system isnt working correctly.
I want it to say if the engine is on that they have to turn it off etc.

pawn Код:
command(refill, playerid, params[])
{
    #pragma unused params
    if(IsAtGasStation(playerid))
    {
        new PCar = GetClosestVehicle(playerid, 5);
        new engine,lights,alarm,doors,bonnet,boot,objective;
        GetVehicleParamsEx(PCar,engine,lights,alarm,doors,bonnet,boot,objective);
        if(IsPlayerConnected(playerid))
        {
            if(!IsPlayerInAnyVehicle(playerid))
            {
                if(engine == VEHICLE_PARAMS_OFF)
                {
                    if(Vehicles[PCar][Fuel] != 100)
                    {
                        ShowMenuForPlayer(Menu:Gas, playerid);
                    }
                    else
                    {
                        SCM(playerid, ADMINBLUE, "Your car is already full!");
                    }
                }
                else
                {
                    SCM(playerid, WHITE,"Your vehicle engine is still on!");
                }
            }
            else
            {
                SCM(playerid, WHITE,"You are still in a vehicle!");
            }
        }
    }
    else
    {
       SCM(playerid,0xFFFF00AA,".:: [ERROR]: You are not at a Gas Station! ::.");
    }
    return 1;
}
I also want it to check how much the car's fuel is and that minus 100, so that is the new fuel that gets added.
and that *3 but it doesn't work.

Menu reaction:
pawn Код:
public OnPlayerSelectedMenuRow(playerid, row)
{
    if(GetPlayerMenu(playerid) == Gas)
    {
        switch(row)
        {
            case 0:
            {
                TogglePlayerControllable(playerid,0);
                GameTextForPlayer(playerid,"~b~Petrol ~n~ ~w~Refueling vehicle ~n~~g~Please wait..",10000,3);
                RefillTimer = SetTimerEx("ReFill", 10000, false, "i", playerid);
                Tankuje[playerid] = 1;
            }
            case 1:
            {
                GameTextForPlayer(playerid,"~r~This function isn't working yet, sorry.",3500,3);
                TogglePlayerControllable(playerid,0);
            }
            case 2:
            {
                GameTextForPlayer(playerid,"~y~Have a nice day!",4000,3);
                HideMenuForPlayer(Gas,playerid);
            }
        }
    }
    return 1;
}
Public refill:
pawn Код:
public ReFill(playerid)
{
    new VehicleFuel, NewFuel, str[128];
    new PCar = GetClosestVehicle(playerid, 5);
    VehicleFuel = Vehicles[PCar][Fuel];
    NewFuel = 100-VehicleFuel;
    Vehicles[PCar][Fuel] = 100;
    GivePlayerMoney(playerid, -3*NewFuel);
    Player[playerid][Money] = -3*NewFuel;
    format(str, sizeof(str), "You refilled your vehicle with %d liters and the price was %d.", NewFuel, 3*NewFuel);
    SCM(playerid, ADMINBLUE, str);
    KillTimer(RefillTimer);
    TogglePlayerControllable(playerid,1);
}
Reply


Messages In This Thread
Need help with my fuel system - by Stefand - 09.12.2012, 07:06
Re: Need help with my fuel system - by Peach - 09.12.2012, 08:43
Re: Need help with my fuel system - by Stefand - 09.12.2012, 09:07
Re: Need help with my fuel system - by RenSoprano - 09.12.2012, 09:11
Re: Need help with my fuel system - by Stefand - 09.12.2012, 09:31
Re: Need help with my fuel system - by Peach - 09.12.2012, 09:32
Re: Need help with my fuel system - by Stefand - 10.12.2012, 13:01

Forum Jump:


Users browsing this thread: 3 Guest(s)