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

refactor!(esx_service) #7

Merged
merged 8 commits into from
Nov 13, 2024
Merged

Conversation

Kenshiin13
Copy link

@Kenshiin13 Kenshiin13 commented Nov 10, 2024

Description:

This PR improves the management of in-service players, integrates better structure for service handling, and enhances security and data integrity all-around.


Key Changes:

  • Service Structure Refactor:

    • The service management system has been encapsulated within a Service class, offering better abstraction and organization.
    • Services are now managed in a centralized services table, with each service having its own methods for adding/removing players, counting players, and sending notifications.
  • Job Duty Management:

    • A new function, setPlayerJobDuty, has been introduced to set players' job duty status when they join/leave a service.
    • This ensures that job duty is reflected in sync with service participation, eliminating the need for duplicated job duty checks in different parts of the code.
  • On-Duty Consistency Across MaxPlayers Limit:

    • All players set as onDuty through xPlayer.setJob() will be added to the jobs service even if this exceeds the services maxPlayers, ensuring consistency between job duty status and service membership.
    • This is not considered a breaking change, as job duty should not be managed manually when using esx_service. Properly reflecting all on-duty players takes precedence over enforcing a services maxPlayers limitations.
  • Breaking Changes:

    • Removal of esx_service:notifyAllInService Over Network:

      • Due to security concerns, the esx_service:notifyAllInService event has been removed from being triggered over the network.
      • All notifications for players in service are now managed within the server, avoiding potential abuse from clients.
      • It is the caller's responsibility to ensure that a player is authorized to send a service message.
      • As a result, this change breaks compatibility with older systems that relied on triggering the event over the network.
    • Removal of esx_service:activateService Over Network:

      • Similarly, the esx_service:activateService event is no longer available over the network for the same security reasons.
      • Service activation is now fully handled server-side.
  • Improved Notification System:

    • Notifications are now properly validated before being sent, with better error handling and warning logs if invalid notifications are attempted.
  • Service Management Enhancements:

    • Services now explicitly handle player removal from both the service and their job duty status upon leaving.
  • Client-Side Mugshot Display Fix:

    • Fixed the client-side notification to properly display the player's mugshot in the notification, which was previously missing.

Testing:

  • All events were tested locally to ensure proper functionality.
  • Verified that the player count updates correctly for each service, and players are properly added/removed.
  • Confirmed that the client-side notifications now properly display with the player’s mugshot as expected.

@Kenshiin13 Kenshiin13 changed the title refactor(esx_service) refactor!(esx_service) Nov 10, 2024
Ignore `maxPlayers` limit when updating job duty status.

This may seem counterintuitive, but in practice, only one system should be used at a time: either manually setting job duty or using `esx_service`. Reflecting all on-duty players in the service takes priority over enforcing the `maxPlayers` cap, ensuring that the duty status remains accurate regardless of service limitations.
@Mycroft-Studios Mycroft-Studios changed the base branch from main to dev November 13, 2024 20:32
@Mycroft-Studios Mycroft-Studios merged commit 3f0d700 into esx-framework:dev Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants