Raised This Month: $ Target: $400
 0% 

Registering multiple commands via cvar


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
tenub
Junior Member
Join Date: Aug 2013
Old 04-30-2016 , 00:43   Registering multiple commands via cvar
Reply With Quote #1

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?

Last edited by tenub; 05-01-2016 at 16:18.
tenub is offline
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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