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): Extra callback functions #1505

Merged
2 changes: 1 addition & 1 deletion [core]/cron/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ game 'gta5'
author 'ESX-Framework'
description 'Allows resources to Run tasks at specific intervals.'
lua54 'yes'
version '1.11.2'
version '1.11.3'

server_script 'server/main.lua'
1 change: 0 additions & 1 deletion [core]/es_extended/client/modules/adjustments.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ end
function Adjustments:DisableAimAssist()
if Config.DisableAimAssist then
SetPlayerTargetingMode(3)
SetPlayerLockonRangeOverride(ESX.playerId, 0.0)
end
end

Expand Down
41 changes: 31 additions & 10 deletions [core]/es_extended/client/modules/callback.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Callbacks.requests = {}
Callbacks.storage = {}
Callbacks.id = 0

-- =============================================
-- MARK: Internal Functions
-- =============================================

function Callbacks:Trigger(event, cb, invoker, ...)

self.requests[self.id] = {
Expand Down Expand Up @@ -65,11 +69,24 @@ function Callbacks:ClientRecieve(eventName, requestId, invoker, ...)
self:Execute(callback, requestId, returnCb, ...)
end

ESX.SecureNetEvent("esx:triggerClientCallback", function(...)
Callbacks:ClientRecieve(...)
end)


ESX.SecureNetEvent("esx:serverCallback", function(...)
Callbacks:ServerRecieve(...)
end)

-- =============================================
-- MARK: ESX Functions
-- =============================================

---@param eventName string
---@param callback function
---@param ... any
---@return nil
ESX.TriggerServerCallback = function(eventName, callback, ...)
function ESX.TriggerServerCallback(eventName, callback, ...)
local invokingResource = GetInvokingResource()
local invoker = (invokingResource and invokingResource ~= "unknown") and invokingResource or "es_extended"

Expand All @@ -79,7 +96,7 @@ end
---@param eventName string
---@param ... any
---@return any
ESX.AwaitServerCallback = function(eventName, ...)
function ESX.AwaitServerCallback(eventName, ...)
local invokingResource = GetInvokingResource()
local invoker = (invokingResource and invokingResource ~= "unknown") and invokingResource or "es_extended"

Expand All @@ -98,17 +115,21 @@ ESX.AwaitServerCallback = function(eventName, ...)
return table.unpack(p.value)
end

ESX.SecureNetEvent("esx:serverCallback", function(...)
Callbacks:ServerRecieve(...)
end)

---@param eventName string
---@param callback function
---@return nil
ESX.RegisterClientCallback = function(eventName, callback)
function ESX.RegisterClientCallback(eventName, callback)
Callbacks:Register(eventName, callback)
end

ESX.SecureNetEvent("esx:triggerClientCallback", function(...)
Callbacks:ClientRecieve(...)
end)
---@param eventName string
---@return boolean
function ESX.DoesClientCallbackExist(eventName)
return Callbacks.storage[eventName] ~= nil
end

---@param eventName string
---@return table | nil
function ESX.GetClientCallbackInfo(eventName)
return Callbacks.storage[eventName]
end
Kenshiin13 marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion [core]/es_extended/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fx_version 'cerulean'
game 'gta5'
description 'The Core resource that provides the functionalities for all other resources.'
lua54 'yes'
version '1.11.2'
version '1.11.3'

shared_scripts {
'locale.lua',
Expand Down
13 changes: 12 additions & 1 deletion [core]/es_extended/server/modules/callback.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,18 @@ end

---@param eventName string
---@param callback function
ESX.RegisterServerCallback = function(eventName, callback)
function ESX.RegisterServerCallback(eventName, callback)
Callbacks:Register(eventName, callback)
end

---@param eventName string
---@return boolean
function ESX.DoesServerCallbackExist(eventName)
return Callbacks.storage[eventName] ~= nil
end

---@param eventName string
---@return table | nil
function ESX.GetServerCallbackInfo(eventName)
return Callbacks.storage[eventName]
end
Kenshiin13 marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion [core]/esx_chat_theme/fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version '1.11.2'
version '1.11.3'
author 'ESX-Framework'
description 'A ESX Stylised theme for the chat resource.'

Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_context/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ game 'gta5'
author 'ESX-Framework & Brayden'
description 'A simplistic context menu for ESX.'
lua54 'yes'
version '1.11.2'
version '1.11.3'

ui_page 'index.html'

Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_identity/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fx_version 'adamant'
game 'gta5'
description 'Allows the player to Pick their characters: Name, Gender, Height and Date-of-birth.'
lua54 'yes'
version '1.11.2'
version '1.11.3'

shared_scripts {
'@es_extended/imports.lua',
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion [core]/esx_loadingscreen/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ game 'common'
fx_version 'cerulean'
author 'ESX-Framework'
description 'Allows resources to Run tasks at specific intervals.'
version '1.11.2'
version '1.11.3'
lua54 'yes'

loadscreen 'index.html'
Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_menu_default/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fx_version 'adamant'
game 'gta5'
description 'A basic menu system for ESX Legacy.'
lua54 'yes'
version '1.11.2'
version '1.11.3'

client_scripts { '@es_extended/imports.lua', 'client/main.lua' }

Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_menu_dialog/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fx_version 'adamant'
game 'gta5'
description 'A basic input dialog for ESX Legacy.'
lua54 'yes'
version '1.11.2'
version '1.11.3'

client_scripts {
'@es_extended/imports.lua',
Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_menu_list/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fx_version 'adamant'
game 'gta5'
description 'A basic table-based menu system for ESX Legacy.'
lua54 'yes'
version '1.11.2'
version '1.11.3'


client_scripts {
Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_multicharacter/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fx_version 'cerulean'
game 'gta5'
author 'ESX-Framework - Linden - KASH'
description 'Allows players to have multiple characters on the same account.'
version '1.11.2'
version '1.11.3'
lua54 'yes'

dependencies { 'es_extended', 'esx_context', 'esx_identity', 'esx_skin' }
Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_notify/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fx_version 'adamant'

lua54 'yes'
game 'gta5'
version '1.11.2'
version '1.11.3'
author 'ESX-Framework'
description 'A beautiful and simple NUI notification system for ESX'

Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_progressbar/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fx_version 'adamant'
game 'gta5'
author 'ESX-Framework'
description 'A beautiful and simple NUI progress bar for ESX'
version '1.11.2'
version '1.11.3'
lua54 'yes'

client_scripts { 'Progress.lua' }
Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_skin/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fx_version 'adamant'

game 'gta5'
description 'Allows players to customise their character\'s appearance'
version '1.11.2'
version '1.11.3'
lua54 'yes'

shared_scripts {
Expand Down
2 changes: 1 addition & 1 deletion [core]/esx_textui/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fx_version 'adamant'
game 'gta5'
author 'ESX-Framework'
description 'A beautiful and simple Persistent Notification system for ESX.'
version '1.11.2'
version '1.11.3'
lua54 'yes'

client_scripts { 'TextUI.lua' }
Expand Down
2 changes: 1 addition & 1 deletion [core]/skinchanger/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fx_version 'adamant'

game 'gta5'
description 'Saves/loads character appearances for ESX Legacy.'
version '1.11.2'
version '1.11.3'
lua54 'yes'

client_scripts {
Expand Down
Loading