[HELP] Please help setting fuel [REP +]
#1

Hello I have a fuel system where I set the fuel depend of type vehicle trucks are 100 L buses are 80 and bikes like nrg freeway are 15.0L and I sit in truck and it should set 100 L but it's set to 40 L

I defined Fuel as

pawn Код:
new Float:Fuel[MAX_VEHICLES];
so under ongamemodeinit I have

pawn Код:
for(new o = 0; o < MAX_VEHICLES; o++)
    {
        if(IsATruck(GetVehicleModel(o))) Fuel[o] = 100.00;
        else if(IsABus(GetVehicleModel(o))) Fuel[o] = 80.00;
        else if(IsABike(GetVehicleModel(o))) Fuel[o] = 15.00;
        else Fuel[o] = 40.00;
    }
then stocks

pawn Код:
stock IsATruck(vehicleid)
{
    switch(GetVehicleModel(vehicleid))
    {
        case 403,406,407,408,414,427,428,443,455,456,498,514,515,524,544,573,578,609: return 1;
    }
    return 0;
}
stock IsABus(id)
{
    if(id == 431 || id == 437) return 1;
    return 0;
}
stock IsABike(id)
{
    if(id == 448 || id == 461 || id == 462 || id == 463 || id == 468 || id == 471 || id == 521 || id == 522 || id == 581 || id == 586) return 1;
    return 0;
}
Reply
#2

Try remove
pawn Код:
else Fuel[o] = 40.00;
Reply
#3

pawn Код:
for(new vehicleid = 1, ValidModel; vehicleid < MAX_VEHICLES; vehicleid++)
{
    ValidModel = GetVehicleModel(vehicleid);
    if(ValidModel > 0)
    {
        if(IsATruck(vehicleid)) Fuel[vehicleid] = 100.00; // here must be vehicleid not model (IsATruck(vehicleid)) because you got in stock switch(GetVehicleModel(vehicleid))
        else if(IsABus(ValidModel)) Fuel[vehicleid] = 80.00;
        else if(IsABike(ValidModel)) Fuel[vehicleid] = 15.00;
        else Fuel[vehicleid] = 40.00;
    }
}
Reply
#4

Use the vehicle's ID, not the model id.
pawn Код:
if(IsATruck(o)) Fuel[o] = 100.00;
else if(IsABus(o)) Fuel[o] = 80.00;
else if(IsABike(o)) Fuel[o] = 15.00;
Like this.
You were trying to pass on the model id as the vehicle id, which would just be the same as:
pawn Код:
GetVehicleModel(GetVehicleModel(vehicleid))
Which wont work.
Reply
#5

So I try to use Jeff's code but the problem is I enter in the truck and the fuel is 0.0

edit I try like this but know I sit in truck or a bike and the fuel is 40.0. Thanks

pawn Код:
for(new vehicleid = 1; vehicleid < MAX_VEHICLES; vehicleid++)
    {
        if(IsATruck(vehicleid)) Fuel[vehicleid] = 100.00;
        else if(IsABus(vehicleid)) Fuel[vehicleid] = 80.00;
        else if(IsABike(vehicleid)) Fuel[vehicleid] = 15.00;
        else Fuel[vehicleid] = 40.00;
    }
Thanks
Reply
#6

You need use this after created vehicles in OnGameModeInit
Reply
#7

In OnGameModeInt type return 1; and try the code
Reply
#8

Quote:
Originally Posted by fuckingcruse
Посмотреть сообщение
In OnGameModeInt type return 1; and try the code
What does returning 1 have to do with this?
Reply
#9

Jeff like you said I put this code under all created vehicles and it turns out that code work the just the way I want. I have one more question how can set this types of fuel in command where I create event vehicles /ecreate if you know what I mean. Thanks

Also I want to thank CalvinC for repyling and helping. Thank you.
Reply
#10

in /ecreate
pawn Код:
new vehicle = CreateVehicle(...);
new Model = GetVehicleModel(vehicle);

if(IsATruck(vehicle)) Fuel[vehicle] = 100.00;
else if(IsABus(Model)) Fuel[vehicle] = 80.00;
else if(IsABike(Model)) Fuel[vehicle] = 15.00;
else Fuel[vehicle] = 40.00;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)