Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server-side knowledge of players in zones #12

Closed
mkafrin opened this issue Jul 11, 2020 · 5 comments
Closed

Server-side knowledge of players in zones #12

mkafrin opened this issue Jul 11, 2020 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@mkafrin
Copy link
Owner

mkafrin commented Jul 11, 2020

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

  • Whenever a player enter or leaves a zone, an event should be sent to the server with the zone (probably by name) and it'll keep a dict of zones to list of players inside of it.
  • Add an export or event on the server where you put in a zone and a function and it will run that function once for everyone in the zone.
  • Add an export to set an event-based callback that will run whenever the players inside a zone changes

Alternative:

  • Add a function to zones called "AddTrigger(triggerName, triggerCallback)"
    • This will create an event handler for the triggername which calls the triggercallback if the player is inside the zone
  • Add a RPC or event server-side called "PolyZone:TriggerZoneEvent"(triggerName) or something similar
    • This event will send the trigger event to all clients and then the event handler on the client will do the rest
@mkafrin mkafrin added the enhancement New feature or request label Jul 11, 2020
@mkafrin mkafrin self-assigned this Jul 11, 2020
@mkafrin
Copy link
Owner Author

mkafrin commented Sep 26, 2020

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

@mkafrin
Copy link
Owner Author

mkafrin commented Dec 20, 2020

Alternative implemented in 24931b1

@mkafrin mkafrin closed this as completed Dec 20, 2020
@mkafrin
Copy link
Owner Author

mkafrin commented Dec 20, 2020

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 mkafrin reopened this Dec 20, 2020
@mkafrin
Copy link
Owner Author

mkafrin commented Dec 20, 2020

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
Copy link
Owner Author

mkafrin commented Dec 21, 2020

Implemented in 1c0c3fc and 7063fd5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant