17.09.2016, 11:32
Quote:
First optimization is your loop, it's calling GetVehiclePoolSize at every iteration.
And a little (mistake or it's mean't to be like that?), it will respawn also used vehicles which will be annoying to players. PHP Code:
|
This is better?
PHP Code:
PUBLIC:AllVehicleRespawn()
{
if(TimeRespawn - gettime() > 13)
{
ServeurAnnonce(_, "15 secondes avant le respawn de tous les vйhicules.");
SetTimer("AllVehicleRespawn", 5000, false);
return 1;
}
else if(TimeRespawn - gettime() > 9)
{
ServeurAnnonce(_, "10 secondes avant le respawn de tous les vйhicules.");
SetTimer("AllVehicleRespawn", 5000, false);
return 1;
}
else if(TimeRespawn - gettime() > 4)
{
ServeurAnnonce(_, "5 secondes avant le respawn de tous les vйhicules.");
SetTimer("AllVehicleRespawn", 5000, false);
return 1;
}
ServeurAnnonce(_, "Tous les vйhicules ont йtй respawn par un administrateur.");
for(new i, j = GetVehiclePoolSize(); i <= j; i++)
{
if(GetVehicleDriver(i) == INVALID_PLAYER_ID) SetVehicleToRespawn(i);
}
return 1;
}
GetVehicleDriver(vehicleid)
{
foreach(new i : Player)
{
if(GetPlayerVehicleID(i) == vehicleid) return i;
}
return INVALID_PLAYER_ID;
}