respawn a detachted trailer?
#9

If the array stores only the trailer IDs in sequence, then:
pawn Код:
const TruckTrailer_size = sizeof TruckTrailer;
new bool: attached_trailers[TruckTrailer_size char], trailer_id, last_vehicleid = TruckTrailer[TruckTrailer_size - 1];

for (new vehicleid = 1, j = GetVehiclePoolSize(); vehicleid <= j; vehicleid++)
{
    if (!(trailer_id = GetVehicleTrailer(vehicleid))) continue;
    if (!(TruckTrailer[0] <= trailer_id <= last_vehicleid)) continue;

    attached_trailers{TruckTrailer_size - (last_vehicleid - trailer_id) - 1} = true;
}

for (new i; i != TruckTrailer_size; i++)
{
    if (!attached_trailers{i}) SetVehicleToRespawn(TruckTrailer[i]);
}
and you'll avoid the 2 loops that go through 24000 iterations in total.
Reply


Messages In This Thread
respawn a detachted trailer? - by rOps - 19.12.2016, 19:37
Re: respawn a detachted trailer? - by Konstantinos - 19.12.2016, 20:06
Re: respawn a detachted trailer? - by rOps - 19.12.2016, 20:09
Re: respawn a detachted trailer? - by Konstantinos - 19.12.2016, 20:10
Re: respawn a detachted trailer? - by Mutha_X - 19.12.2016, 20:13
Re: respawn a detachted trailer? - by rOps - 19.12.2016, 20:20
Re: respawn a detachted trailer? - by Mutha_X - 19.12.2016, 20:26
Re: respawn a detachted trailer? - by rOps - 19.12.2016, 20:31
Re: respawn a detachted trailer? - by Konstantinos - 19.12.2016, 20:42
Re: respawn a detachted trailer? - by rOps - 19.12.2016, 20:51

Forum Jump:


Users browsing this thread: 1 Guest(s)