Command API, Part 1 of 3

Today I’d like to highlight the latest wiki article: Scripting Commands in SourceMod. SourceMod’s Command API is slightly different than AMX Mod X’s; this is partly for optimization, and partly because of how Half-Life 2 works.

The first difference we’ll discuss is that there is no command filtering. As noted in the article, this notation is no longer possible:

register_clcmd("say /ff", "Command_FF");

Why didn’t we accommodate this? Two reasons, and they’re both related to one fact: The only usage of this syntax seemed to be for “say” and “say_team” and no other commands. I have never seen a plugin use this syntax for anything else, although I’m sure it has been done.

So, the first reason is that we’d be adding a rather complicated functionality with very limited use. The second reason is that since it’s limited, every command that went through IVEngineServer::ClientCommand would essentially be compared against a list of say hooks, even though most commands aren’t actually “say.” Of course, we could find ways to optimize around this; for example, per-command filters or filters strictly for say — but it’s a lot of work for a feature that’s entirely a convenience.

There’s a third hidden reason which will be explained in part 3 – it’s not actually technically feasible to implement it, given how Source’s command system works.

Next article we’ll see how SourceMod handles admin commands.

Leave a Reply

You must be logged in to post a comment.