Raised This Month: $ Target: $400
 0% 

Overriding Commands (not permissions)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DJ Data
SourceMod Donor
Join Date: Dec 2012
Location: Switzerland
Old 09-16-2015 , 12:35   Overriding Commands (not permissions)
Reply With Quote #1

Hey,

Is there a way to unhook !help and !motd and replace them by my hooks/functions?
__________________
SourcePawn Coding Level: Novice
DJ Data is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 09-16-2015 , 13:08   Re: Overriding Commands (not permissions)
Reply With Quote #2

registering it again should work

assuming they're called in the order they're registered in, you might need to delay it if the command doesn't already exist
Miu is offline
DJ Data
SourceMod Donor
Join Date: Dec 2012
Location: Switzerland
Old 09-16-2015 , 14:07   Re: Overriding Commands (not permissions)
Reply With Quote #3

Even if i reload the plugin, it seems like gameme's help, sourcemod's help and my own help command seem to fire at the same time.
__________________
SourcePawn Coding Level: Novice
DJ Data is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 09-16-2015 , 15:16   Re: Overriding Commands (not permissions)
Reply With Quote #4

Returning Plugin_Stop should do it

e: Seems like ithas a FIFO order actually which is awkward

Last edited by Miu; 09-16-2015 at 15:29.
Miu is offline
psychonic

BAFFLED
Join Date: May 2008
Old 09-16-2015 , 18:20   Re: Overriding Commands (not permissions)
Reply With Quote #5

Quote:
Originally Posted by Miu View Post
e: Seems like ithas a FIFO order actually which is awkward
The order is officially undefined and is an implementation detail. It can change at any time; don't rely on it.

If you don't want certain commands to be present, don't run the plugins providing those commands (or remove them from that plugin).
psychonic is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-17-2015 , 11:25   Re: Overriding Commands (not permissions)
Reply With Quote #6

Quote:
Originally Posted by psychonic View Post
The order is officially undefined and is an implementation detail. It can change at any time; don't rely on it.

If you don't want certain commands to be present, don't run the plugins providing those commands (or remove them from that plugin).
It may be that people don't like editing core plugins. As I recall, motd is part of basetriggers.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
psychonic

BAFFLED
Join Date: May 2008
Old 09-17-2015 , 12:33   Re: Overriding Commands (not permissions)
Reply With Quote #7

Quote:
Originally Posted by Powerlord View Post
It may be that people don't like editing core plugins. As I recall, motd is part of basetriggers.
Indeed, but that doesn't change the answer.
psychonic is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-17-2015 , 13:48   Re: Overriding Commands (not permissions)
Reply With Quote #8

Quote:
Originally Posted by psychonic View Post
Indeed, but that doesn't change the answer.
No, but the fact that CommandListeners are processed before ConCmds are does.

For everyone else, I should explain that. If you know a command is a registered using RegConCmd, you can AddCommandListener on the same command and return Plugin_Handled or Plugin_Stop in the CommandListener to prevent the original plugin from ever receiving it.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
psychonic

BAFFLED
Join Date: May 2008
Old 09-17-2015 , 13:59   Re: Overriding Commands (not permissions)
Reply With Quote #9

Quote:
Originally Posted by Powerlord View Post
No, but the fact that CommandListeners are processed before ConCmds are does.

For everyone else, I should explain that. If you know a command is a registered using RegConCmd, you can AddCommandListener on the same command and return Plugin_Handled or Plugin_Stop in the CommandListener to prevent the original plugin from ever receiving it.
At which point you end up running two plugins just to achieve a net result of... nothing.

Not to mention having troubleshooting issues when you forgot or don't realize that you have one plugin trying to block another plugin.

Last edited by psychonic; 09-17-2015 at 14:00.
psychonic is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-17-2015 , 15:46   Re: Overriding Commands (not permissions)
Reply With Quote #10

Quote:
Originally Posted by psychonic View Post
At which point you end up running two plugins just to achieve a net result of... nothing.

Not to mention having troubleshooting issues when you forgot or don't realize that you have one plugin trying to block another plugin.
There are reasons to do it. NativeVotes BaseCommands uses Command Listeners to override sm_cancelvote and sm_revote and handle them differently if NativeVotes has a vote running.

If NativeVotes doesn't have a vote running, then it allows a fallthrough to BaseCommands which will ultimately handle the cancel/revote/rejection of the command.

(Note: Because sm_cancelvote is an admin command, NativeVotes BaseCommands also does a CheckCommandAccess call)
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 09-17-2015 at 15:47.
Powerlord is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:19.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode