[HELP] Question about command fillallcars - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP] Question about command fillallcars (
/showthread.php?tid=532977)
[HELP] Question about command fillallcars -
Luca12 - 21.08.2014
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]);
}
}
Re: [HELP] Question about command fillallcars -
Luca12 - 22.08.2014
any anyone? thanks
Re: [HELP] Question about command fillallcars -
BuLLeT[LTU] - 22.08.2014
Wrong foreach usage. You should use foreach(i,Player)
Re: [HELP] Question about command fillallcars -
HazardouS - 22.08.2014
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
}
}