Skip to content

fix(es_extended/shared/functions): fix ESX.GetConfig bug#1699

Merged
Kenshiin13 merged 1 commit into
devfrom
get-cfg
Aug 13, 2025
Merged

fix(es_extended/shared/functions): fix ESX.GetConfig bug#1699
Kenshiin13 merged 1 commit into
devfrom
get-cfg

Conversation

@Kenshiin13

Copy link
Copy Markdown
Contributor

Description

Fixes a bug in ESX.GetConfig where falsy config values (e.g., false, nil) would incorrectly cause the function to return the entire Config table instead of the actual value. This ensures accurate value retrieval even for falsy config values.


Motivation

The previous inline logic using and/or would fall back to returning the full config if Config[key] was falsy. This behavior was incorrect and caused issues when a config value was intentionally false. This change fixes that logic.


Implementation Details

Replaced the ternary-style one-liner with a simple if statement to explicitly check if the key parameter is not nil. This avoids misinterpreting falsy values and ensures proper return values.

Updated function:

---@param key? string Key pair to get specific value of config
---@return unknown Returns the whole config if no key is passed, or a specific value
function ESX.GetConfig(key)
    if key ~= nil then
        return Config[key]
    end

    return Config
end

Usage Example

local value = ESX.GetConfig("SomeKey") -- Will now correctly return false if Config["SomeKey"] = false
local fullConfig = ESX.GetConfig()     -- Returns entire Config table

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.

@Zykem Zykem left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks.

@Kenshiin13 Kenshiin13 merged commit e02d230 into dev Aug 13, 2025
2 of 4 checks passed
@Kenshiin13 Kenshiin13 deleted the get-cfg branch August 13, 2025 15:23
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