Raised This Month: $ Target: $400
 0% 

help with say cmd


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kimilover
Junior Member
Join Date: Oct 2010
Old 05-21-2013 , 05:06   help with say cmd
Reply With Quote #1

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
}
kimilover is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 05-21-2013 , 10:51   Re: help with say cmd
Reply With Quote #2

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

__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
kimilover
Junior Member
Join Date: Oct 2010
Old 05-22-2013 , 06:37   Re: help with say cmd
Reply With Quote #3

Quote:
Originally Posted by ^SmileY View Post
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.
kimilover is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 05-21-2013 , 16:18   Re: help with say cmd
Reply With Quote #4

sv_password is not a command, therefore you cannot use server_cmd native to change its value
jimaway is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 05-23-2013 , 15:27   Re: help with say cmd
Reply With Quote #5

Quote:
Originally Posted by jimaway View Post
sv_password is not a command, therefore you cannot use server_cmd native to change its value
yes you can.

Last edited by .Dare Devil.; 05-23-2013 at 15:27.
.Dare Devil. is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 05-22-2013 , 08:42   Re: help with say cmd
Reply With Quote #6

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
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 05-22-2013 at 08:43.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
kimilover
Junior Member
Join Date: Oct 2010
Old 05-22-2013 , 09:17   Re: help with say cmd
Reply With Quote #7

Quote:
Originally Posted by ^SmileY View Post
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.
kimilover is offline
Reply


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 16:27.


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