Raised This Month: $ Target: $400
 0% 

How can I retrieve what a client say's with say command?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Reel mafioso
Member
Join Date: Oct 2014
Location: wouldn't you like to kno
Old 05-11-2015 , 05:39   How can I retrieve what a client say's with say command?
Reply With Quote #1

So I'm working on a difficulty system which a client uses say commands like !easy or !extra etc. to change difficulty. Currently it's a big code with 7 functions, each dedicated to changing difficulty. 1 function is for easy, 1 for hard and so on. I want to, instead of having 7, have only 1 with a switch loop and use "!easy" "!hard" and so on as a CASE. Is there a way to do this?

Last edited by Reel mafioso; 05-11-2015 at 05:40.
Reel mafioso is offline
Shiina.Mashiro
Senior Member
Join Date: Sep 2014
Location: Vietnam
Old 05-11-2015 , 10:11   Re: How can I retrieve what a client say's with say command?
Reply With Quote #2

not quite sure about this, and didnt test yet
PHP Code:
public plugin_init()
{
    
register_clcmd("say""handle_say")
}
public 
handle_say(id)
{
    new 
arg[10]
    
read_args(argcharsmax(arg))
    
remove_quotes(arg)
    switch(
arg)
    {
        case 
"!easy":
        
//// so on
    
}

__________________
Shiina.Mashiro is offline
Freezo Begin
BANNED
Join Date: Mar 2014
Location: Morocco
Old 05-11-2015 , 11:11   Re: How can I retrieve what a client say's with say command?
Reply With Quote #3

Quote:
Originally Posted by Shiina.Mashiro View Post
not quite sure about this, and didnt test yet
PHP Code:
public plugin_init()
{
    
register_clcmd("say""handle_say")
}
public 
handle_say(id)
{
    new 
arg[10]
    
read_args(argcharsmax(arg))
    
remove_quotes(arg)
    switch(
arg)
    {
        case 
"!easy":
        
//// so on
    
}


Switch string isnt supported in pawn perhaps other lang like ... ( c# . vb . Java ... ) . Anyway change the size of args because it will read the args not the unique cmd . Use a check for string equali() ...
or just handle it it will be better ...

Last edited by Freezo Begin; 05-11-2015 at 11:29.
Freezo Begin is offline
xEhsaan
Member
Join Date: Mar 2015
Location: Isfahan, Iran
Old 05-11-2015 , 11:24   Re: How can I retrieve what a client say's with say command?
Reply With Quote #4

Example #1 is for using clcmd directly for handling certain commands.
Example #2 is for handling them with register_event

#1:
PHP Code:
public plugin_init() {
register_clcmd"say !easy""Handle_Easy" )
register_clcmd"say !medium""Handle_Medium" )
//...
}
public 
Handle_Easy(){
//...
}
public 
Handle_Medium(){
//...

#2:
PHP Code:
public plugin_init(){
register_event("SayText""Handler");
}

public 
Handler() {
new 
arg[10]
read_args(argcharsmax(arg))
remove_quotes(arg)

if ( 
equaliarg"!easy" ) )
// handle easy

if ( equaliarg"!medium" ) )
// handle med

//...

Hope you success in your coding ;)
Good luck.
__________________
* Wait for something awesome...
* AMX Mod X Plugin Translation Repository [Paused Temporarily]
* Knife Deathmatch Shop
* Knife CFG Detector
* Looking for an idea...
xEhsaan is offline
Send a message via Skype™ to xEhsaan
Reel mafioso
Member
Join Date: Oct 2014
Location: wouldn't you like to kno
Old 05-11-2015 , 14:53   Re: How can I retrieve what a client say's with say command?
Reply With Quote #5

Quote:
Originally Posted by xEhsaan View Post
Example #1 is for using clcmd directly for handling certain commands.
Example #2 is for handling them with register_event

#1:
PHP Code:
public plugin_init() {
register_clcmd"say !easy""Handle_Easy" )
register_clcmd"say !medium""Handle_Medium" )
//...
}
public 
Handle_Easy(){
//...
}
public 
Handle_Medium(){
//...

#2:
PHP Code:
public plugin_init(){
register_event("SayText""Handler");
}

public 
Handler() {
new 
arg[10]
read_args(argcharsmax(arg))
remove_quotes(arg)

if ( 
equaliarg"!easy" ) )
// handle easy

if ( equaliarg"!medium" ) )
// handle med

//...

Hope you success in your coding ;)
Good luck.
Wow thanks! It worked just like I wanted it to. Although little not, xEhsaan, register_event didn't work for me (it kept saying invalid number of arguments, even though i quadruple checked I typed it correctly). So I had to use
Code:
register_clcmd("say", "set_lvl");
Thanks Shiina.Mashiro for the idea on the first one!
Reel mafioso is offline
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 05-11-2015 , 23:45   Re: How can I retrieve what a client say's with say command?
Reply With Quote #6

@Reel mafioso
just change this on the xEhsaan code

PHP Code:
register_event("SayText""Handler"); 

PHP Code:
register_clcmd("say""Handler"); 
and
PHP Code:
public Handler() 

PHP Code:
public Handler(id
__________________
Thanks everyone. #miss_you_all

Last edited by indraraj striker; 05-11-2015 at 23:45.
indraraj striker is offline
Reel mafioso
Member
Join Date: Oct 2014
Location: wouldn't you like to kno
Old 05-12-2015 , 01:43   Re: How can I retrieve what a client say's with say command?
Reply With Quote #7

Quote:
Originally Posted by indraraj striker View Post
@Reel mafioso
just change this on the xEhsaan code

PHP Code:
register_event("SayText""Handler"); 

PHP Code:
register_clcmd("say""Handler"); 
and
PHP Code:
public Handler() 

PHP Code:
public Handler(id
Yes, I had done exactly such. But I just named Handler to set_lvl which is the name of the function that changes difficulty.
Reel mafioso 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 16:19.


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