-
-
Notifications
You must be signed in to change notification settings - Fork 474
Add onClientCommand event to cancel client-side commands #4303
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
base: master
Are you sure you want to change the base?
Add onClientCommand event to cancel client-side commands #4303
Conversation
Let me know if there's something else. Not sure why some of my comments/answers are not showing. |
Hello @FileEX just in case you missed my comment to your review because Github says it's 'Pending' |
@@ -2722,6 +2722,7 @@ void CClientGame::AddBuiltInEvents() | |||
// Console events | |||
m_Events.AddEvent("onClientConsole", "text", NULL, false); | |||
m_Events.AddEvent("onClientCoreCommand", "command", NULL, false); | |||
m_Events.AddEvent("onClientCommand", "command", NULL, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nullptr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job , i have made some changes that will enhance command handling by adding argument support to the event , but i don't have changing permission to your branch , anyway the final usage would be like this :
function onClientCommand(command, arguments)
outputChatBox("Command: " .. command, 255, 255, 0)
outputChatBox("Arguments: " .. arguments, 0, 255, 255)
if command == "blocked" then
outputChatBox("Command blocked!", 255, 0, 0)
return false
end
return true
end
addEventHandler("onClientCommand", root, onClientCommand)

Okay, I didn’t realize that My suggestion is that Also, I noticed a bug. g_pClientGame->GetRegisteredCommands()->ProcessCommand(szCommandBufferPointer, szArguments); returns false – because that means the command doesn’t exist. Right now, it always returns true, even if the command doesn’t exist. As a result, when you type something like /foo, there’s no “unknown command” message – it just silently fails. You could fix this as well while you're at it. Lastly, regarding You could also consider having the |
Adds onClientCommand event to intercept and cancel client-side commands before execution.
#3160
Before you go ahead and create a pull request, please make sure:
If your work is incomplete, do not prefix your pull request with "WIP", instead
create a draft pull request: https://github.blog/2019-02-14-introducing-draft-pull-requests/
Thank you!