Raised This Month: $ Target: $400
 0% 

Help with "say /" comands


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TudorLaLeagane
Junior Member
Join Date: Mar 2018
Old 12-28-2018 , 07:19   Help with "say /" comands
Reply With Quote #1

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
TudorLaLeagane is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-28-2018 , 08:38   Re: Help with "say /" comands
Reply With Quote #2

Hook the "say" command itself and use "read_args" and "parse" to take the arguments.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 12-28-2018 , 08:39   Re: Help with "say /" comands
Reply With Quote #3

Quote:
Originally Posted by TudorLaLeagane View Post
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.
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
TudorLaLeagane
Junior Member
Join Date: Mar 2018
Old 12-28-2018 , 13:24   Re: Help with "say /" comands
Reply With Quote #4

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
}
TudorLaLeagane is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 12-28-2018 , 13:38   Re: Help with "say /" comands
Reply With Quote #5

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

__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/

Last edited by iceeedr; 12-28-2018 at 13:38.
iceeedr is offline
Send a message via Skype™ to iceeedr
TudorLaLeagane
Junior Member
Join Date: Mar 2018
Old 12-28-2018 , 14:07   Re: Help with "say /" comands
Reply With Quote #6

I just want to take 2 strings and show them in chat.
TudorLaLeagane is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 12-28-2018 , 18:20   Re: Help with "say /" comands
Reply With Quote #7

Quote:
Originally Posted by TudorLaLeagane View Post
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

__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/

Last edited by iceeedr; 12-28-2018 at 18:21.
iceeedr is offline
Send a message via Skype™ to iceeedr
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:32.


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