I am trying to use a cvar value to register a list of commands. To test, I am defaulting this cvar to register "/commands" and "/members" and have successfully done so. However, it seems "g_WebUrl" is not being read correctly by my "ShowMotd" function. It seems both commands ("/commands" and "/members") bring up the last-parsed argument (ie. "http://localhost/members"):
PHP Code:
#include <amxmodx>
#define PLUGIN "Register Web URI Commands"
#define VERSION "1.0"
#define AUTHOR "pvab"
new g_WebBase[64], g_WebCommand[27], g_WebUrl[128]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
create_cvar("kz_web_base", "http://localhost")
create_cvar("kz_web_commands", "commands members")
RegisterURICommands()
}
public RegisterURICommands()
{
new commands[512], command[32], pos;
get_cvar_string("kz_web_base", g_WebBase, 63)
get_cvar_string("kz_web_commands", commands, 511)
while (true) {
pos = argparse(commands, pos, g_WebCommand, sizeof(g_WebCommand) - 1);
if (pos == -1) {
break
}
register_clcmd(command, "ShowMotd")
formatex(command, 31, "say /%s", g_WebCommand)
formatex(g_WebUrl, 127, "%s/%s", g_WebBase, g_WebCommand)
}
}
public ShowMotd(id)
{
show_motd(id, g_WebUrl)
}
Could anyone guide me?