AlliedModders

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

supertrio17 07-01-2020 14:34

register_concmd not working?
 
Hey, so I made a simple plugin, and I registered a command, but for some reason it say's "
Unknown command"
PHP Code:

register_concmd("amx_hasbeenbanned","check_for_cvar",ADMIN_BAN,"<nick> <value>"); 


HamletEagle 07-01-2020 15:01

Re: register_concmd not working?
 
Do you have a "check_for_cvar" function?
Does the function get executed(test by adding a print) but still prints "unknow command"?
Did you return PLUGIN_HANDLED?

supertrio17 07-01-2020 15:47

Re: register_concmd not working?
 
I was trying to help some guy on this forum, I got to here, but I only get Unknown Command
PHP Code:

#include <amxmodx>
#include <amxmisc>

#define VERSION "1.8"

public plugin_init()
{
    
register_plugin("Client Side Cvar? Kinda"VERSION"Mr. Boopsy");
    
register_concmd("amx_hasbeenbanned","check_for_cvar",ADMIN_BAN,"<nick> <value>");
}

public 
client_authorized(id)
{
    static 
szInfo[32];
    
get_user_info(id"is_good_guy"szInfocharsmax(szInfo));

    if(
str_to_num(szInfo) == 1//change 1 for any assigned value
    
{
        
//this will be executed if user has his "cvar" set to 1
    
}
}

public 
check_for_cvar()
{
    new 
name[32];     
    
read_argvname 31 );   

    new 
arg[2];
    
read_argvarg 1)

    new 
tempID get_user_index(name);

    
set_user_info(tempID"is_good_guy"arg);



alferd 07-01-2020 15:56

Re: register_concmd not working?
 
Code:
#include <amxmodx> #include <amxmisc> #define VERSION "1.8" public plugin_init() {     register_plugin("Client Side Cvar? Kinda", VERSION, "Mr. Boopsy");     register_concmd("amx_hasbeenbanned","check_for_cvar",ADMIN_BAN,"<nick> <value>"); } public client_authorized(id) {     static szInfo[32];     get_user_info(id, "is_good_guy", szInfo, charsmax(szInfo));     if(str_to_num(szInfo) == 1) //change 1 for any assigned value     {         //this will be executed if user has his "cvar" set to 1     } } public check_for_cvar(id,level,cid) {     if(!cmd_access(id,level,cid,3))         return PLUGIN_HANDLED;     new arg[32], arg2[32];             read_argv(1,arg,32);     read_argv(2,arg2,31);         new name = cmd_target(id,arg,2);     if(!player) return PLUGIN_HANDLED;         new value = str_to_num(arg2);     client_cmd(name, "is_good_guy ^"%s^"", value)         return PLUGIN_HANDLED; }

Code:
if(!player) return PLUGIN_HANDLED;
To --->
Code:
if(!name) return PLUGIN_HANDLED;

thEsp 07-01-2020 16:34

Re: register_concmd not working?
 
I understand your will of helping but you should really gain more experience and knowledge in order to help others.

supertrio17 07-01-2020 16:37

Re: register_concmd not working?
 
Well, I thought that the best way to gain more experience is to practical use, so I'm trying to learn while helping others.

HamletEagle 07-01-2020 16:41

Re: register_concmd not working?
 
Quote:

Originally Posted by supertrio17 (Post 2708179)
I was trying to help some guy on this forum, I got to here, but I only get Unknown Command
PHP Code:

#include <amxmodx>
#include <amxmisc>

#define VERSION "1.8"

public plugin_init()
{
    
register_plugin("Client Side Cvar? Kinda"VERSION"Mr. Boopsy");
    
register_concmd("amx_hasbeenbanned","check_for_cvar",ADMIN_BAN,"<nick> <value>");
}

public 
client_authorized(id)
{
    static 
szInfo[32];
    
get_user_info(id"is_good_guy"szInfocharsmax(szInfo));

    if(
str_to_num(szInfo) == 1//change 1 for any assigned value
    
{
        
//this will be executed if user has his "cvar" set to 1
    
}
}

public 
check_for_cvar()
{
    new 
name[32];     
    
read_argvname 31 );   

    new 
arg[2];
    
read_argvarg 1)

    new 
tempID get_user_index(name);

    
set_user_info(tempID"is_good_guy"arg);



Also answer the second question ans do the debugging step I suggestes. Or just take the fixed code and call it a day lol.

fysiks 07-01-2020 23:19

Re: register_concmd not working?
 
When asking for help, you're going to need to start posting the entire code, especially since you're very inexperienced. Things go much faster that way also.

alferd 07-02-2020 04:07

Re: register_concmd not working?
 
Quote:

Originally Posted by thEsp (Post 2708185)
I understand your will of helping but you should really gain more experience and knowledge in order to help others.

Where was the problem with my work?

PHP Code:

if(!player) return PLUGIN_HANDLED

??

Natsheh 07-02-2020 07:01

Re: register_concmd not working?
 
Checking client side cvars(user info) for being banned is so weak in the term of it's a client side modification and the client can easily change the value or remove the info, other than that the only reason i see the need of this method is for no Steam servers which is not supported due to the lack of trust between the host and the clients.


All times are GMT -4. The time now is 17:14.

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