[HELP] Question about command fillallcars
#1

So I have that command and in command I haave the code which set fuel by type of vehicle like trucks etc

pawn Код:
for(new o; o < MAX_CARS; o++)
        {
            if(IsATruck(GetVehicleModel(o))) Fuel[o] = 100.00;
            else if(IsABus(GetVehicleModel(o))) Fuel[o] = 80.00;
            else if(IsAMotocycle(GetVehicleModel(o))) Fuel[o] = 15.00;
            else Fuel[o] = 40.00;
        }
so that code work after minute or maybe less the fuel textdraw is updated so I want when I fuel the all cars the textdraw is updated when I type the command So in that code above I add likee this


pawn Код:
for(new o; o < MAX_CARS; o++)
        {
foreach(Player,i)
    {
            if(IsATruck(GetVehicleModel(o))) Fuel[o] = 100.00;
            else if(IsABus(GetVehicleModel(o))) Fuel[o] = 80.00;
            else if(IsAMotocycle(GetVehicleModel(o))) Fuel[o] = 15.00;
            else Fuel[o] = 40.00;
new string[64];
            format(string,sizeof string,"%.1fl",Fuel[o]);
            TextDrawSetString(Speedometar0[i],string);
            TextDrawShowForPlayer(i,Speedometar0[i]);
    }
}
Reply
#2

any anyone? thanks
Reply
#3

Wrong foreach usage. You should use foreach(i,Player)
Reply
#4

pawn Код:
for(new o = 0; o < MAX_CARS; o++)
{
    if(IsATruck(GetVehicleModel(o))) Fuel[o] = 100.00;
    else if(IsABus(GetVehicleModel(o))) Fuel[o] = 80.00;
    else if(IsAMotocycle(GetVehicleModel(o))) Fuel[o] = 15.00;
    else Fuel[o] = 40.00;
    new string[64];
    foreach(Player,i) // i think this works, but i'd use foreach(i : Player) instead
    { //you may want to add another check to make sure player "i" is inside vehicle "o", maybe driving it
        format(string,sizeof(string),"%.1fl",Fuel[o]);
        TextDrawSetString(Speedometar0[i],string);
        TextDrawShowForPlayer(i,Speedometar0[i]); //if the player is already seeing the textdraw, you don't have to show it to him again
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)