Raised This Month: $ Target: $400
 0% 

Catch say


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Artifact
Veteran Member
Join Date: Jul 2010
Old 06-28-2012 , 13:28   Catch say
Reply With Quote #1

How to catch when someone type in chat /playername
ex my name is wow and when someone type /wow to get information of my fps
__________________
Artifact is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-28-2012 , 13:40   Re: Catch say
Reply With Quote #2

I was actually just wondering this....I was thinking that maybe you can do a register_clcmd("say /", "HandleSay") then grab the name as the argument with arg[1]. But i'm not sure if "say /" will ever get called. If not....you can always do it as a console command....
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
Artifact
Veteran Member
Join Date: Jul 2010
Old 06-28-2012 , 14:06   Re: Catch say
Reply With Quote #3

Or register just say and arg[1] = "/" because "say /" be like this
Code:
 say / wow
and we dont want space :p
__________________

Last edited by Artifact; 06-28-2012 at 14:07.
Artifact is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-28-2012 , 16:41   Re: Catch say
Reply With Quote #4

here is some code to give you a hand....
Code:
//init
register_clmd("say", "cmdPM")

public cmdPM(id)
{
	if(!get_pcvar_num(toggle_pcvar) )
		return PLUGIN_CONTINUE
		
	new args[200]; read_args(args, charsmax(args) )
	remove_quotes(args)	// take the raw string
	
	if(args[0] == '/')	// make sure it starts with a /
	{
				// This will get the player index from the defined name
		new player = cmd_target(id, args[1], CMDTARGET_NO_BOTS)
		
		(!player) ? client_print(id, print_chat, "%L", id, "INVALID_PLAYER", target[1]) : displayInfo(player, id)
	}

	return PLUGIN_HANDLED_MAIN
}
Quote:
/wow
This will print that it is a command, the user's ID, and the user's name. I'm still working on it....but that's what i have so far. (its going into one of my plugins as well) it should work fine for you.

EDIT: i edited above's code to be better looking, and working for your use. I C/P'd from my code (which includes ML tag- you can remove that) You'll have to define displayInfo(target, id) yourself to include what you want to display to the caller (id) about the person they want to know (target). It works beautifully, i must say.
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 06-30-2012 at 11:12. Reason: Made code more elegant.
Liverwiz is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-28-2012 , 18:46   Re: Catch say
Reply With Quote #5

Quote:
Originally Posted by Liverwiz View Post
I was actually just wondering this....I was thinking that maybe you can do a register_clcmd("say /", "HandleSay") then grab the name as the argument with arg[1]. But i'm not sure if "say /" will ever get called. If not....you can always do it as a console command....
This will not work. Your second post is correct with the exception of registering the command. You should use register_clcmd() for "say".
__________________
fysiks is offline
Old 06-28-2012, 18:53
Liverwiz
This message has been deleted by Liverwiz. Reason: nvmd, misread
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-28-2012 , 19:00   Re: Catch say
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
You should use register_clcmd() for "say".
Code Updated.

It should be noted that this will tamper with any other commands you have bound to say / w/e. I just found this out, and will be changing it to an ! as the key.

EDIT: code updated again. To mitigate the above mentioned issue.
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 06-28-2012 at 19:46.
Liverwiz is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-29-2012 , 01:35   Re: Catch say
Reply With Quote #7

Quote:
// This will get the userID from the defined name
I think you randmoly wrote userID, this is confusing because of #userid thing that is a different thing.
Better to write 'player index'.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-29-2012 , 01:52   Re: Catch say
Reply With Quote #8

Quote:
Originally Posted by ConnorMcLeod View Post
I think you randmoly wrote userID, this is confusing because of #userid thing that is a different thing.
Better to write 'player index'.
damnit, you know what cmd_target does. Though to someone who doesn't.....they shouldn't be dicking around in the code anyway.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-29-2012 , 02:25   Re: Catch say
Reply With Quote #9

Quote:
Originally Posted by Liverwiz View Post
damnit, you know what cmd_target does. Though to someone who doesn't.....they shouldn't be dicking around in the code anyway.
This is irrelevant since you are answering to someone asking help in scripting forum, your answer shouldn't be confusing.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 06-29-2012 , 07:39   Re: Catch say
Reply With Quote #10

PHP Code:
new args[200]; 
Just to mention - the maximum lenght of a chat message is 191 symbols (array size 192).
__________________
<VeCo> 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 06:06.


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