SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 15/04/2012, 12:05 PM   #1
HondaCBR
Huge Clucker
 
Join Date: Apr 2011
Posts: 286
Reputation: 0
Default Fuel[i] -= 1; (Insted of taking 1, takes all fuel)

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 Code:
SetTimer("GasUpdate", 5000, 1);

//function
pawn Code:
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 Code:
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;
            }
HondaCBR is offline   Reply With Quote
Old 15/04/2012, 12:10 PM   #2
IceCube!
High-roller
 
IceCube!'s Avatar
 
Join Date: Aug 2011
Location: Grove Street, Home; Atleast it was before I fucked everything up. Motto: Carpe Diem, Bitch!
Posts: 1,777
Reputation: 230
Default Re: Fuel[i] -= 1; (Insted of taking 1, takes all fuel)

[pawn]
pawn Code:
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
__________________

Image by Phyzic
Projects (28/01/2017)
Skype: Hewlett_T
None.I'm dead, honest!
IceCube! is offline   Reply With Quote
Old 15/04/2012, 01:03 PM   #3
HondaCBR
Huge Clucker
 
Join Date: Apr 2011
Posts: 286
Reputation: 0
Default Re: Fuel[i] -= 1; (Insted of taking 1, takes all fuel)

Thx, but now the fuel goes to like 139218321
HondaCBR is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fuel Nonameman Help Archive 3 05/08/2010 10:16 PM
How to add fuel per second? lmfaoown Help Archive 13 07/03/2010 04:36 PM
[HELP] fuel Mobst3r111 Help Archive 0 26/05/2009 06:44 PM
Fuel help nuninho13 Help Archive 16 10/03/2009 05:29 PM


All times are GMT. The time now is 06:26 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.