AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   command value not working (https://forums.alliedmods.net/showthread.php?t=173507)

urban_ninja 12-06-2011 08:26

command value not working
 
Hey, This is my 1st time making a command that carry's a value. Basically how do I get the value from the entered command over to the indexed maxbots?
PHP Code:

maxbots 

The foxbot control command works but the command value is always turning up as 0 regardless of the command value entered by console.

My code:
PHP Code:

new id,level,cid
new maxbots[2]
public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_concmd("amx_bot_max""BotCon")
}
public 
BotCon(id)
{
    
read_argv(idmaxbots,2)
    
server_cmd("bot ^"max_bots %d^""maxbots)



kramesa 12-06-2011 10:41

Re: command value not working
 
Try

PHP Code:

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_concmd("amx_bot_max""BotCon")
}

public 
BotCon(id)
{
    new 
maxbots[35]
    
read_args(maxbotscharsmax(maxbots))
    
remove_quotes(maxbots)
    
    
server_cmd("bot ^"max_bots %d^""maxbots)



fysiks 12-06-2011 21:40

Re: command value not working
 
You need to start looking at existing plugins and see how things are done. The funcwiki is great but it probably confused you on read_argv() because the "id" shown there is not the "id" of a player at all. It is the index of the argument that you want to retrieve.

PHP Code:

#include <amxmodx>

public plugin_init()
{
    
register_plugin("Plugin""0.1""Author")
    
register_concmd("amx_bot_max""BotCon")
}
public 
BotCon(id)
{
    new 
szMaxbots[3]
    
read_argv(1szMaxbotscharsmax(szMaxbots))
    new 
iMaxbots str_to_num(szMaxbots)
    
server_cmd("bot ^"max_bots %d^""iMaxbots)


@Kramesa: You were functionally close but but I would rather use read_argv() for clarity. To fix your code you would need to change the %d to %s (I think).

urban_ninja 12-07-2011 08:43

Re: command value not working
 
neither of your guys codes did anything. They actually made the command not function at all.

Quote:

You need to start looking at existing plugins and see how things are done.
I do but more times than not, what I find is similar but not the exact same problem.

Quote:

The funcwiki is great but it probably confused you on read_argv() because the "id" shown there is not the "id" of a player at all
Sometime function description and explained use can be deceiving.

fysiks 12-07-2011 20:42

Re: command value not working
 
Quote:

Originally Posted by urban_ninja (Post 1609100)
neither of your guys codes did anything. They actually made the command not function at all.

It works fine for me when I changed "bot" to "shr" for DOD. Which means that everything that I wrote works fine. Maybe you are using the wrong format of command for your bot program.


Quote:

Originally Posted by urban_ninja (Post 1609100)
I do but more times than not, what I find is similar but not the exact same problem.

Well Duh! If you found the same exact thing then you wouldn't need to do anything but use the plugin you found as is. All you need is similar plugins. I was most specifically refering to the read_argv() function which just about any client command plugin uses.

urban_ninja 12-08-2011 09:09

Re: command value not working
 
Quote:

It works fine for me when I changed "bot" to "shr" for DOD. Which means that everything that I wrote works fine. Maybe you are using the wrong format of command for your bot program.
The command format for foxbot is all bot commands have to be prefixed by "bot" with quotes and then the bot command with quotes("bot" "bot_max #"). Use that command format through rcon and it works but I dont want to give full access to admins just for bot commands. The admin mod foxbot control plugin also uses the same command format.

I just need a foxbot control plugin to replace the one from admin mod so I can finally get rid of admin mod.

fysiks 12-08-2011 16:17

Re: command value not working
 
Quote:

Originally Posted by urban_ninja (Post 1609660)
The command format for foxbot is all bot commands have to be prefixed by "bot" with quotes and then the bot command with quotes("bot" "bot_max #"). Use that command format through rcon and it works but I dont want to give full access to admins just for bot commands. The admin mod foxbot control plugin also uses the same command format.

I just need a foxbot control plugin to replace the one from admin mod so I can finally get rid of admin mod.

Are you saying you are supposed to have quotes around the word bot? If yes, then you forgot to do that. If no then I don't see anything wrong.

Vet 12-26-2011 22:24

Re: command value not working
 
Try this. Its a snippet of what works on our server. It also adds a check to ensure the bot value is
within a specific range (edit for you needs) and reports the change in chat. Requires admin level 'f'.

Code:

#include <amxmodx>

#define PLUGIN "AMX Bot Control"
#define VERSION "1.0"
#define AUTHOR "Vet(3TT3V)"

public plugin_init()
{
        register_plugin(PLUGIN, VERSION, AUTHOR)
        register_concmd("amx_bot_max", "BotCon", ADMIN_MAP)
}

public BotCon(id, lvl, cid)
{
        if (!cmd_access(id, lvl, cid, 2))
                return PLUGIN_HANDLED

        new arg[8]
        new tmpint
        read_argv(1, arg, 7)
        tmpint = str_to_num(arg)
        if (tmpint < 1 || tmpint > 19) {
                console_print(id, "Number out of range (1 - 19)")
                return PLUGIN_HANDLED
        }
        new tmpstr[32]
        format(tmpstr, 31, "bot ^"max_bots %d^"", tmpint)
        server_cmd(tmpstr)

        console_print(id, "max_bots set to %d", tmpint)
        get_user_name(id, tmpstr, 31)
        log_message("[AMXX] Admin %s set max_bots to %d", tmpstr, tmpint)
        if (get_cvar_num("amx_show_activity") == 2)
                client_print(0, print_chat, "ADMIN %s: set max_bots to %d", tmpstr, tmpint)

        return PLUGIN_HANDLED
}

FYI, per the Foxbot instructions I've read, the prefix is NOT surrounded by quotes.
An example RCON command would be: RCON bot "max_bots 10"


All times are GMT -4. The time now is 12:11.

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