AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Chat argv's look inside. (https://forums.alliedmods.net/showthread.php?t=120469)

Lure.d 03-05-2010 06:51

Chat argv's look inside.
 
Ello there, i've got this problem:
When i try to get TWO arguments for ex:

PHP Code:

public plugin_init() {
...
     
register_clcmd("say""c_say");
     
register_clcmd("say_team""c_say");
}

public 
c_say(id) {
     new 
arg1[100];
     
readv_args(1arg1sizeof(arg1) - 1);

     
client_print(0print_chat"[TAG] %s"arg1);

     if(
contain(arg1"/settopic") != -1) {
          new 
arg2[50];
          
readv_args(2arg2sizeof(arg2) - 1);

          
client_print(0print_chat"[TAG] Topic set to: %s"arg2);
     }


It successfully gets what i type and outputs to [TAG] Text...
But if i say /settopic and it just dont get the second arg, so how to do it?
Do i have to get the second argument at very start?

EDIT: Tried putting reading arg2 on top - doesn't work.

Arkshine 03-05-2010 07:04

Re: Chat argv's look inside.
 
You don't need to register only say/say_team, register directly "say /settopic".

Lure.d 03-05-2010 11:22

Re: Chat argv's look inside.
 
You MUST understand that im making plugin that:
1. Converts original chat(%name%: %message%) -> ([TAG] %name%: %message%
2. I want it to also correspond to commands(and it does)
3. I also want it to change for ex topic...

hleV 03-05-2010 15:06

Re: Chat argv's look inside.
 
PHP Code:

#include <amxmodx>
 
public plugin_init()
{
        new const Function[] = 
"cmdSay";
 
        
register_clcmd("say", Function);
        
register_clcmd("say_team", Function);
}
 
public 
cmdSay()
{
        new 
szText[256];
        
read_args(szText255);
        
remove_quotes(szText);
 
        if (!
equali(szText"/settopic "10))
                return 
PLUGIN_CONTINUE;
 
        
client_print(0print_chat"[TAG] Topic set to: %s"szText[10]);
 
        return 
PLUGIN_HANDLED;




All times are GMT -4. The time now is 08:42.

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