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

Simplify the purpose of PostCommandCalled #87

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lua/ulib/server/concommand.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions lua/ulib/shared/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
21 changes: 2 additions & 19 deletions lua/ulib/shared/defines.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"

Expand Down