Stealfuel
#1

Hey guys, I got this command called /stealfuel it's working fine but I wonder how can I make it limited? Like that the gascan can only contain 20 fuel and can get the maximum out of a vehicle for example if the vehicle got 10 fuel that the gascan gains 10 fuel instead 20. I hope you get what I mean.
Here are the codes
pawn Код:
CMD:stealfuel(playerid, params[])
{
    if(PlayerInfo[playerid][pScrewdriver] == 1 && PlayerInfo[playerid][pCan] == 1 && PlayerInfo[playerid][pHosePipe] == 1)
    {
        new closestcar = GetClosestCar(playerid);
        if(IsPlayerNearVehicle(playerid, closestcar, 7.0))
        {
            if(Fuel[closestcar] == 0)
            {
                SendClientMessage(playerid, COLOR_YELLOW,"This vehicle is out of fuel.");
            }
            else if(Fuel[closestcar] > 0)
            {
                if(PlayerInfo[playerid][pCanFuel] == 20) return SendClientMessage(playerid, COLOR_YELLOW,"Your gascan is full.");
                PlayerInfo[playerid][pCanFuel] += ;
                Fuel[closestcar] -= ;
            }
        else
        {
        SendClientMessage(playerid, COLOR_DARKRED,"[SERVER] {FFFFFF}You aren't near any vehicle.");
        }
    }
    else
    {
    SendClientMessage(playerid, COLOR_DARKRED,"[SERVER] {FFFFFF}Make sure you got a gascan, hosepipe and a screwdriver in order to steal fuel.");
    }
    return 1;
}
Reply
#2

pawn Код:
else if(Fuel[closestcar] > 0)
            {
                if(PlayerInfo[playerid][pCanFuel] == 20) return SendClientMessage(playerid, COLOR_YELLOW,"Your gascan is full.");
                new Float:FillAmount = 20 - PlayerInfo[playerid][pCanFuel];
               
                    if((Fuel[closestcar] - FillAmount) < 0)
                    {
                         PlayerInfo[playerid][pCanFuel] += Fuel[closestcar];
                         Fuel[closestcar] = 0.0;
                    }
                    else
                    {
                        PlayerInfo[playerid][pCanFuel] += FillAmount;
                        Fuel[closestcar] -= FillAmount;                      
                    }  
            }
Reply
#3

I don't get it it once I stealfuel from a vehicle with 10 fuel, it tells me that my gascan contains 11025631 fuel.
Reply
#4

Ahh your fuel is probably not a float then you'll need to update it a bit.
Reply
#5

The fuel is actually a float
pawn Код:
new Float:Fuel[MAX_VEHICLES] = {100.0, ...};
Reply
#6

Oh yea, I see what I did wrong, like you just said %d are providing weird values and thats exactly what I used to see the amount of gas. Thanks both for helping me out on this one
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)