#1

Should I add loop here? Cuz I don't know I want to lower fuel at car for all players not only for one...

pawn Код:
public FLower(playerid)
{
    new vehicleid = GetPlayerVehicleID(playerid);
    Carinfo[vehicleid][F] = Carinfo[vehicleid][F] - FUEL_DECREASE;
    TextDrawShowForPlayer(playerid, vFuel[playerid]);
    TextDrawShowForPlayer(playerid, Fuel[playerid]);
    if(Carinfo[vehicleid][F] < 1)
    {
        new engine,lights,alarm,doors,bonnet,boot,objective;
        GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
        SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
        Carinfo[vehicleid][F] = 0;
        KillTimer(GasTimer[playerid]);
        GameTextForPlayer(playerid, "~r~Vehicle is out of ~w~fuel~r~!", 5000, 5);
        TextDrawHideForPlayer(playerid, Veh[playerid]);
        TextDrawHideForPlayer(playerid, Gear[playerid]);
        TextDrawHideForPlayer(playerid, Speed[playerid]);
        TextDrawHideForPlayer(playerid, HP[playerid]);
        TextDrawHideForPlayer(playerid, vHP[playerid]);
        TextDrawHideForPlayer(playerid, vGear[playerid]);
        TextDrawHideForPlayer(playerid, vSpeed[playerid]);
        TextDrawHideForPlayer(playerid, vName[playerid]);
        TextDrawHideForPlayer(playerid, Fuel[playerid]);
        TextDrawHideForPlayer(playerid, vFuel[playerid]);
    }
    if(Carinfo[vehicleid][F] > 95) TextDrawSetString(vFuel[playerid]," ~g~~n~lllll~n~~y~~h~lllll~y~~n~lllll~n~~r~lllll");
    if(Carinfo[vehicleid][F] > 90 && Carinfo[vehicleid][F] < 95) TextDrawSetString(vFuel[playerid], " ~g~~n~llll~n~~y~~h~lllll~y~~n~lllll~n~~r~lllll");
    if(Carinfo[vehicleid][F] > 85 && Carinfo[vehicleid][F] < 90) TextDrawSetString(vFuel[playerid], " ~g~~n~lll~n~~y~~h~lllll~y~~n~lllll~n~~r~lllll");
    if(Carinfo[vehicleid][F] > 80 && Carinfo[vehicleid][F] < 85) TextDrawSetString(vFuel[playerid], " ~g~~n~ll~n~~y~~h~lllll~y~~n~lllll~n~~r~lllll");
    if(Carinfo[vehicleid][F] > 75 && Carinfo[vehicleid][F] < 80) TextDrawSetString(vFuel[playerid], " ~g~~n~l~n~~y~~h~lllll~y~~n~lllll~n~~r~lllll");
    if(Carinfo[vehicleid][F] > 70 && Carinfo[vehicleid][F] < 75) TextDrawSetString(vFuel[playerid], " ~n~~n~~y~~h~lllll~y~~n~lllll~n~~r~lllll");
    if(Carinfo[vehicleid][F] > 65 && Carinfo[vehicleid][F] < 70) TextDrawSetString(vFuel[playerid], " ~n~~n~~y~~h~llll~y~~n~lllll~n~~r~lllll");
    if(Carinfo[vehicleid][F] > 60 && Carinfo[vehicleid][F] < 65) TextDrawSetString(vFuel[playerid], " ~n~~n~~y~~h~lll~y~~n~lllll~n~~r~lllll");
    if(Carinfo[vehicleid][F] > 55 && Carinfo[vehicleid][F] < 60) TextDrawSetString(vFuel[playerid], " ~n~~n~~y~~h~ll~y~~n~lllll~n~~r~lllll");
    if(Carinfo[vehicleid][F] > 50 && Carinfo[vehicleid][F] < 55) TextDrawSetString(vFuel[playerid], " ~n~~n~~y~~h~l~y~~n~lllll~n~~r~lllll");
    if(Carinfo[vehicleid][F] > 45 && Carinfo[vehicleid][F] < 50) TextDrawSetString(vFuel[playerid], " ~n~~n~~y~~n~lllll~n~~r~lllll");
    if(Carinfo[vehicleid][F] > 40 && Carinfo[vehicleid][F] < 45) TextDrawSetString(vFuel[playerid], " ~n~~n~~y~~n~llll~n~~r~lllll");
    if(Carinfo[vehicleid][F] > 35 && Carinfo[vehicleid][F] < 40) TextDrawSetString(vFuel[playerid], " ~n~~n~~y~~n~lll~n~~r~lllll");
    if(Carinfo[vehicleid][F] > 30 && Carinfo[vehicleid][F] < 35) TextDrawSetString(vFuel[playerid], " ~n~~n~~y~~n~ll~n~~r~lllll");
    if(Carinfo[vehicleid][F] > 25 && Carinfo[vehicleid][F] < 30) TextDrawSetString(vFuel[playerid], " ~n~~n~~y~~n~l~n~~r~lllll");
    if(Carinfo[vehicleid][F] > 20 && Carinfo[vehicleid][F] < 25) TextDrawSetString(vFuel[playerid], " ~n~~n~~n~~n~~r~lllll");
    if(Carinfo[vehicleid][F] > 15 && Carinfo[vehicleid][F] < 20) TextDrawSetString(vFuel[playerid], " ~n~~n~~n~~n~~r~llll");
    if(Carinfo[vehicleid][F] > 10 && Carinfo[vehicleid][F] < 15) TextDrawSetString(vFuel[playerid], " ~n~~n~~n~~n~~r~lll");
    if(Carinfo[vehicleid][F] > 5 && Carinfo[vehicleid][F] < 10) TextDrawSetString(vFuel[playerid], " ~n~~n~~n~~n~~r~ll");
    if(Carinfo[vehicleid][F] > 1 && Carinfo[vehicleid][F] < 5) TextDrawSetString(vFuel[playerid], " ~n~~n~~n~~n~~r~l");
    if(Carinfo[vehicleid][F] < 1) TextDrawSetString(vFuel[playerid], " ~n~~n~~n~~n~~r~|");
    return 1;
}
Reply
#2

Yes, this will only count for "playerid" otherwise.
Reply
#3

Well how should I add it? MAX_PLAYERS? or... anything else ?
Reply
#4

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
     FLower(i);
}
Reply
#5

Well thanks Rep for both of you
Reply
#6

Is that correct?

pawn Код:
public FLower(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        FLower(i);
    }
    new vehicleid = GetPlayerVehicleID(playerid);
    Carinfo[vehicleid][F] = Carinfo[vehicleid][F] - FUEL_DECREASE;
    TextDrawShowForPlayer(playerid, vFuel[playerid]);
    TextDrawShowForPlayer(playerid, Fuel[playerid]);
    if(Carinfo[vehicleid][F] < 1)
    {// rest of code...
Reply
#7

Okay, remove the entire callback and forward and timer from your script, and then add this at the bottom:

pawn Код:
forward FLower();
public FLower()
{
    new
        engine,
        lights,
        alarm,
        doors,
        bonnet,
        boot,
        objective,
        vehicleid;

    for (new i = 0, j = GetMaxPlayers(); i != j; i ++)
    {
        if (!IsPlayerConnected(i))
            continue;

        vehicleid = GetPlayerVehicleID(i);
        Carinfo[vehicleid][F] = Carinfo[vehicleid][F] - FUEL_DECREASE;
        TextDrawShowForPlayer(i, vFuel[i]);
        TextDrawShowForPlayer(i, Fuel[i]);

        if(Carinfo[vehicleid][F] < 1)
        {
            GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);

            Carinfo[vehicleid][F] = 0;
            KillTimer(GasTimer[i]);
            GameTextForPlayer(i, "~r~Vehicle is out of ~w~fuel~r~!", 5000, 5);
            TextDrawHideForPlayer(i, Veh[i]);
            TextDrawHideForPlayer(i, Gear[i]);
            TextDrawHideForPlayer(i, Speed[i]);
            TextDrawHideForPlayer(i, HP[i]);
            TextDrawHideForPlayer(i, vHP[i]);
            TextDrawHideForPlayer(i, vGear[i]);
            TextDrawHideForPlayer(i, vSpeed[i]);
            TextDrawHideForPlayer(i, vName[i]);
            TextDrawHideForPlayer(i, Fuel[i]);
            TextDrawHideForPlayer(i, vFuel[i]);
        }
        if(Carinfo[vehicleid][F] > 95) TextDrawSetString(vFuel[i]," ~g~~n~lllll~n~~y~~h~lllll~y~~n~lllll~n~~r~lllll");
        if(Carinfo[vehicleid][F] > 90 && Carinfo[vehicleid][F] < 95) TextDrawSetString(vFuel[i], " ~g~~n~llll~n~~y~~h~lllll~y~~n~lllll~n~~r~lllll");
        if(Carinfo[vehicleid][F] > 85 && Carinfo[vehicleid][F] < 90) TextDrawSetString(vFuel[i], " ~g~~n~lll~n~~y~~h~lllll~y~~n~lllll~n~~r~lllll");
        if(Carinfo[vehicleid][F] > 80 && Carinfo[vehicleid][F] < 85) TextDrawSetString(vFuel[i], " ~g~~n~ll~n~~y~~h~lllll~y~~n~lllll~n~~r~lllll");
        if(Carinfo[vehicleid][F] > 75 && Carinfo[vehicleid][F] < 80) TextDrawSetString(vFuel[i], " ~g~~n~l~n~~y~~h~lllll~y~~n~lllll~n~~r~lllll");
        if(Carinfo[vehicleid][F] > 70 && Carinfo[vehicleid][F] < 75) TextDrawSetString(vFuel[i], " ~n~~n~~y~~h~lllll~y~~n~lllll~n~~r~lllll");
        if(Carinfo[vehicleid][F] > 65 && Carinfo[vehicleid][F] < 70) TextDrawSetString(vFuel[i], " ~n~~n~~y~~h~llll~y~~n~lllll~n~~r~lllll");
        if(Carinfo[vehicleid][F] > 60 && Carinfo[vehicleid][F] < 65) TextDrawSetString(vFuel[i], " ~n~~n~~y~~h~lll~y~~n~lllll~n~~r~lllll");
        if(Carinfo[vehicleid][F] > 55 && Carinfo[vehicleid][F] < 60) TextDrawSetString(vFuel[i], " ~n~~n~~y~~h~ll~y~~n~lllll~n~~r~lllll");
        if(Carinfo[vehicleid][F] > 50 && Carinfo[vehicleid][F] < 55) TextDrawSetString(vFuel[i], " ~n~~n~~y~~h~l~y~~n~lllll~n~~r~lllll");
        if(Carinfo[vehicleid][F] > 45 && Carinfo[vehicleid][F] < 50) TextDrawSetString(vFuel[i], " ~n~~n~~y~~n~lllll~n~~r~lllll");
        if(Carinfo[vehicleid][F] > 40 && Carinfo[vehicleid][F] < 45) TextDrawSetString(vFuel[i], " ~n~~n~~y~~n~llll~n~~r~lllll");
        if(Carinfo[vehicleid][F] > 35 && Carinfo[vehicleid][F] < 40) TextDrawSetString(vFuel[i], " ~n~~n~~y~~n~lll~n~~r~lllll");
        if(Carinfo[vehicleid][F] > 30 && Carinfo[vehicleid][F] < 35) TextDrawSetString(vFuel[i], " ~n~~n~~y~~n~ll~n~~r~lllll");
        if(Carinfo[vehicleid][F] > 25 && Carinfo[vehicleid][F] < 30) TextDrawSetString(vFuel[i], " ~n~~n~~y~~n~l~n~~r~lllll");
        if(Carinfo[vehicleid][F] > 20 && Carinfo[vehicleid][F] < 25) TextDrawSetString(vFuel[i], " ~n~~n~~n~~n~~r~lllll");
        if(Carinfo[vehicleid][F] > 15 && Carinfo[vehicleid][F] < 20) TextDrawSetString(vFuel[i], " ~n~~n~~n~~n~~r~llll");
        if(Carinfo[vehicleid][F] > 10 && Carinfo[vehicleid][F] < 15) TextDrawSetString(vFuel[i], " ~n~~n~~n~~n~~r~lll");
        if(Carinfo[vehicleid][F] > 5 && Carinfo[vehicleid][F] < 10) TextDrawSetString(vFuel[i], " ~n~~n~~n~~n~~r~ll");
        if(Carinfo[vehicleid][F] > 1 && Carinfo[vehicleid][F] < 5) TextDrawSetString(vFuel[i], " ~n~~n~~n~~n~~r~l");
        if(Carinfo[vehicleid][F] < 1) TextDrawSetString(vFuel[i], " ~n~~n~~n~~n~~r~|");
    }
    return 1;
}
And under OnGameModeInit:

pawn Код:
// Every 60 seconds.
SetTimer("FLower", 60000, true);
Reply
#8

Thank you but one more question about SetTimer on callback OnGameModeInit I changed to your code but I'm using this cmd to start timer to lower fuel...

pawn Код:
if(strcmp(cmdtext, "/engine", true) == 0) {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}You need to be in vehicle to use this command.");
        if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}You need to be driver to use this command.");
        if(Carinfo[vehicleid][F] < 1) return SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}This vehicle is out of fuel.");
        if(ES[playerid] == 1) return SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}You are already starting your engine.");
        if(engine == 1) {
            KillTimer(GasTimer[playerid]);
            SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
            SendClientMessage(playerid, COLOR_PURPLE,"{00FF00}INFO: {FFFFFF}Engine turned off.");
            TextDrawHideForPlayer(playerid, vName[playerid]);
            TextDrawHideForPlayer(playerid, vSpeed[playerid]);
            TextDrawHideForPlayer(playerid, vGear[playerid]);
            TextDrawHideForPlayer(playerid, vHP[playerid]);
            TextDrawHideForPlayer(playerid, vFuel[playerid]);
            TextDrawHideForPlayer(playerid, HP[playerid]);
            TextDrawHideForPlayer(playerid, Speed[playerid]);
            TextDrawHideForPlayer(playerid, Gear[playerid]);
            TextDrawHideForPlayer(playerid, Veh[playerid]);
            TextDrawHideForPlayer(playerid, Fuel[playerid]);
            return 1;
        } else {
            SendClientMessage(playerid, COLOR_PURPLE,"{00FF00}INFO: {FFFFFF}You twisted the key, wait 4 seconds.");
            ES[playerid] = 1;
            SetTimerEx("EngStart", 4000, false, "d", playerid);
            return 1;
        }
    }
And than..

pawn Код:
public EngStart(playerid)
{
    new vname[50];
    // This will help us to detect vehicle HP
    new Float:vehHP, vehicleid = GetPlayerVehicleID(playerid);
    GetVehicleHealth(vehicleid, vehHP);
    new engine,lights,alarm,doors,bonnet,boot,objective;
    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
   
    // If vehicle HP is 550 or more it will turn it's engine on 100%
    if(vehHP >= 550)
    {
        SendClientMessage(playerid, COLOR_YELLOW,"{00FF00}INFO: {FFFFFF}Engine is succesfully started, write {FF6A22}/engine {FFFFFF}to turn off engine.");
        ES[playerid] = 0;
        SetVehicleParamsEx(vehicleid,1,lights,alarm,doors,bonnet,boot,objective);
        GasTimer[playerid] = SetTimerEx("FLower", 1000, true, "i", playerid);
        format(vname, sizeof(vname), "%s", Vehicles[GetVehicleModel(GetPlayerVehicleID(playerid)) - 400]);
        TextDrawSetString(vName[playerid], vname);
        TextDrawShowForPlayer(playerid, vName[playerid]);
        TextDrawShowForPlayer(playerid, vSpeed[playerid]);
        TextDrawShowForPlayer(playerid, vGear[playerid]);
        TextDrawShowForPlayer(playerid, vHP[playerid]);
        TextDrawShowForPlayer(playerid, vFuel[playerid]);
        TextDrawShowForPlayer(playerid, HP[playerid]);
        TextDrawShowForPlayer(playerid, Speed[playerid]);
        TextDrawShowForPlayer(playerid, Gear[playerid]);
        TextDrawShowForPlayer(playerid, Veh[playerid]);
        TextDrawShowForPlayer(playerid, Fuel[playerid]);
GasTimer = SetTimerEx.... (I have 1000 ms cuz I'm testing the script so my fuel goes down faster..)
Should I change GasTimer = SetTimerEx to GasTimer = SetTimer() cuz I don't have any params at "public FLower()" now ...?
Reply
#9

Please guys
Reply
#10

If there isn't any parameters at callback should I use SetTimer or SetTimerEx to call that callback?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)