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

feat(es_extended): Dynamic Settings to replace Configs #1611

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from

Conversation

Mycroft-Studios
Copy link
Member

@Mycroft-Studios Mycroft-Studios commented Feb 10, 2025

Description

This PR replaces static lua configs, with Dynamic Settings, that can be changed in game, allowing for much easier setup
This will integrate into the Pause Menu and other upcoming features in projects


Motivation

Making ESX easier to use, for all users.


Implementation Details

  • Adds a Settings Handler to the Server
  • Adds a Settings Handler to the Client
  • Syncs changes to the client, from the server
  • Stores Settings in a JSON, for those that wish to still edit the files
  • Allows Getting Other Resources settings, but only setting your own.

Usage Example

Client

local useAimAssist = ESX.GetSetting("AimAssist") -- for same resource Settings
local UIColour = ESX.GetResourceSetting("es_extended", "UIColour") -- for other resources Settings

AddEventHandler("es_extended:settingChanged", function(resource, category, key, value)
     print(("Setting changed: ^5%s^7, ^5%s^7, ^5%s^7, ^5%s^7"):format(resource, category, key, value))
end)

Server

ESX.RegisterSetting("Key", "Label", "Category",  false) -- Register a Setting
local useAimAssist = ESX.GetSetting("AimAssist") -- for same resource Settings
local UIColour = ESX.GetResourceSetting("es_extended", "UIColour") -- for other resources Settings
ESX.SetSetting("AimAssist", false) -- Set your own Resources settings

AddEventHandler("es_extended:settingChanged", function(resource, category, key, value)
     print(("Setting changed: ^5%s^7, ^5%s^7, ^5%s^7, ^5%s^7"):format(resource, category, key, value))
end)

Commands

  • /changeSetting resource settingKey value
    • Example: /changeSetting es_extended AimAssist false
    • Output: [Info] Setting AimAssist changed to false for es_extended
  • /checkSetting resource settingKey
    • Example: /checkSetting es_extended AimAssist
    • Output: [Info] Setting es_extended - AimAssist: false

PR Checklist

  • My commit messages and PR title follow the Conventional Commits standard.
  • My changes have been tested locally and function as expected.
  • My PR does not introduce any breaking changes.
  • I have provided a clear explanation of what my PR does, including the reasoning behind the changes and any relevant context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In-Development
Development

Successfully merging this pull request may close these issues.

1 participant