Open dragokas opened 3 years ago
Hi! What's your use case for this proposed feature?
Adding command name to a global cache for further checking in real time - is particular command exists. CommandExist() doesn't do its job: https://github.com/alliedmodders/sourcemod/issues/1480
GetCommandIterator is the proper way to do this.
There is no way to use GetCommandIterator() to retrieve an updated list of commands just for 1 single and simple check, because it gives like ~0.5-1 second lag to iterate the whole convars and commands list.
A global callback for when commands are registered or unregistered sounds acceptable. But it could be very spammy, so I think it would need to be an opt-in thing (eg, so you can do an initial scan on plugin load, and then activate the callback after). Eg, this kind of signature:
// status == true, adding command
// status == false, removing command - bonus points for this being an enum
typedef CommandRegistrationCallback = function void (Handle plugin, const char[] name, bool status);
void AddCommandRegistrationListener(CommandRegistrationCallback callback);
I'd be happy to review a PR for this.
Thanks for the suggestion. I'm writing in C++ very rarely. I'll give a chance to somebody more skilled.
Use case: !COMMAND eater.
When some plugin gets dynamically loaded/unloaded we have no way to identify what commands are added other than making a full commands enumeration with a significant CPU cycle loss. We don't even know when to do such enumeration, because no OnPluginLoaded() forward exists at all (second problem).
So, I suggest to add:
making life much easy.
Thank you.