Raised This Month: $51 Target: $400
 12% 

command value not working


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
urban_ninja
Senior Member
Join Date: Feb 2009
Old 12-06-2011 , 08:26   command value not working
Reply With Quote #1

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)

__________________

Last edited by urban_ninja; 12-06-2011 at 08:27.
urban_ninja is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 12-06-2011 , 10:41   Re: command value not working
Reply With Quote #2

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)

__________________
kramesa is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-06-2011 , 21:40   Re: command value not working
Reply With Quote #3

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).
__________________

Last edited by fysiks; 12-06-2011 at 21:42.
fysiks is offline
urban_ninja
Senior Member
Join Date: Feb 2009
Old 12-07-2011 , 08:43   Re: command value not working
Reply With Quote #4

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.
__________________

Last edited by urban_ninja; 12-07-2011 at 08:43.
urban_ninja is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-07-2011 , 20:42   Re: command value not working
Reply With Quote #5

Quote:
Originally Posted by urban_ninja View Post
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 View Post
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.
__________________
fysiks is offline
urban_ninja
Senior Member
Join Date: Feb 2009
Old 12-08-2011 , 09:09   Re: command value not working
Reply With Quote #6

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.
__________________
urban_ninja is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-08-2011 , 16:17   Re: command value not working
Reply With Quote #7

Quote:
Originally Posted by urban_ninja View Post
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.
__________________
fysiks is offline
Vet
Veteran Member
Join Date: Jul 2006
Location: I|O wa
Old 12-26-2011 , 22:24   Re: command value not working
Reply With Quote #8

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"
__________________
=====================================
- My Plugins -
=====================================
Vet is offline
Send a message via MSN to Vet
Reply



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 21:28.


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