not supply gasoline +REP
#1

I'm using a filterscript, well, he tells how many of gasoline has, and every step you walk with the car it decreases. When gasoline is over, the car stops working. Has the /refuel, to fuel, the more it sets the gasoline to 100 and the car will not start. Can anyone help? + rep

CMD:
pawn Code:
CMD:refuel(playerid,params[])
{
        if (!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFFC800FF,"You are not in an vehicle!"); //if a player isnt in a vehicle, it stops here
        if (isrefuelling[playerid]) return SendClientMessage(playerid,0xFFC800FF,"You are already refuelling!");  //if a player is already refuelling, it stops here
        else
        {
        SetCameraBehindPlayer(playerid); //Sets the camera behind the player (looks better because the player will be frozen for a few secs)
        isrefuelling[playerid] = 1; //setting isrefuelling to 1 so the player cant spam /refuel
        new string[125];format(string,sizeof string,"Fuel: ~r~%i~g~",fuel[playerid]);
        TextDrawSetString(td_fuel[playerid],string);
        GameTextForPlayer(playerid,"Your ~r~vehicle has been ~g~refueled.",2500,4);
        isrefuelling[playerid]=0;
        for(new i=0;i<MAX_PLAYERS;i++) {
        if (isrefuelling[i]) continue;
        new vid = GetPlayerVehicleID(i);
        if (GetPlayerVehicleSeat(i) == 0) {
            fuel[vid] = 101 -1;
            if (fuel[vid]<1)
            {
                fuel[vid] = 0;
                SetVehicleParamsEx(vid,0,0,0,0,1,1,0); //change this to watever you like
                GameTextForPlayer(i,"~r~You are out of ~w~fuel~r~!",5000,4); //show text
            }
        }
        new sstring[125];format(sstring,sizeof sstring,"Fuel: ~r~%i~g~",fuel[vid]);
        TextDrawSetString(td_fuel[i],string);
        TextDrawShowForPlayer(i,td_fuel[i]);

    }

        }    //setting refueltimer
        return 1;
}
Gasoline over
pawn Code:
public timer_fuel_lower()
{
    for(new i=0;i<MAX_PLAYERS;i++) {
        if (isrefuelling[i]) continue;
        new vid = GetPlayerVehicleID(i);
        if (GetPlayerVehicleSeat(i) == 0) {
            fuel[vid] = fuel[vid] -1;
            if (fuel[vid]<1)
            {
                fuel[vid] = 0;
                SetVehicleParamsEx(vid,0,0,0,0,1,1,0); //change this to watever you like
                GameTextForPlayer(i,"~b~Fuel~y~ Ende~p~d",5000,4); //show text
            }
        }
        new string[125];format(string,sizeof string,"Fuel: ~r~%i~g~",fuel[vid]);
        TextDrawSetString(td_fuel[i],string);

    }
    return 1;
}
Reply
#2

You have completely failed in that script.
The way you made /refuel command will restore fuel to you and to everyone else who is currently in a vehicle, driver seat and not refuelling. Even after using the restore you will need to start the vehicle engine manually (SetVehicleParamsEx).

Also I see you are using fuel[playerid] in one place and fuel[vid] in another.
This cannot happen, it will simply cause run time errors and problems.
Change your script to use either fuel[playerid] or fuel[vid] and then I will be able to help you.
Reply
#3

anyone... ?
Reply
#4

You where already helped, fix that simple step FOTIS6 suggested then if it doesnt work post again
Reply
#5

Not quite sure what you mean, but try this
pawn Code:
CMD:refuel(playerid,params[])
{
    if (!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFFC800FF,"You are not in an vehicle!");
    if (GetPlayerVehicleSeat(playerid) != 0) return SendClientMessage(playerid, 0xFFC800FF, "You are not a driver!");
    if (isrefuelling[playerid]) return SendClientMessage(playerid,0xFFC800FF,"You are already refuelling!");  
    else
    {
        new string[125];
        fuel[vid] = 100;

        SetCameraBehindPlayer(playerid);
        isrefuelling[playerid]=0;
        new vid = GetPlayerVehicleID(playerid);
        SetVehicleParamsEx(vid,1,0,0,0,1,1,0);

        GameTextForPlayer(playerid,"Your ~r~vehicle has been ~g~refueled.",2500,4);
        format(string,sizeof string,"Fuel: ~r~%i~g~",fuel[playerid]);
        TextDrawSetString(td_fuel[playerid],string);
        TextDrawShowForPlayer(playerid,td_fuel[playerid]);
    }    
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)