Skip to content

Commit

Permalink
Merge pull request #1582 from Kenshiin13/1.12.3-hotfix
Browse files Browse the repository at this point in the history
1.12.3 hotfix
  • Loading branch information
Arctos2win authored Jan 6, 2025
2 parents ef98c71 + 0690f10 commit a18a714
Show file tree
Hide file tree
Showing 16 changed files with 217 additions and 88 deletions.
2 changes: 1 addition & 1 deletion [core]/cron/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 align='center'>[ESX] Cron</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://documentation.esx-framework.org/legacy/installation'>Documentation</a></b></h5>
<h1 align='center'>[ESX] Cron</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://docs.esx-legacy.com/legacy/installation'>Documentation</a></b></h5>

A simple, but vital, resource that allows resources to Run tasks at specific intervals.

Expand Down
26 changes: 13 additions & 13 deletions [core]/es_extended/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<h1 align='center'>es_extended</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://documentation.esx-framework.org/legacy/installation'>Documentation</a></b></h5>

## Legal

es_extended

Copyright (C) 2015-2024 Jérémie N'gadi

This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version.

This program Is distributed In the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty Of MERCHANTABILITY Or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License For more details.

You should have received a copy Of the GNU General Public License along with this program. If Not, see <http://www.gnu.org/licenses/>.
<h1 align='center'>es_extended</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://docs.esx-legacy.com/legacy/installation'>Documentation</a></b></h5>

## Legal

es_extended

Copyright (C) 2015-2024 Jérémie N'gadi

This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version.

This program Is distributed In the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty Of MERCHANTABILITY Or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License For more details.

You should have received a copy Of the GNU General Public License along with this program. If Not, see <http://www.gnu.org/licenses/>.
201 changes: 161 additions & 40 deletions [core]/es_extended/imports.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ESX = exports["es_extended"]:getSharedObject()
_resourceName = GetCurrentResourceName()
ESX.currentResourceName = GetCurrentResourceName()

OnPlayerData = function (key, val, last) end

Expand Down Expand Up @@ -44,67 +44,188 @@ if not IsDuplicityVersion() then -- Only register this event for the client
end
end

if not lib?.require then
local cachedModules = {} ---@type table<string, any>
local loadingModules = {} ---@type table<string, true?>

---@param modulePath string
if GetResourceState("ox_lib") == "missing" then
---@Credits: https://github.com/overextended/ox_lib/blob/master/imports/require/shared.lua - Licensed under the GNU Lesser General Public License v3.0
local loaded = {}
local _require = require

package = {
path = './?.lua;./?/init.lua',
preload = {},
loaded = setmetatable({}, {
__index = loaded,
__newindex = function() end,
__metatable = false,
})
}

---@param modName string
---@return string
---@return string
local function getResourceNameFromModulePath(modulePath)
local externalResourceName = modulePath:match("^@(.-)%.")
if externalResourceName then
return externalResourceName
local function getModuleInfo(modName)
local resource = modName:match('^@(.-)/.+') --[[@as string?]]

if resource then
return resource, modName:sub(#resource + 3)
end

return _resourceName
local idx = 4 -- call stack depth (kept slightly lower than expected depth "just in case")

while true do
local dbgInfo = debug.getinfo(idx, 'S')
local src = dbgInfo and dbgInfo.source

if not src then
return ESX.currentResourceName, modName
end

resource = src:match('^@@([^/]+)/.+')

if resource and not src:find('^@@es_extended/imports') then
return resource, modName
end

idx = idx + 1
end
end

---@param modulePath string
---@return string, number
local function getModuleFilePath(modulePath)
if modulePath:sub(1, 1) == "@" then
modulePath = modulePath:sub(modulePath:find("%.") + 1)
local tempData = {}

---@param name string
---@param path string
---@return string? filename
---@return string? errmsg
---@diagnostic disable-next-line: duplicate-set-field
function package.searchpath(name, path)
local resource, modName = getModuleInfo(name:gsub('%.', '/'))
local tried = {}

for template in path:gmatch('[^;]+') do
local fileName = template:gsub('^%./', ''):gsub('?', modName:gsub('%.', '/') or modName)
local file = LoadResourceFile(resource, fileName)

if file then
tempData[1] = file
tempData[2] = resource
return fileName
end

tried[#tried + 1] = ("no file '@%s/%s'"):format(resource, fileName)
end

return modulePath:gsub("%.", "/")
return nil, table.concat(tried, "\n\t")
end

---@param modulePath string
---@return any
function require(modulePath)
assert(type(modulePath) == "string", "Module path must be a string")
---Attempts to load a module at the given path relative to the resource root directory.\
---Returns a function to load the module chunk, or a string containing all tested paths.
---@param modName string
---@param env? table
local function loadModule(modName, env)
local fileName, err = package.searchpath(modName, package.path)

if loadingModules[modulePath] then
error(("Circular dependency detected for module '%s'."):format(modulePath))
if fileName then
local file = tempData[1]
local resource = tempData[2]

ESX.Table.Wipe(tempData)
return assert(load(file, ('@@%s/%s'):format(resource, fileName), 't', env or _ENV))
end

if cachedModules[modulePath] then
return cachedModules[modulePath]
return nil, err or 'unknown error'
end

---@alias PackageSearcher
---| fun(modName: string): function loader
---| fun(modName: string): nil, string errmsg

---@type PackageSearcher[]
package.searchers = {
function(modName)
local ok, result = pcall(_require, modName)

if ok then return result end

return ok, result
end,
function(modName)
if package.preload[modName] ~= nil then
return package.preload[modName]
end

return nil, ("no field package.preload['%s']"):format(modName)
end,
function(modName) return loadModule(modName) end,
}

---@param filePath string
---@param env? table
---@return unknown
---Loads and runs a Lua file at the given path. Unlike require, the chunk is not cached for future use.
function ESX.load(filePath, env)
if type(filePath) ~= 'string' then
error(("file path must be a string (received '%s')"):format(filePath), 2)
end

loadingModules[modulePath] = true
local result, err = loadModule(filePath, env)

if result then return result() end

error(("file '%s' not found\n\t%s"):format(filePath, err))
end

---@param filePath string
---@return table
---Loads and decodes a json file at the given path.
function ESX.loadJson(filePath)
if type(filePath) ~= 'string' then
error(("file path must be a string (received '%s')"):format(filePath), 2)
end

local resourceSrc, modPath = getModuleInfo(filePath:gsub('%.', '/'))
local resourceFile = LoadResourceFile(resourceSrc, ('%s.json'):format(modPath))

if resourceFile then
return json.decode(resourceFile)
end

local resourceName = getResourceNameFromModulePath(modulePath)
local moduleFilePath = getModuleFilePath(modulePath)
local moduleFileContent = LoadResourceFile(resourceName, moduleFilePath .. ".lua")
error(("json file '%s' not found\n\tno file '@%s/%s.json'"):format(filePath, resourceSrc, modPath))
end

if not moduleFileContent then
loadingModules[modulePath] = nil
error(("Module '%s' not found in resource '%s'."):format(moduleFilePath, resourceName))
---Loads the given module, returns any value returned by the seacher (`true` when `nil`).\
---Passing `@resourceName.modName` loads a module from a remote resource.
---@param modName string
---@return unknown
function ESX.require(modName)
if type(modName) ~= 'string' then
error(("module name must be a string (received '%s')"):format(modName), 3)
end

local chunk, err = load(moduleFileContent, ("@%s/%s"):format(resourceName, moduleFilePath), "t")
local module = loaded[modName]

if not chunk then
loadingModules[modulePath] = nil
error(("Failed to load module '%s': %s"):format(moduleFilePath, err))
if module == '__loading' then
error(("^1circular-dependency occurred when loading module '%s'^0"):format(modName), 2)
end

local result = chunk()
if module ~= nil then return module end

loaded[modName] = '__loading'

cachedModules[modulePath] = result ~= nil and result or true
loadingModules[modulePath] = nil
local err = {}

return result
for i = 1, #package.searchers do
local result, errMsg = package.searchers[i](modName)
if result then
if type(result) == 'function' then result = result() end
loaded[modName] = result or result == nil

return loaded[modName]
end

err[#err + 1] = errMsg
end

error(("%s"):format(table.concat(err, "\n\t")))
end

require = ESX.require
end
2 changes: 1 addition & 1 deletion [core]/es_extended/server/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ end

---@return table
function ESX.GetItems()
return Core.Items
return ESX.Items
end

---@return table
Expand Down
6 changes: 3 additions & 3 deletions [core]/es_extended/shared/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ AddEventHandler("esx:getSharedObject", function(cb)
cb(ESX)
end
local invokingResource = GetInvokingResource()
print(("^3[WARNING]^0 Resource ^5%s^0 used the ^5getSharedObject^0 event. This is not the recommended way to import ESX. Visit https://documentation.esx-framework.org/tutorials/tutorials-esx/sharedevent to find out why."):format(invokingResource))
print(("^3[WARNING]^0 Resource ^5%s^0 used the ^5getSharedObject^0 event. This is not the recommended way to import ESX. Visit https://docs.esx-legacy.com/tutorials/tutorials-esx/sharedevent to find out why."):format(invokingResource))
end)

-- backwards compatibility (DO NOT TOUCH !)
Config.OxInventory = Config.CustomInventory == "ox"
-- backwards compatibility (DO NOT TOUCH !)
Config.OxInventory = Config.CustomInventory == "ox"
12 changes: 10 additions & 2 deletions [core]/es_extended/shared/modules/table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,18 @@ function ESX.Table.Sort(t, order)
end
end

function ESX.Table.ToArray(table)
---@param t table
---@return Array
function ESX.Table.ToArray(t)
local array = {}
for _, v in pairs(table) do
for _, v in pairs(t) do
array[#array + 1] = v
end
return array
end

---@param t table
---@return table
function ESX.Table.Wipe(t)
return table.wipe(t)
end
2 changes: 1 addition & 1 deletion [core]/esx_chat_theme/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 align='center'>[ESX] Chat Theme</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://documentation.esx-framework.org/legacy/installation'>Documentation</a></b></h5>
<h1 align='center'>[ESX] Chat Theme</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://docs.esx-legacy.com/legacy/installation'>Documentation</a></b></h5>

A ESX-Based Chat-theme for your server

Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_context/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 align='center'>[ESX] Context</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://documentation.esx-framework.org/legacy/installation'>Documentation</a></b></h5>
<h1 align='center'>[ESX] Context</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://docs.esx-legacy.com/legacy/installation'>Documentation</a></b></h5>

A elegant, easy to use Context Menu system to make User Interactions clean and hassle free

Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_identity/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 align='center'>[ESX] Identity</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://documentation.esx-framework.org/legacy/installation'>Documentation</a></b></h5>
<h1 align='center'>[ESX] Identity</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://docs.esx-legacy.com/legacy/installation'>Documentation</a></b></h5>

A Core Resource that Allows the player to Pick their characters, Name, Gender, Height and Date-of-birth.

Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_loadingscreen/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 align='center'>[ESX] Loading Screen</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://documentation.esx-framework.org/legacy/installation'>Documentation</a></b></h5>
<h1 align='center'>[ESX] Loading Screen</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://docs.esx-legacy.com/legacy/installation'>Documentation</a></b></h5>

A simple but beautiful Loading Screen for your server!

Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_menu_default/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 align='center'>[ESX] Menu Defualt</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://documentation.esx-framework.org/legacy/installation'>Documentation</a></b></h5>
<h1 align='center'>[ESX] Menu Defualt</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://docs.esx-legacy.com/legacy/installation'>Documentation</a></b></h5>

A default List type menu for ESX.

Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_multicharacter/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 align='center'>[ESX] Multi-Character</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://documentation.esx-framework.org/'>Documentation</a></b></h5>
<h1 align='center'>[ESX] Multi-Character</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://docs.esx-legacy.com/'>Documentation</a></b></h5>

A Simplistic system, that allows Players to have multiple Characters, which can be customised for all player with `Config.Slots` or personally set a players character count using `setslots`, `remslots`, `enablechar` and `disablechar` Commands :)

Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_notify/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 align='center'>[ESX] Notify</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://documentation.esx-framework.org/legacy/installation'>Documentation</a></b></h5>
<h1 align='center'>[ESX] Notify</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://docs.esx-legacy.com/legacy/installation'>Documentation</a></b></h5>

A beautiful and simple NUI notification system for ESX

Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_textui/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 align='center'>[ESX] TextUI</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://documentation.esx-framework.org/legacy/installation'>Documentation</a></b></h5>
<h1 align='center'>[ESX] TextUI</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://docs.esx-legacy.com/legacy/installation'>Documentation</a></b></h5>

A beautiful and simple Persistent Notification.

Expand Down
2 changes: 1 addition & 1 deletion [core]/skinchanger/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 align='center'>[ESX] SkinChanger</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://documentation.esx-framework.org/legacy/installation'>Documentation</a></b></h5>
<h1 align='center'>[ESX] SkinChanger</a></h1><p align='center'><b><a href='https://discord.esx-framework.org/'>Discord</a> - <a href='https://esx-framework.org/'>Website</a> - <a href='https://docs.esx-legacy.com/legacy/installation'>Documentation</a></b></h5>

skinchanger is a resource used to both Set and Get Players clothing, accessories and Model - It supports the freemode peds `mp_m_freemode_01` and `mp_f_freemode_01` as well as all Ped Features.

Expand Down
Loading

0 comments on commit a18a714

Please sign in to comment.