2 questions
#1

Hi guys, how's it going?

Recently with some tests I noticed that my fuel system only works on first vehicle on server. It won't decrease on any other vehicle. I will gladly put all codes necessary.

pawn Код:
#undef MAX_VEHICLES
#define MAX_VEHICLES 500
public FuelAndSync()
{
    for(new i = 1; i <= MAX_VEHICLES; i++)
    {
        if (IsValidVehicle(i))
        {
            if(!IsABicikl(i)) // is not a bicycle
            {

                    if(VehInfo[i][Motor] == false) return 1; // engine
                    if(VehInfo[i][Gorivo] >= 0.60) // fuel
                    {
                        if(IsATruck(i)) { VehInfo[i][Gorivo] -= 0.40; }
                        else if(IsAOldCar(i)) { VehInfo[i][Gorivo] -= 0.40; } //
                                                 // ....
                    }
                    else
                    {
                        ToggleVehicleEngine(i);
                        VehInfo[i][Motor] = false;
                        VehInfo[i][NemaGoriva] = true;
                       
                        foreach (Player, j)
                        {
                            if(IsPlayerInVehicle(j, i) && GetPlayerState(j) == PLAYER_STATE_DRIVER)
                            {
                                SCM(j, COLOR_LIGHTRED, "Ostali ste bez goriva!");
                               
                            }
                        }
                    }
            }
        }
    }
And also I am wondering why my fuel shows e.g. 3.59 L when it should 3.60? Do I need to round it?
Reply
#2

Try changing this:
pawn Код:
for(new i = 0; i < MAX_VEHICLES; i++)
Reply
#3

Quote:
Originally Posted by Sid_Alexander
Посмотреть сообщение
Try changing this:
pawn Код:
for(new i = 0; i < MAX_VEHICLES; i++)
Vehicle IDs start from 1 so there is no need for putting 0 here.

P.S. I already had it that way and big NOPE
Reply
#4

Can somebody help me before I go on a trip?
Reply
#5

Change return 1; to continue;
Reply
#6

Return at the engine false part?
Reply
#7

Yes because it stops other ids after id 0
Reply
#8

Okay, thank you very much. Wouldn't want to bother you any longer but do you know maybe why my float looks like 3.59 and not 3.60? 4.00 - 0.40...

Edited pardon
Reply
#9

Have to say this:

pawn Код:
for(new i =0; i < MAX_VEHICLES; i++)
That loops through ALL vehicles...

Why not use foreach?

pawn Код:
foreach(Player, pid)
{
    switch(GetPlayerState(pid))
    {
        case PLAYER_STATE_DRIVER
        {
             new vid = GetPlayerVehicleID(pid);
             //lower the fuel...
        }
    }
}
If you want to round stuff, use floatround
Reply
#10

Quote:
Originally Posted by Sime30
Посмотреть сообщение
Okay, thank you very much. Wouldn't want to bother you any longer but do you know maybe why my float looks like 3.59 and not 3.60? 4.00 - 0.40...

Edited pardon
Try this
0.4 or 0.400001 or 0.40001
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)