Closed zpl-zak closed 9 months ago
I wonder if this shouldn't be done automatically by the server rather than the scripter? (same for npcs, objects, etc)
What's the benefit?
Server does not know which entities were spawned by the gamemode itself. Most of the logic is handled by Framework, so the world engine does not know how to distinguish gamemode-related entities. It would require us to signal mod-level layer back so mod would get a chance to despawn specific entities.
It is just simpler to track all gamemode-created entities within the script itself.
EDIT: It might change in the future, but such a rework would be low priority for now, so this is a better solution for now.
Put on hold, different solution will be implemented.
Problem
Upon gamemode reload, we spawn new batch of parked vehicles, however we do not despawn existing ones yet.
Solution
Leverage
gamemodeUnloading
event to despawn all parked vehicles in our sample gamemode script.Call
car.destruct()
to remove entity.