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

problem while handling a say command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Cader
Senior Member
Join Date: Mar 2007
Old 05-18-2009 , 20:48   problem while handling a say command
Reply With Quote #1

I want to make a command that changes server's current password immediately. A say command like; .svpass <newPassword>

I made a code that works but not properly. If I use "say .svpass 12345" via console, it works. But it doesnt when I try do this by pressing "y" key to say, then type .svpass 12345 , nothing happens.

Here is what I coded :

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

public plugin_init()
{
        
register_plugin(PLUGINVERSIONAUTHOR)
        
register_clcmd("say .svpass""pass")
}


public 
pass (id) {
new 
newpass[32]
read_argv(1newpass31)
server_cmd("sv_password %s"newpass)
return 
PLUGIN_HANDLED

Cader is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 05-18-2009 , 21:32   Re: problem while handling a say command
Reply With Quote #2

edit:

tested and works:
PHP Code:
#include <amxmodx>
 
#define SVPASS_CMD ".svpass"
#define SVPASS_LEN 7 // how many chars the cmd has
 
public plugin_init() 
{
    
register_clcmd("say""hookSay")
}
 
public 
hookSay(id)
{
    static 
msg[192]
 
    
read_args(msg191)
    
remove_quotes(msg)
    
trim(msg)
 
    if(!
equali(msgSVPASS_CMDSVPASS_LEN))
        return 
PLUGIN_CONTINUE
 
    copy
(msg191msg[SVPASS_LEN+1]) // remove the ".svpass" from string
 
    
server_cmd("sv_password ^"%s^""msg)
 
    
client_print(0print_chat"(test) Server password changed to: %s"msg// you can remove this
 
    
return PLUGIN_HANDLED

__________________

Last edited by Hunter-Digital; 05-18-2009 at 21:42.
Hunter-Digital is offline
Cader
Senior Member
Join Date: Mar 2007
Old 05-18-2009 , 21:40   Re: problem while handling a say command
Reply With Quote #3

hmm, maybe it works. But I didn't like this method. Do we have to catch svpass in this way? Coz I have more "say" commands and I dont want to use all in one function and using if/elses
Cader is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 05-18-2009 , 21:45   Re: problem while handling a say command
Reply With Quote #4

You could use just IF

PHP Code:
public hookSay(id)
{
    static 
msg[192]
 
    
read_args(msg191)
    
remove_quotes(msg)
    
trim(msg)
 
    if(
equali(msgSVPASS_CMDSVPASS_LEN))
    {
        
copy(msg191msg[SVPASS_LEN+1])
        
server_cmd("sv_password ^"%s^""msg)
        
client_print(0print_chat"(test) Server password changed to: %s"msg)
 
        return 
PLUGIN_HANDLED
    
}
 
    if(
equali(msg".hostname"9))
    {
        
copy(msg191msg[9])
        
server_cmd("hostname ^"%s^""msg)
 
        return 
PLUGIN_HANDLED
    
}
 
    return 
PLUGIN_CONTINUE

Anyway, another method I do not know, search through plugins that does this thing you want and see their methods
__________________
Hunter-Digital is offline
Cader
Senior Member
Join Date: Mar 2007
Old 05-18-2009 , 22:06   Re: problem while handling a say command
Reply With Quote #5

thank you anyway, is it possible to use more than one register to "say" command? like ;

public plugin_init()
{
register_clcmd("say", "SVPass")
register_clcmd("say", "HostName")
}
Cader is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-18-2009 , 22:32   Re: problem while handling a say command
Reply With Quote #6

Yes (I think, try it and find out). Also, I don't see why your first code won't work.
__________________
fysiks is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 05-18-2009 , 23:56   Re: problem while handling a say command
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
Also, I don't see why your first code won't work.
it's because you can't retrieve any other arguments from the say command, except for all arguments together like Hunter-Digital did, and then you need to separate each word.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-19-2009 , 19:27   Re: problem while handling a say command
Reply With Quote #8

Quote:
Originally Posted by Dores View Post
it's because you can't retrieve any other arguments from the say command, except for all arguments together like Hunter-Digital did, and then you need to separate each word.
Oh, I get it now . Thanks for the explaination.
__________________
fysiks is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 05-19-2009 , 23:57   Re: problem while handling a say command
Reply With Quote #9

lol, sorry, but i don't really know why it's like that, i just know it is.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
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 07:10.


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