mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 08:13:21 +00:00
optimizations + more modules
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
ESX = {}
|
||||
ESX.Loops = {}
|
||||
ESX.LoopsRunning = {}
|
||||
ESX.Modules = {}
|
||||
ESX.PlayerData = {}
|
||||
ESX.PlayerLoaded = false
|
||||
@@ -57,6 +59,59 @@ RegisterNUICallback('frame_message', function(data, cb)
|
||||
cb('')
|
||||
end)
|
||||
|
||||
ESX.LogError = function(err)
|
||||
local str = err .. ' ' .. debug.traceback()
|
||||
print(str)
|
||||
TriggerServerEvent('esx:error:log', str);
|
||||
end
|
||||
|
||||
ESX.LogScopeError = function(scope, err)
|
||||
local str = '[esx] error in scope (' .. scope .. ') ' .. err .. ' ' .. debug.traceback()
|
||||
print(str)
|
||||
TriggerServerEvent('esx:error:log', str);
|
||||
end
|
||||
|
||||
|
||||
ESX.LogLoopError = function(loop, err)
|
||||
local str = '[esx] error in loop (' .. loop .. ') ' .. err .. ' ' .. debug.traceback()
|
||||
print(str)
|
||||
TriggerServerEvent('esx:error:log', str);
|
||||
end
|
||||
|
||||
ESX.Loop = function(name, func, wait, conditions)
|
||||
|
||||
ESX.Loops[name] = {
|
||||
func = func,
|
||||
wait = wait,
|
||||
conditons = conditions or {},
|
||||
name = name,
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
ESX.Scope = function(name, func)
|
||||
|
||||
local status, result = xpcall(func, function(err)
|
||||
ESX.LogScopeError(name, err)
|
||||
end)
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
ESX.MakeScope = function(name, func)
|
||||
|
||||
return function(...)
|
||||
|
||||
local status, result = xpcall(func, ESX.LogError, function(err)
|
||||
ESX.LogScopeError(name, err)
|
||||
end)
|
||||
|
||||
return result
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
ESX.IsPlayerLoaded = function()
|
||||
return ESX.PlayerLoaded
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user