Raised This Month: $ Target: $400
 0% 

[CSGO] say/say_team listener problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lechoo
Member
Join Date: Jul 2010
Location: Poland
Old 04-25-2015 , 05:51   [CSGO] say/say_team listener problem
Reply With Quote #1

Hello guys. I have problem with a listener in my plugin. This is part of my code (everything else is working, so I just give part of it. I know it's not the optimal way at all, but ''working, so fuk it''). In this part user should send to chat 3 numbers from 0 to 255 (those numbers are used to set color of TE_SetupBeamPoints).

Code:
public Action:HookPlayerChat(client, const String:command[], args)
{
    if(waitingForInput[client]==true)
    {
        if(StrEqual(command, "say") || StrEqual(command, "say_team"))
        {
            if(GetCmdArgs()==3)
            {
                new color1,color2,color3;
                decl String:arg1[4];decl String:arg2[4];decl String:arg3[4];
                GetCmdArg(1,arg1,sizeof(arg1));
                GetCmdArg(2,arg2,sizeof(arg2));
                GetCmdArg(3,arg3,sizeof(arg3));
                color1=StringToInt(arg1,10);
                color2=StringToInt(arg2,10);
                color3=StringToInt(arg3,10);
                if(0<=color1<=255 && 0<=color2<=255 && 0<=color3<=255)
                {
                    customColor[client]=true;
                    colorOfPlayer[client][0]=color1;
                    colorOfPlayer[client][1]=color2;
                    colorOfPlayer[client][2]=color3;
                    colorOfPlayer[client][3]=255;
                    waitingForInput[client] = false;
                    PrintToChat(client,"[\x04JailBreak\x01] You have chosen: \x07Red: %d \x04Green: %d \x0CBlue: %d\x01).",color1,color2,color3);
                } else PrintToChat(client,"[\x04JailBreak\x01] Your input is wrong. Write \x09three numbers from 0 to 255\x01.");
            } else
            PrintToChat(client,"[\x04JailBreak\x01] Number of arguments do not match. Write \x09three numbers from 0 to 255\x01.");
        }
        return Plugin_Handled;
    }
    return Plugin_Continue;
}
The thing is: When I press Y or U (and ex. input "255 255 255"), I always get "Number of arguments do not match.", but if I send console command (ex. "say 255 255 255"), it is working. Why is it like this? Is there any fix?
__________________
Sorry for my bad English

Last edited by lechoo; 04-25-2015 at 05:55.
lechoo is offline
Send a message via Skype™ to lechoo
Miu
Veteran Member
Join Date: Nov 2013
Old 04-25-2015 , 07:15   Re: [CSGO] say/say_team listener problem
Reply With Quote #2

Using the chat is equivalent to the command say "255 255 255", which is one argument.

Haven't tested, but try this:

PHP Code:
decl String:buf[64], String:args[3][16];
GetCmdArgString(bufsizeof(buf));
StripQuotes(buf);
ExplodeString(buf" "argssizeof(args) / sizeof(args[]), sizeof(args[])); 
Miu is offline
lechoo
Member
Join Date: Jul 2010
Location: Poland
Old 04-25-2015 , 07:36   Re: [CSGO] say/say_team listener problem
Reply With Quote #3

Thanks, it works now. ;) I have one more question.

] say 255 255 255
] say "255 255 255"

Both written in console give the same output to chat, but with my method from first post only first console command worked. Why? Does say command without quotemarks give more than 1 arg? I kinda don't understand that.

@edit oh, I read documentation and now everything is clear. Thanks for your help, topic can be closed.
__________________
Sorry for my bad English

Last edited by lechoo; 04-25-2015 at 07:40. Reason: read documentation
lechoo is offline
Send a message via Skype™ to lechoo
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 04-25-2015 , 07:45   Re: [CSGO] say/say_team listener problem
Reply With Quote #4

Code:
command <arg1> <arg2> <arg3> ...
examples:
Code:
command 12 asd 52
arg1 = 12
arg2 = asd
arg3 = 52
Code:
command how are you?
arg1 = how
arg2 = are
arg3 = you?
Code:
command 12 "how are you?" 52
arg1 = 12
arg2 = how are you?
arg3 = 52
Undestand now?

Btw. Why dont you use actuall command it allows you to use GetCmdArg function...

Last edited by KissLick; 04-25-2015 at 07:46.
KissLick is offline
lechoo
Member
Join Date: Jul 2010
Location: Poland
Old 04-25-2015 , 07:52   Re: [CSGO] say/say_team listener problem
Reply With Quote #5

I'm using menu like this:

Choose color:
1. Red
2. Yellow
[...]
8. Custom

After pressing 8 plugin writes to client's chat "Choose 3 numbers in RGB" and starts listening his chat. After giving those 3 numbers (or writing !cancel) listening ends, and numbers are send to {R,G,B,A} array customColor[client]. I have already some ConsoleCmds in my plugin, I think I don't need more of them (especially for only 1 small function).
__________________
Sorry for my bad English
lechoo is offline
Send a message via Skype™ to lechoo
BAILANDO
Senior Member
Join Date: Feb 2015
Location: Slovakia
Old 04-25-2015 , 07:57   Re: [CSGO] say/say_team listener problem
Reply With Quote #6

it better to use if(args == 3), no?

and what you need now? menuaction for custom color? or now its fixed and works?
BAILANDO is offline
lechoo
Member
Join Date: Jul 2010
Location: Poland
Old 04-25-2015 , 08:14   Re: [CSGO] say/say_team listener problem
Reply With Quote #7

It's already fixed, everything works.
__________________
Sorry for my bad English
lechoo is offline
Send a message via Skype™ to lechoo
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 04-25-2015 , 17:08   Re: [CSGO] say/say_team listener problem
Reply With Quote #8

Use OnClientSayCommand instead of hook "say" and "say_team"
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.


Last edited by Franc1sco; 04-25-2015 at 17:09.
Franc1sco is offline
Send a message via MSN to Franc1sco
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 03:12.


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