mkafrin / PolyZone

PolyZone is a FiveM mod to define zones of different shapes and test whether a point is inside or outside of the zone
MIT License
204 stars 191 forks source link

(Not an Issue) No Vehicles Spawning In Zone #59

Closed ItsNapp closed 2 years ago

ItsNapp commented 2 years ago

Is there a way I can make it so No Vehicles are able to spawn in a specific zone that I set?

mkafrin commented 2 years ago

@NappTheDev Hmm, this is a tough one due to current limitations running PolyZone server-side. There is the entityCreating event on the server (docs here https://docs.fivem.net/docs/scripting-reference/events/server-events) that can be cancelled to instantly delete the entity. Testing whether the entity is a vehicle and is in a zone, and if so cancelling the event would work, but PolyZone isn't officially supported server-side as of now. You could try using it for this and see if you run into any errors, but it's not officially supported.

A possible client-side solution would be to use GetGamePool (https://docs.fivem.net/natives/?_0x2B9D4F50) to iterate over all CVehicle and if any are in the zone, call DeleteEntity on them. But that'd be pretty expensive and prone to issues like flickering.

Not sure if there's a great solution for this unless the first one works without any issues popping up.