Any reason why SetVehicleRespawn could become ridiclously slow?
#1

My vehicle pool is 1475.

pawn Код:
respawnAllVehicles()
{
    new bool:vehicleActivityStatus[MAX_VEHICLES] = {false, ...}, pCurVehicleID = INVALID_VEHICLE_ID;
    foreach(new i : Character)
    {
        if(playerData[i][pCurrentVehicleDrivenID] != INVALID_VEHICLE_ID) {
            pCurVehicleID = playerData[i][pCurrentVehicleDrivenID];
        }
        else if(IsPlayerInAnyVehicle(i)) {
            pCurVehicleID = GetPlayerVehicleID(i);
        }
        if(pCurVehicleID != INVALID_VEHICLE_ID) {
            vehicleActivityStatus[pCurVehicleID] = true;
            if(IsTrailerAttachedToVehicle(pCurVehicleID)) {
                vehicleActivityStatus[GetVehicleTrailer(pCurVehicleID)] = true;
            }
        }
        pCurVehicleID = INVALID_VEHICLE_ID;
    }
    for(new i = 0, j = GetVehiclePoolSize(); i < j; i++) {
        if(IsValidVehicle(i) && vehicleActivityStatus[i] == false) {
            SetVehicleToRespawn(i);
        }
    }
    return;
}
This command takes 15 seconds to execute on my home host, and a few on linux.

I recently added IsValidVehicle(i), that IS NOT slowing it down.

If you remove SetVehicleToRespawn, the loop takes 0 ms. But when you add SetVehicleToRespawn.. idk whats happening man.

This guy complained about the same issue https://sampforum.blast.hk/showthread.php?tid=575688.
Reply
#2

I'm not sure, but i usually do respawn ~400 vehicles once smoothly, do you have any kind of heavy stuff under onvehiclespawn?
Reply
#3

Wow I think thats it. I didn't even think about that.

Thank you.

Lol this can be trashed!
Reply
#4

Or it can stay here for others that may experience this.
Reply
#5

Don't set number plates under OnVehicleSpawn.

I realized that once you set a number plate on creation, you don't have to set it again when it respawns / dies. I thought so, but I didn't know.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)