AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   help with say cmd (https://forums.alliedmods.net/showthread.php?t=216436)

kimilover 05-21-2013 05:06

help with say cmd
 
Hi guys i want a say cmd .setpass "password" to set sv_password "password". I try to make it with this code but it isn work when i write .setpass 32 but when i write .setpass and it dont set any password because i dont give one.

Quote:

/* Say cmd .Setpass ...*/

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>

#define PLUGIN ".setpass"
#define VERSION "1.0"
#define AUTHOR "Nefos"


public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say","set_pass")
}

public set_pass(id) {
if(has_flag(id, "v"))
{
new password[32], setpass[32]
read_args(setpass,31)
remove_quotes(setpass)
if (equali(setpass, ".setpass ", 11))
{


read_argv(2, password, 32)
server_cmd("sv_password %s",password)
client_print(0, print_chat,"[AMXX] PASSWORD SETTED")
}
}

else {
client_print(0,print_chat,"NO ACCESS")
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}

^SmileY 05-21-2013 10:51

Re: help with say cmd
 
PHP Code:

#include <amxmodx>
#include <amxmisc>

new g_Password;

public 
plugin_init()
{
    
register_plugin("Simple Password",AMXX_VERSION_STR,"SmileY");
    
    
g_Password get_cvar_pointer("sv_password");
    
    
register_clcmd("say","cmd_SAY");
    
register_clcmd("say_team","cmd_SAY");
    
    
// To remove a password using this comand, using .password "" (With the double quotes "")
    
register_concmd(".password","cmdPassword",ADMIN_PASSWORD,".password <Password>");
}

public 
cmd_SAY(id)
{
    new 
szArgs[192];
    
read_args(szArgs,charsmax(szArgs));
    
remove_quotes(szArgs);
    
    if(
szArgs[0] == '.')
    {
        
client_cmd(id,szArgs);
        
        return 
PLUGIN_HANDLED// Remove the .password XXX comand from Chat
    
}
    return 
PLUGIN_CONTINUE;
}

public 
cmdPassword(id,level,cid)
{
    if(!
cmd_access(id,level,cid,2)) return PLUGIN_HANDLED;
    
    new 
szArgs[192];
    
read_args(szArgs,charsmax(szArgs));
    
remove_quotes(szArgs);
    
    new 
szName[32];
    
get_user_name(id,szName,charsmax(szName));
    
    if(
equali(szArgs,"^"^""))
    {
        
set_pcvar_string(g_Password,"");
        
        
client_print(0,print_chat,"[AMXX] %s Removed the Password to server!",szName);
        
        return 
PLUGIN_HANDLED;
    }
    else
    {
        
set_pcvar_string(g_Password,szArgs);
        
        
client_print(0,print_chat,"[AMXX] %s Added a new Password to server!",szName);
    }
    
    return 
PLUGIN_CONTINUE;


Use .password XXXX to add, and .password "" to remove the server pass

:)

jimaway 05-21-2013 16:18

Re: help with say cmd
 
sv_password is not a command, therefore you cannot use server_cmd native to change its value

kimilover 05-22-2013 06:37

Re: help with say cmd
 
Quote:

Originally Posted by ^SmileY (Post 1955722)
PHP Code:

#include <amxmodx>
#include <amxmisc>

new g_Password;

public 
plugin_init()
{
    
register_plugin("Simple Password",AMXX_VERSION_STR,"SmileY");
    
    
g_Password get_cvar_pointer("sv_password");
    
    
register_clcmd("say","cmd_SAY");
    
register_clcmd("say_team","cmd_SAY");
    
    
// To remove a password using this comand, using .password "" (With the double quotes "")
    
register_concmd(".password","cmdPassword",ADMIN_PASSWORD,".password <Password>");
}

public 
cmd_SAY(id)
{
    new 
szArgs[192];
    
read_args(szArgs,charsmax(szArgs));
    
remove_quotes(szArgs);
    
    if(
szArgs[0] == '.')
    {
        
client_cmd(id,szArgs);
        
        return 
PLUGIN_HANDLED// Remove the .password XXX comand from Chat
    
}
    return 
PLUGIN_CONTINUE;
}

public 
cmdPassword(id,level,cid)
{
    if(!
cmd_access(id,level,cid,2)) return PLUGIN_HANDLED;
    
    new 
szArgs[192];
    
read_args(szArgs,charsmax(szArgs));
    
remove_quotes(szArgs);
    
    new 
szName[32];
    
get_user_name(id,szName,charsmax(szName));
    
    if(
equali(szArgs,"^"^""))
    {
        
set_pcvar_string(g_Password,"");
        
        
client_print(0,print_chat,"[AMXX] %s Removed the Password to server!",szName);
        
        return 
PLUGIN_HANDLED;
    }
    else
    {
        
set_pcvar_string(g_Password,szArgs);
        
        
client_print(0,print_chat,"[AMXX] %s Added a new Password to server!",szName);
    }
    
    return 
PLUGIN_CONTINUE;


Use .password XXXX to add, and .password "" to remove the server pass

:)

thx for your time.but i want to know what i am doing wrong with my code because i am intresting to learn pawn language.

^SmileY 05-22-2013 08:42

Re: help with say cmd
 
First off all, efficiency !
You need to use a natives from get admin rights, like in amxmisc include.
Second, post the whole code using a [PHP] tag or [CODE] tag :)

For hook a say command you need to custom function, to hook the first char '.' and put as console command.

see the amxmodx documentation for more info, or look this: https://forums.alliedmods.net/showthread.php?t=207106

kimilover 05-22-2013 09:17

Re: help with say cmd
 
Quote:

Originally Posted by ^SmileY (Post 1956258)
First off all, efficiency !
You need to use a natives from get admin rights, like in amxmisc include.
Second, post the whole code using a [PHP] tag or [CODE] tag :)

For hook a say command you need to custom function, to hook the first char '.' and put as console command.

see the amxmodx documentation for more info, or look this: https://forums.alliedmods.net/showthread.php?t=207106

thx my friend.

.Dare Devil. 05-23-2013 15:27

Re: help with say cmd
 
Quote:

Originally Posted by jimaway (Post 1955919)
sv_password is not a command, therefore you cannot use server_cmd native to change its value

yes you can.


All times are GMT -4. The time now is 16:27.

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