Stealfuel
#1

Guys, I got a little problem with this cmd, it works actually how I wanted it to work but there is one thing that I need help with. Once I steel fuel from a car I get the fuel in the can, but then I type the cmd again and then the gas can status is 0 while it was full before that . I hope you guys can keep up. Here are the codes.

pawn Код:
CMD:stealfuel(playerid, params[])
{
    if(PlayerInfo[playerid][pCan] == 1 && PlayerInfo[playerid][pSiphon] == 1)
    {
        new closestcar = GetClosestCar(playerid);
        new string[128];
        if(IsPlayerInRangeOfVehicle(playerid, closestcar, 7.0))
        {
            if(Fuel[closestcar] == 0)
            {
                format(string,sizeof(string),"* %s opens the bottom of the vehicles gas tank",RPN(playerid));
                ProxDetector(30.0, playerid, string, COLOR_PURPLE);
                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.");
                new Float:FillAmount = 20 - PlayerInfo[playerid][pCanFuel];

                    if((Fuel[closestcar] - FillAmount) < 0)
                    {
                         PlayerInfo[playerid][pCanFuel] += Fuel[closestcar];
                         Fuel[closestcar] = 0.0;
                         format(string,sizeof(string),"* %s opens the bottom of the vehicles gas tank, uses their siphon to drain the gasoline into the gascan, but extracts nothing from the empty gastank.",RPN(playerid));
                         ProxDetector(30.0, playerid, string, COLOR_PURPLE);
                    }
                    else
                    {
                        PlayerInfo[playerid][pCanFuel] += FillAmount;
                        Fuel[closestcar] -= FillAmount;
                        format(string,sizeof(string),"* %s opens the bottom of the vehicles gas tank, uses their siphon to drain the gasoline into the gascan.",RPN(playerid));
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE);
                    }
            }
        }
        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 and a siphon in order to steal fuel.");
    }
    return 1;
}
Reply
#2

if its full FillAmount will be set to =0 then the whole thing messes up.

the function is scripted a complex way!
there is a much more simpler way of doing it.
i would show you but im on the phone.
edit
I'll show u when I get home(if I don't forget)!
Reply
#3

Creating this command has been a pain in the ass for me all the time any help is appreciated
Reply
#4

:S anyone?
Reply
#5

Bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)