Timer Big Problem ! Fuel
#1

Hello guys. I have a timer setted at 20 seconds, to check the fuel for vehicles with driver.
pawn Код:
// Top Of Script
forward CheckGas();

// OnGameModeInit
T_Timer[T_CheckGas] = SetTimer("CheckGas", 20000, true);

// OnGameModeExit
KillTimer(T_Timer[T_CheckGas]);

// OnPlayerStateChange
if((oldstate == PLAYER_STATE_ONFOOT) && (newstate == PLAYER_STATE_DRIVER))
{
    CheckGas();
}

// Public Function
public CheckGas()
{
    new vehicle;
    foreach(Player, i)
    {
        if(GetPlayerState(i) == PLAYER_STATE_DRIVER && (vehicle = GetPlayerVehicleID(i)))
        {
            if(IsAPlane(vehicle) || IsABoat(vehicle) || IsAShamal(vehicle) || IsAPoliceCar(vehicle) || IsAnAmbulance(vehicle) || VehiclesWithoutFuel(vehicle) || IsABike(vehicle) || StopEngine[i])
            {
                continue;
            }
            if(Gas[vehicle] >= 1)
            {
                if(Gas[vehicle] <= 10)
                {
                    PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0);
                }
                Gas[vehicle]--;
            }
            else
            {
                NoFuel[i] = true;
                TogglePlayerControllable(i, 0);
                GameTextForPlayer(i,"No More Fuel !", 2800, 3);
            }
        }
    }
    return 1;
}
At 1 player, it works ok.
Код:
0 ms
22545 ms
44807 ms
67015 ms
88295 ms
110166 ms
132162 ms
153928 ms
175282 ms
197225 ms
218785 ms
240508 ms
262268 ms
283859 ms
305173 ms
326547 ms
348476 ms
370254 ms
392577 ms
414271 ms
436030 ms
457487 ms
478941 ms
500810 ms
522291 ms
543695 ms
565660 ms
But at more players ( 20, 50, 100, 200 ), look:
Код:
1 ms
1712 ms
3670 ms
14553 ms
19132 ms
20031 ms
21971 ms
25299 ms
27042 ms
29597 ms
29908 ms
33996 ms
34577 ms
35830 ms
36506 ms
39003 ms
39997 ms
40348 ms
46131 ms
47074 ms
47297 ms
pawn Код:
0 ms
1037 ms
1330 ms
1394 ms
1525 ms
1655 ms
2675 ms
3796 ms
4892 ms
0 ms
433 ms
815 ms
1182 ms
1346 ms
2632 ms
3713 ms
3786 ms
3843 ms
3902 ms
4054 ms
4308 ms
5757 ms
7152 ms
7517 ms
Why !?
Reply
#2

Код:
if(GetPlayerState(i) == PLAYER_STATE_DRIVER && (vehicle = GetPlayerVehicleID(i)))
maybe u put only one " = " after vehicle? or is that on purpose ? lol
Reply
#3

no no, that's ok ...
Reply
#4

anybody else ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)