AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Registering multiple commands via cvar (https://forums.alliedmods.net/showthread.php?t=282140)

tenub 04-30-2016 00:43

Registering multiple commands via cvar
 
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(PLUGINVERSIONAUTHOR)
    
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_WebBase63)
    
get_cvar_string("kz_web_commands"commands511)

    while (
true) {
        
pos argparse(commandsposg_WebCommandsizeof(g_WebCommand) - 1);

        if (
pos == -1) {
            break
        }

        
register_clcmd(command"ShowMotd")

        
formatex(command31"say /%s"g_WebCommand)
        
formatex(g_WebUrl127"%s/%s"g_WebBaseg_WebCommand)
    }
}


public 
ShowMotd(id)
{
    
show_motd(idg_WebUrl)


Could anyone guide me?


All times are GMT -4. The time now is 18:36.

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