AlliedModders

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

TudorLaLeagane 12-28-2018 07:19

Help with "say /" comands
 
Hi! I have a problem, how can i read the args from a "say /" command? Here is my code:

Code:

register_clcmd("say /testarg","CmdTestArg")
Code:

public CmdTestArg(id)
{
        if(!is_user_admin(id))
                return PLUGIN_HANDLED
               
        new arg1[64],arg2[64]
        read_argv(2,arg1,charsmax(arg1))
        read_argv(3,arg2,charsmax(arg2))
        chat_color(id,"!y[MESAJUL] !g: !y%s !g%s",arg1,arg2)
        return PLUGIN_CONTINUE
}


when i write in console "say /testarg 1 2" It works, but when i type with Y it doesn't work

OciXCrom 12-28-2018 08:38

Re: Help with "say /" comands
 
Hook the "say" command itself and use "read_args" and "parse" to take the arguments.

iceeedr 12-28-2018 08:39

Re: Help with "say /" comands
 
Quote:

Originally Posted by TudorLaLeagane (Post 2631414)
Hi! I have a problem, how can i read the args from a "say /" command? Here is my code:

Code:

register_clcmd("say /testarg","CmdTestArg")
Code:

public CmdTestArg(id)
{
        if(!is_user_admin(id))
                return PLUGIN_HANDLED
               
        new arg1[64],arg2[64]
        read_argv(2,arg1,charsmax(arg1))
        read_argv(3,arg2,charsmax(arg2))
        chat_color(id,"!y[MESAJUL] !g: !y%s !g%s",arg1,arg2)
        return PLUGIN_CONTINUE
}


when i write in console "say /testarg 1 2" It works, but when i type with Y it doesn't work

If a player has a bind such as bind "b" "say /command blabla", then arg 1 will be /command and arg 2 will be blabla, but if he types /command blabla via "y" key then arg1 will be "/command blabla"

That's why the only method that should be used is read_args(said, charsmax(said)) + remove_quotes( said ) and then you have to parse args with the method you want.

TudorLaLeagane 12-28-2018 13:24

Re: Help with "say /" comands
 
It still doesn't work...
Code:

public CmdTestArg(id)
{
        if(!is_user_admin(id))
                return PLUGIN_HANDLED
               
        new msg[256]
        read_args(msg,charsmax(msg))
        new Arg0[15], Arg1[33],Arg2[33]
        parse(msg,Arg0,14,Arg1,32,Arg2,32)
        chat_color(id,"!y[MESAJUL] !g: !y%s !g%s",Arg1,Arg2)
        return PLUGIN_CONTINUE
}


iceeedr 12-28-2018 13:38

Re: Help with "say /" comands
 
Explain what you are trying to do. Here's an example for you.
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "arsmi"


public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_clcmd("say""Say_Cmmds")

}

public 
Say_Cmmds(id)
{
    new 
szMessage[192
    
read_args(szMessagecharsmax(szMessage)) 
    
remove_quotes(szMessage)
    
    if(
equali(szMessage,".teste"))
    {
        
//do something
        
return PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE



TudorLaLeagane 12-28-2018 14:07

Re: Help with "say /" comands
 
I just want to take 2 strings and show them in chat.

iceeedr 12-28-2018 18:20

Re: Help with "say /" comands
 
Quote:

Originally Posted by TudorLaLeagane (Post 2631465)
I just want to take 2 strings and show them in chat.

It is not the ideal code, but it gives you an idea.

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Bruno"


public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_clcmd("say""Say_Cmmds")

}

public 
Say_Cmmds(id)
{
    new 
szMessage[192], Arg0[10], Arg1[10], Arg2[10]
    
read_args(szMessagecharsmax(szMessage)) 
    
remove_quotes(szMessage)
    
    
parse(szMessageArg0charsmax(Arg0), Arg1charsmax(Arg1), Arg2charsmax(Arg2))
    
    if(
Arg0[0] == '/')
    {
        
client_print(idprint_chat"%s - %s"Arg1Arg2)
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE




All times are GMT -4. The time now is 07:32.

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