Fuel[i] -= 1; (Insted of taking 1, takes all fuel) - 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: Fuel[i] -= 1; (Insted of taking 1, takes all fuel) (
/showthread.php?tid=334611)
Fuel[i] -= 1; (Insted of taking 1, takes all fuel) -
HondaCBR - 15.04.2012
When you enter the car the fuel is 100, but 5s after you start the engine it goes down to 0 insted of [98/99]
//gamemodeini
pawn Код:
SetTimer("GasUpdate", 5000, 1);
//function
pawn Код:
public GasUpdate()
{
for(new d=0;d<MAX_PLAYERS;d++)
for(new i=0;i<CAR_AMOUNT;i++)
{
GetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,boot,objective);
if(engine==1)
{
if(Gas[i] > 0)
{
new Float:Velocity[3];
GetVehicleVelocity(i, Velocity[0], Velocity[1], Velocity[2]);
if(Velocity[0] <= 1 && Velocity[1] <= 1 && Velocity[2] <= 1)
{
Gas[i] -= 1;
}
else
{
Gas[i] -= 2;
}
}
else
{
SetVehicleParamsEx(i,0,lights,alarm,doors,bonnet,boot,objective);
if(IsPlayerInVehicle(d,i))
{
}
}
}
}
}
//spawning a car using /va
pawn Код:
CarAdmin = CreateVehicle(vehicle, x, y, z, a+90, -1, -1, -1);
LinkVehicleToInterior(CarAdmin, GetPlayerInterior(playerid));
new VehicleModel = GetVehicleModel(CarAdmin);
if( VehicleModel == 509 || VehicleModel == 481 || VehicleModel == 510 )// Bikes
{
SetVehicleParamsEx(CarAdmin,1,0,0,0,0,0,0);
Gas[CarAdmin] = 100;
}
else
{
SetVehicleParamsEx(CarAdmin,0,0,0,0,0,0,0);
Gas[CarAdmin] = 100;
}
Re: Fuel[i] -= 1; (Insted of taking 1, takes all fuel) -
IceCube! - 15.04.2012
[pawn]
pawn Код:
public GasUpdate()
{
for(new i=0;i<CAR_AMOUNT;i++)
{
GetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,boot,objective);
if(engine==1)
{
if(Gas[i] > 0)
{
new Float:Velocity[3];
GetVehicleVelocity(i, Velocity[0], Velocity[1], Velocity[2]);
if(Velocity[0] <= 1 && Velocity[1] <= 1 && Velocity[2] <= 1)
{
Gas[i] -= 1;
}
else
{
Gas[i] -= 2;
}
}
else
{
SetVehicleParamsEx(i,0,lights,alarm,doors,bonnet,boot,objective);
if(IsPlayerInVehicle(d,i))
{
}
}
}
}
}
YOu were loopong through car amunt 500 times meaning each car had atleast -400 fuel
Re: Fuel[i] -= 1; (Insted of taking 1, takes all fuel) -
HondaCBR - 15.04.2012
Thx, but now the fuel goes to like 139218321