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
202 stars 193 forks source link

Server-side knowledge of players in zones #12

Closed mkafrin closed 3 years ago

mkafrin commented 4 years ago

The server should know what players are in what zones so events can be sent to everyone in or outside of a zone.

Alternative:

mkafrin commented 4 years ago

Will need to add the ability to broadcast to server to create or destroy a zone on everyone's client.

mkafrin commented 3 years ago

Alternative implemented in 24931b1d8b061f0655168aec041f67083456d334

mkafrin commented 3 years ago

Re-opening for following question:

Can this be made better for ComboZones? Maybe someone wants an event tied to a particular zone inside a ComboZone, instead of the whole thing. Can addEvent on ComboZones take an optional zoneName param and then it will call isPointInsideExhaustive() and loop through the returned zones to see if one of the zones' name matches the zoneName param.

mkafrin commented 3 years ago

Should this use events all the way instead of callbacks? Meaning instead of passing a callback to addEvent and an event with that name being created on the zone, instead a generically named event (or named based on the zone somehow) is created and called from server-side, then in the event-handler, if the player is in the zone, it then triggers the event with the eventName passed to addEvent.

For example, the event you create on the zone can be like "__PolyZone__:{eventName}" and then if the player is in the zone, it triggers the "eventName" event.

mkafrin commented 3 years ago

Implemented in 1c0c3fced3948ba2245ed4455eb2f7f99c4ca201 and 7063fd57a5f55b31294b0a6826059a267eec8dfe