// continue as usual and scan for normal commands
if (GenericCommand(command)// handled by common/command/generic.qc
|| LocalCommand_macro_command(argc) // handled by one of the above LocalCommand_* functions
- || MUTATOR_CALLHOOK(CSQC_ConsoleCommand, s, argc, command) // handled by a mutator
+ || MUTATOR_CALLHOOK(GameCommand, s, argc, command) // handled by a mutator
) return;
// nothing above caught the command, must be invalid
#include "../../common/mutators/base.qh"
-// globals
-
-string cmd_name;
-int cmd_argc;
-string cmd_string;
-
-/**
- * Called when a client command is parsed
- * NOTE: hooks MUST start with if (MUTATOR_RETURNVALUE) return false;
- * NOTE: return true if you handled the command, return false to continue handling
- * NOTE: THESE HOOKS MUST NEVER EVER CALL tokenize()
- * // example:
- * MUTATOR_HOOKFUNCTION(foo, CSQC_ConsoleCommand) {
- * if (MUTATOR_RETURNVALUE) return false; // command was already handled
- * if (cmd_name == "echocvar" && cmd_argc >= 2) {
- * print(cvar_string(argv(1)), "\n");
- * return true;
- * }
- * if (cmd_name == "echostring" && cmd_argc >= 2) {
- * print(substring(cmd_string, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), "\n");
- * return true;
- * }
- * return false;
- * }
- */
-#define EV_CSQC_ConsoleCommand(i, o) \
- /** command name */ i(string, cmd_name) \
- /** also, argv() can be used */ i(int, cmd_argc) \
- /** whole command, use only if you really have to */ i(string, cmd_string) \
- /**/
-MUTATOR_HOOKABLE(CSQC_ConsoleCommand, EV_CSQC_ConsoleCommand);
-
/* Called when the crosshair is being updated */
MUTATOR_HOOKABLE(UpdateCrosshair, EV_NO_ARGS);
/**/
MUTATOR_HOOKABLE(BuildMutatorsPrettyString, EV_BuildMutatorsPrettyString);
+string cmd_name;
+int cmd_argc;
+string cmd_string;
+
+/**
+ * Called when a game command is parsed
+ * NOTE: hooks MUST start with if (MUTATOR_RETURNVALUE) return false;
+ * NOTE: return true if you handled the command, return false to continue handling
+ * NOTE: THESE HOOKS MUST NEVER EVER CALL tokenize()
+ * // example:
+ * MUTATOR_HOOKFUNCTION(foo, GameCommand) {
+ * if (MUTATOR_RETURNVALUE) return false; // command was already handled
+ * if (cmd_name == "echocvar" && cmd_argc >= 2) {
+ * print(cvar_string(argv(1)), "\n");
+ * return true;
+ * }
+ * if (cmd_name == "echostring" && cmd_argc >= 2) {
+ * print(substring(cmd_string, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), "\n");
+ * return true;
+ * }
+ * return false;
+ * }
+ */
+#define EV_GameCommand(i, o) \
+ /** command name */ i(string, cmd_name) \
+ /** also, argv() can be used */ i(int, cmd_argc) \
+ /** whole command, use only if you really have to */ i(string, cmd_string) \
+ /**/
+MUTATOR_HOOKABLE(GameCommand, EV_GameCommand);
+
#endif
float updateConwidths(float width, float height, float pixelheight);
-void GameCommand(string theCommand)
+void GameCommand(string command)
{
- float argc;
- argc = tokenize_console(theCommand);
+ int argc = tokenize_console(command);
+ string s = strtolower(argv(0));
if(argv(0) == "help" || argc == 0)
{
return;
}
- if(GenericCommand(theCommand))
+ if(GenericCommand(command))
return;
if(argv(0) == "sync")
return;
}
+ if (MUTATOR_CALLHOOK(GameCommand, s, argc, command)) return; // handled by a mutator
+
print(_("Invalid command. For a list of supported commands, try menu_cmd help.\n"));
}
../common/items/all.qc
../common/monsters/all.qc
+../common/mutators/all.qc
../common/vehicles/all.qc
../common/weapons/all.qc
*/
MUTATOR_HOOKABLE(PlayerUseKey, EV_NO_ARGS);
-/**
- * called when a client command is parsed
- * NOTE: hooks MUST start with if (MUTATOR_RETURNVALUE) return false;
- * NOTE: return true if you handled the command, return false to continue handling
- * NOTE: THESE HOOKS MUST NEVER EVER CALL tokenize()
- * // example:
- * MUTATOR_HOOKFUNCTION(foo_SV_ParseClientCommand)
- * {
- * if (MUTATOR_RETURNVALUE) // command was already handled?
- * return false;
- * if (cmd_name == "echocvar" && cmd_argc >= 2)
- * {
- * print(cvar_string(argv(1)), "\n");
- * return true;
- * }
- * if (cmd_name == "echostring" && cmd_argc >= 2)
- * {
- * print(substring(cmd_string, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), "\n");
- * return true;
- * }
- * return false;
- * }
- */
-#define EV_SV_ParseClientCommand(i, o) \
- /** command name */ i(string, cmd_name) \
- /** also, argv() can be used */ i(int, cmd_argc) \
- /** whole command, use only if you really have to */ i(string, cmd_string) \
- /**/
-string cmd_name;
-int cmd_argc;
-string cmd_string;
-MUTATOR_HOOKABLE(SV_ParseClientCommand, EV_SV_ParseClientCommand);
+/** Called when a client command is parsed, same structure as GameCommand */
+MUTATOR_HOOKABLE(SV_ParseClientCommand, EV_GameCommand);
/**
* called when a spawnpoint is being evaluated