mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-11-17 17:48:36 +00:00
fix(addCommand): catch errors in command handler
+ additional minor changes. Use DoesPlayerExist native. Mark addCommand cb as async.
This commit is contained in:
1 parent
f98e2bbc1f
commit
fd112ca03c
4 files changed
+171
-157
No files matched your search
@@ -41,7 +41,7 @@ local function parseArguments(source, args, raw, params)
|
||||
elseif param.type == 'playerId' then
|
||||
value = arg == 'me' and source or tonumber(arg)
|
||||
|
||||
if not value or not GetPlayerGuid(value--[[@as string]]) then
|
||||
if not value or not DoesPlayerExist(value--[[@as string]]) then
|
||||
value = false
|
||||
end
|
||||
else
|
||||
@@ -102,7 +102,11 @@ function lib.addCommand(commandName, properties, cb, ...)
|
||||
|
||||
if not args then return end
|
||||
|
||||
cb(source, args, raw)
|
||||
local success, resp = pcall(cb, source, args, raw)
|
||||
|
||||
if not success then
|
||||
Citizen.Trace(("^1command '%s' failed to execute!\n%s"):format(string.strsplit(' ', raw) or raw, resp))
|
||||
end
|
||||
end
|
||||
|
||||
for i = 1, numCommands do
|
||||
|
||||
Reference in new issue
Block a user