Raised This Month: $51 Target: $400
 12% 

Force client into messagemode say


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Crackhead69
Member
Join Date: Feb 2021
Old 04-08-2021 , 10:11   Force client into messagemode say
Reply With Quote #1

Hello!
I was wondering how can i force a player into messagemode say..
The point is to parse the string he typed into a number and then use this number for random purposes.

The only common searching keyword that came to mind regarding this issue was ZP give ammo thing, which had nothing to do with client typed number (as long as for whichever ones i found). Didn't know what exactly to search for so that's the reason for me opening the topic.

For example:
Client opens a menu -> Selects first option -> first option forces his "messagemode" to appear, and he types a number which will be printed in chat
Crackhead69 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-09-2021 , 00:48   Re: Force client into messagemode say
Reply With Quote #2

You can do it by sending the messagemode command with a custom named command to the user:

Code:
public plugin_init()
{
	register_clcmd("myCustomMsgModeCmd", "cmdCustomMsgModeCmdHandler")
}

public cmdCustomMsgModeCmdHandler(id)
{
	// react to the custom command
}

public MenuHandler(id)
{
	client_cmd(id, "messagemode myCustomMsgModeCmd")
}
Instead of "say:" being shown, you should see "myCustomMsgModeCmd:" at the top left of your screen where you would normally see the what you type for a normal chat message.
__________________

Last edited by fysiks; 04-09-2021 at 00:53.
fysiks is offline
LondoN
Senior Member
Join Date: Dec 2015
Location: Roman, Romania.
Old 04-09-2021 , 07:51   Re: Force client into messagemode say
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
You can do it by sending the messagemode command with a custom named command to the user:

Code:
public plugin_init()
{
	register_clcmd("myCustomMsgModeCmd", "cmdCustomMsgModeCmdHandler")
}

public cmdCustomMsgModeCmdHandler(id)
{
	// react to the custom command
}

public MenuHandler(id)
{
	client_cmd(id, "messagemode myCustomMsgModeCmd")
}
Instead of "say:" being shown, you should see "myCustomMsgModeCmd:" at the top left of your screen where you would normally see the what you type for a normal chat message.
i have a little question...

messagemode is not blocked by cl_filterstuffcmd?
__________________
LondoN is offline
Crackhead69
Member
Join Date: Feb 2021
Old 04-09-2021 , 08:48   Re: Force client into messagemode say
Reply With Quote #4

Quote:
Originally Posted by LondoN View Post
i have a little question...

messagemode is not blocked by cl_filterstuffcmd?
As far as i know it is not. It only blocks stuff that is not very client friendly, such as Bind and Connect.

Quote:
Originally Posted by fysiks View Post
You can do it by sending the messagemode command with a custom named command to the user:

Code:
public plugin_init()
{
	register_clcmd("myCustomMsgModeCmd", "cmdCustomMsgModeCmdHandler")
}

public cmdCustomMsgModeCmdHandler(id)
{
	// react to the custom command
}

public MenuHandler(id)
{
	client_cmd(id, "messagemode myCustomMsgModeCmd")
}
Instead of "say:" being shown, you should see "myCustomMsgModeCmd:" at the top left of your screen where you would normally see the what you type for a normal chat message.
Thank you!
Is there a way tho to make it work without another public for that ?
Like this:
PHP Code:
public plugin_init()
    
register_clcmd("say /num","test")
    
public 
test(id){
    
client_cmdid"messagemode Amount" );
    
    new 
szArgs192 ];
    
read_argsszArgscharsmaxszArgs ) );
    
remove_quotesszArgs ); 
    
    
client_print(id,print_chat,"%s",szArgs)
    
set_user_health(idstr_to_num(szArgs))

To make it continue to the rest of code only when he has first typed something
Crackhead69 is offline
nG_getwreck
Senior Member
Join Date: Oct 2020
Location: Philippines from South K
Old 04-09-2021 , 10:14   Re: Force client into messagemode say
Reply With Quote #5

Quote:
Originally Posted by LondoN View Post
i have a little question...

messagemode is not blocked by cl_filterstuffcmd?
No, its not considered as "slowhacking" command, stuffcmd blocks only slowhacking commands like: bind, connect, fps_max, fps_override, developer and etc...
__________________

Last edited by nG_getwreck; 04-09-2021 at 10:14.
nG_getwreck is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 04-09-2021 , 10:39   Re: Force client into messagemode say
Reply With Quote #6

Quote:
Originally Posted by Crackhead69 View Post
As far as i know it is not. It only blocks stuff that is not very client friendly, such as Bind and Connect.


Thank you!
Is there a way tho to make it work without another public for that ?
Like this:
PHP Code:
public plugin_init()
    
register_clcmd("say /num","test")
    
public 
test(id){
    
client_cmdid"messagemode Amount" );
    
    new 
szArgs192 ];
    
read_argsszArgscharsmaxszArgs ) );
    
remove_quotesszArgs ); 
    
    
client_print(id,print_chat,"%s",szArgs)
    
set_user_health(idstr_to_num(szArgs))

To make it continue to the rest of code only when he has first typed something
Best option would be to code all into plugin_init()
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
Crackhead69
Member
Join Date: Feb 2021
Old 04-09-2021 , 10:47   Re: Force client into messagemode say
Reply With Quote #7

Quote:
Originally Posted by JocAnis View Post
Best option would be to code all into plugin_init()
Huh?
I am not looking for players to set their health to whatever they want every time the plugin is loaded.
The script i gave was just an example of what i am trying to achieve for personal doings.
How come typing that in plugin_init would be helpful? Maybe i did not understand your idea.
Crackhead69 is offline
Old 04-09-2021, 11:00
kww
This message has been deleted by kww.
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 04-09-2021 , 11:04   Re: Force client into messagemode say
Reply With Quote #8

Quote:
Originally Posted by Crackhead69 View Post
Is there a way tho to make it work without another public for that ?
Like this:
PHP Code:
//some code... 
To make it continue to the rest of code only when he has first typed something
No way. (I think you know all this without me...) (fysiks said what u need to do)
PHP Code:
public plugin_init() {
    
// Here u are hooking if some player typed "/num" in the chat.
    // When someone types "/num", the "test(id)" function will start.
    
register_clcmd("say /num","test")

    
register_clcmd("test2","function_to_run")
    
// "test2" is command that will be shown in messagemode
    // (note: afaik only actual commands can be used in messagemode or u will get "unknown command" error,
    // so u can't use messagemode without some command.
    // if u will not add some command then u can't operate on inputted arguments)
}

public 
test(id) {
    
// as u added "test2" command, u can use "messagemode" now
    
client_cmd(id"messagemode test2");
}

public 
function_to_run(id){
    
// here u are getting arguments entered for "test2" command
    
new szArgs192 ];
    
read_argsszArgscharsmaxszArgs ) );
    
remove_quotesszArgs ); 
    
    
client_print(id,print_chat,"%s",szArgs// is it for debug?
    
set_user_health(idstr_to_num(szArgs))

Spoiler

Last edited by kww; 04-09-2021 at 11:20.
kww is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-10-2021 , 00:14   Re: Force client into messagemode say
Reply With Quote #9

Quote:
Originally Posted by JocAnis View Post
Best option would be to code all into plugin_init()
That doesn't make any sense.

Quote:
Originally Posted by Crackhead69 View Post
Is there a way tho to make it work without another public for that ?
Like this:
PHP Code:
public plugin_init()
    
register_clcmd("say /num","test")
    
public 
test(id){
    
client_cmdid"messagemode Amount" );
    
    new 
szArgs192 ];
    
read_argsszArgscharsmaxszArgs ) );
    
remove_quotesszArgs ); 
    
    
client_print(id,print_chat,"%s",szArgs)
    
set_user_health(idstr_to_num(szArgs))

To make it continue to the rest of code only when he has first typed something
No, if you create a "wait" within a single function, the server would freeze. The amount of time between when you send the messagemode command and when they provide a value is unknown and could actually be infinite (because they can cancel if they want with escape, IIRC).

messagemode sends and command to the server so it can only be hooked like other commands sent to the server like I've done it in my example. The only unfortunate part is that you're limited on what you can set as the command name.
__________________
fysiks is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 04-10-2021 , 05:44   Re: Force client into messagemode say
Reply With Quote #10

Excuse me for using irony lol

It was just a reaction, i didnt know 2 functions was too much so he needs all-in-one...but anyway, my bad, i thought it was Requests, not Helping thread
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)

Last edited by JocAnis; 04-10-2021 at 05:45.
JocAnis 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 12:05.


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