-
-
Notifications
You must be signed in to change notification settings - Fork 749
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #959 from esx-framework/dev
1.9.4
- Loading branch information
Showing
67 changed files
with
3,069 additions
and
2,098 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
local RequestId = 0 | ||
local serverRequests = {} | ||
|
||
local clientCallbacks = {} | ||
|
||
---@param eventName string | ||
---@param callback function | ||
---@param ... any | ||
ESX.TriggerServerCallback = function(eventName, callback, ...) | ||
serverRequests[RequestId] = callback | ||
|
||
TriggerServerEvent('esx:triggerServerCallback', eventName, RequestId, GetInvokingResource() or "unknown", ...) | ||
|
||
RequestId = RequestId + 1 | ||
end | ||
|
||
RegisterNetEvent('esx:serverCallback', function(requestId, invoker, ...) | ||
if not serverRequests[requestId] then | ||
return print(('[^1ERROR^7] Server Callback with requestId ^5%s^7 Was Called by ^5%s^7 but does not exist.'):format(requestId, invoker)) | ||
end | ||
|
||
serverRequests[requestId](...) | ||
serverRequests[requestId] = nil | ||
end) | ||
|
||
---@param eventName string | ||
---@param callback function | ||
ESX.RegisterClientCallback = function(eventName, callback) | ||
clientCallbacks[eventName] = callback | ||
end | ||
|
||
RegisterNetEvent('esx:triggerClientCallback', function(eventName, requestId, invoker, ...) | ||
if not clientCallbacks[eventName] then | ||
return print(('[^1ERROR^7] Client Callback not registered, name: ^5%s^7, invoker resource: ^5%s^7'):format(eventName, invoker)) | ||
end | ||
|
||
clientCallbacks[eventName](function(...) | ||
TriggerServerEvent('esx:clientCallback', requestId, invoker, ...) | ||
end, ...) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.