Help Fuel system
#1

Actually i downloaded a fuel filterscript....

pawn Код:
//THIS FILTERSCRIPT IS MADE BY FiReMaNStone Thank you
// please dont Remove Credits
#include <a_samp>
new fuel[MAX_VEHICLES];
forward timer_fuel_lower();
forward timer_refuel(playerid);
new isrefuelling[MAX_PLAYERS] = 0;
new Text:td_fuel[MAX_PLAYERS];
public OnFilterScriptInit()
{
    for(new i=0;i<MAX_VEHICLES;i++) {
        fuel[i] = 100;
    }
    SetTimer("timer_fuel_lower",4200,true);
    return 1;
}
public OnPlayerSpawn(playerid)
{
    td_fuel[playerid] = TextDrawCreate(45,324,"Fuel: 100");
    TextDrawBackgroundColor(td_fuel[playerid],0x00000033);
    TextDrawFont(td_fuel[playerid],3);
    TextDrawLetterSize(td_fuel[playerid],0.699999,1.700000);
    TextDrawColor(td_fuel[playerid],0x000000ff);
    TextDrawSetShadow(td_fuel[playerid],3);
    return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        new vid = GetPlayerVehicleID(playerid);
        new string[125];format(string,sizeof string,"Fuel:%i",fuel[vid]);
        TextDrawSetString(td_fuel[playerid],string);
        TextDrawShowForPlayer(playerid,td_fuel[playerid]);
    } else {
        TextDrawHideForPlayer(playerid,td_fuel[playerid]);
    }
    return 1;
}
public OnPlayerCommandText(playerid,cmdtext[]) {

    if (!strcmp("/refuel",cmdtext,true,7)) {
        if (!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFFC800FF,"You are not in an vehicle!");
        if (isrefuelling[playerid]) return SendClientMessage(playerid,0xFFC800FF,"You are already refuelling!");
        if (GetPlayerMoney(playerid) - 2000 <0) return SendClientMessage(playerid,0xFFC800FF,"You dont have enough money!");
        SetCameraBehindPlayer(playerid);
        TogglePlayerControllable(playerid,0);
        isrefuelling[playerid] = 1;
        TextDrawSetString(td_fuel[playerid],"Refuelling...");
        SetTimerEx("timer_refuel",4500,false,"i",playerid);
        return 1;
    }

    return 0;
}
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;
                RemovePlayerFromVehicle(i);
                GameTextForPlayer(i,"~r~You are out of ~w~fuel~r~!",5000,4);
            }
        }
        new string[125];format(string,sizeof string,"Fuel:%i",fuel[vid]);
        TextDrawSetString(td_fuel[i],string);
    }
    return 1;
}

public timer_refuel(playerid)
{
    new vid = GetPlayerVehicleID(playerid);
    fuel[vid] = fuel[vid] = 100;
    isrefuelling[playerid] = 0;
    TextDrawSetString(td_fuel[playerid],"Fuel:100");
    TogglePlayerControllable(playerid,1);
}
Only i need to set the fuel only for hydra/hunter/rhino/seasparrow! Please change from MAX_VEHICLES to the vehicleid!

Thanks in advance
Reply
#2

What exactly are you trying to do...? Make it so only those vehicles lose fuel and can be refueled or what?
Reply
#3

@ antonio, yes make it thos only vehicles to lose the fuel...
Reply
#4

Try this
pawn Код:
//THIS FILTERSCRIPT IS MADE BY FiReMaNStone Thank you
// please dont Remove Credits
#include <a_samp>
new fuel[4];
forward timer_fuel_lower();
forward timer_refuel(playerid);

new isrefuelling[MAX_PLAYERS] = 0;

new Text:td_fuel[MAX_PLAYERS];

public OnFilterScriptInit()
{
    for(new i=0;i<MAX_VEHICLES;i++)
    {
        if (i==520 || i==447 || i==425 || i==432)
        {
        fuel[i] = 100;
        }
    }
    SetTimer("timer_fuel_lower",4200,true);
    return 1;
}
public OnPlayerSpawn(playerid)
{
    td_fuel[playerid] = TextDrawCreate(45,324,"Fuel: 100");
    TextDrawBackgroundColor(td_fuel[playerid],0x00000033);
    TextDrawFont(td_fuel[playerid],3);
    TextDrawLetterSize(td_fuel[playerid],0.699999,1.700000);
    TextDrawColor(td_fuel[playerid],0x000000ff);
    TextDrawSetShadow(td_fuel[playerid],3);
    return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        new vid = GetPlayerVehicleID(playerid);
        if (vid==520 || vid==447 || vid==425 || vid==432)
        {
        new string[125];format(string,sizeof string,"Fuel:%i",fuel[vid]);
        TextDrawSetString(td_fuel[playerid],string);
        TextDrawShowForPlayer(playerid,td_fuel[playerid]);
        }
    }
    else
    {
        TextDrawHideForPlayer(playerid,td_fuel[playerid]);
    }
    return 1;
}
public OnPlayerCommandText(playerid,cmdtext[]) {

    if (!strcmp("/refuel",cmdtext,true,7)) {
        if (!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFFC800FF,"You are not in an vehicle!");
        if (isrefuelling[playerid]) return SendClientMessage(playerid,0xFFC800FF,"You are already refuelling!");
        if (GetPlayerMoney(playerid) - 2000 <0) return SendClientMessage(playerid,0xFFC800FF,"You dont have enough money!");
        SetCameraBehindPlayer(playerid);
        TogglePlayerControllable(playerid,0);
        isrefuelling[playerid] = 1;
        TextDrawSetString(td_fuel[playerid],"Refuelling...");
        SetTimerEx("timer_refuel",4500,false,"i",playerid);
        return 1;
    }

    return 0;
}
public timer_fuel_lower()
{
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if (isrefuelling[i]) continue;
        new vid = GetPlayerVehicleID(i);
        if (vid==520 || vid==447 || vid==425 || vid==432)
        {
            if (GetPlayerVehicleSeat(i) == 0)
            {
                fuel[vid] = fuel[vid] -1;
                if (fuel[vid]<1)
                {
                    fuel[vid] = 0;
                    RemovePlayerFromVehicle(i);
                    GameTextForPlayer(i,"~r~You are out of ~w~fuel~r~!",5000,4);
                }
            }
        }
        new string[125];format(string,sizeof string,"Fuel:%i",fuel[vid]);
        TextDrawSetString(td_fuel[i],string);
    }
    return 1;
}

public timer_refuel(playerid)
{
    new vid = GetPlayerVehicleID(playerid);
    if (vid==520 || vid==447 || vid==425 || vid==432)
    {
    fuel[vid] = fuel[vid] = 100;
    isrefuelling[playerid] = 0;
    TextDrawSetString(td_fuel[playerid],"Fuel:100");
    TogglePlayerControllable(playerid,1);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)