25.07.2020, 14:49
Quote:
What would be the most efficient way of removing dynamic objects attached to a vehicle, for ANY vehicle?
I've got more than 10,000 objects easily in my server, so a loop is not ideal... The only "true" way to consider all objects is by hooking CreateObject, storing the value in a variable and then looping through it, using Streamer_GetIntData to match the vehicle ID and then remove it however considering the amount of objects I have this would end up being very laggy and bad for server performance... Any alternatives? |
PHP Code:
new AttachedObjects[MAX_VEHICLES][100];
hook AttachObjectToVehicle()
{
new free_slot;
for (free_slot = 0; free_slot < sizeof AttachedObjects[vehicled]; free_slot++)
if (AttachedObjects[vehicled][free_slot] == 0) break;
AttachedObjects[vehicleid][free_slot] = objectid;
}
DestroyObjectsAttachedToVehicle(vehicleid)
{
for (new i; i < sizeof AttachedObjects[vehicleid]; i++)
DestroyObject(AttachedObjects[vehicleid][i])
}