Simplify the purpose of PostCommandCalled (#87)

This commit is contained in:
Brandon Sturgeon 2022-09-14 18:46:17 -05:00 committed by GitHub
parent e4272fe742
commit fe5aedc7c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 26 deletions

View File

@ -25,7 +25,6 @@ ULib.sayCmds = ULib.sayCmds or {}
Revisions:
v2.10 - Made case-insensitive
v2.72 - Added ULibPostCommandCalled
]]
local function sayCmdCheck( ply, strText, bTeam )
local match
@ -69,8 +68,7 @@ local function sayCmdCheck( ply, strText, bTeam )
local fn = data.fn
local hide = data.hide
local err = ULib.pcallError( fn, ply, match:Trim(), argv, args )
hook.Call( ULib.HOOK_POST_COMMAND_CALLED, _, ply, data.__cmd, argv, hide, not err )
ULib.pcallError( fn, ply, match:Trim(), argv, args )
if hide then return "" end
end

View File

@ -948,8 +948,8 @@ local function translateCmdCallback( ply, commandName, argv )
end
end
cmd:call( isOpposite, unpack( args ) )
hook.Call( ULib.HOOK_POST_TRANSLATED_COMMAND, _, ply, commandName, args )
local callResult = cmd:call( isOpposite, unpack( args ) )
hook.Call( ULib.HOOK_POST_TRANSLATED_COMMAND, _, ply, commandName, args, callResult )
end
local function translateAutocompleteCallback( commandName, args )
@ -1315,7 +1315,6 @@ end
Revisions:
v2.62 - Initial
v2.72 - Added ULibPostCommandCalled
]]
function cmds.execute( cmdTable, ply, commandName, argv )
if CLIENT and not cmdTable.__client_only then
@ -1330,7 +1329,6 @@ function cmds.execute( cmdTable, ply, commandName, argv )
local return_value = hook.Call( ULib.HOOK_COMMAND_CALLED, _, ply, commandName, argv )
if return_value ~= false then
cmdTable.__fn( ply, commandName, argv )
hook.Call( ULib.HOOK_POST_COMMAND_CALLED, _, ply, commandName, argv )
end
end

View File

@ -116,25 +116,6 @@ ULib.HOOK_LOCALPLAYERREADY = "ULibLocalPlayerReady"
]]
ULib.HOOK_COMMAND_CALLED = "ULibCommandCalled"
--[[
Hook: ULibPostCommandCalled
Called *on server* after a ULib command is run.
Parameters passed to callback:
ply - The player that executed the command.
commandName - The command that was executed.
args - The table of args for the command.
hide - If triggered from a chat command, a boolean indicating if the output of the command should be hidden.
success - If triggered from a chat command, a boolean indicating if the command ran successfully.
Revisions:
v2.72 - Initial
]]
ULib.HOOK_POST_COMMAND_CALLED = "ULibPostCommandCalled"
--[[
Hook: ULibPlayerTarget
@ -186,10 +167,12 @@ ULib.HOOK_PLAYER_TARGETS = "ULibPlayerTargets" -- Exactly the same as the above
ply - The player that executed the command.
commandName - The command that's being executed.
translated_args - A table of the translated arguments, as passed into the callback function itself.
callResult - The return value of the command function.
Revisions:
v2.40 - Initial
v2.72 - Add the callResult parameter
]]
ULib.HOOK_POST_TRANSLATED_COMMAND = "ULibPostTranslatedCommand"