MafiaHub / MafiaMP

Multiplayer experience for Mafia: Definitive Edition
https://mafiahub.dev
Other
42 stars 5 forks source link

Car duplication on gamemode reload #38

Closed zpl-zak closed 9 months ago

zpl-zak commented 9 months ago

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.

Deewarz commented 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?

zpl-zak commented 9 months ago

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.

zpl-zak commented 9 months ago

Put on hold, different solution will be implemented.