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

Solved How to intercept text entered in console?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 04-23-2020 , 03:36   How to intercept text entered in console?
Reply With Quote #1

Hi,

what function should I detour to have ability to catch (and ideally, modify) my own entered text in game console ~, like "aaaaaaaaaaaaaa":

Quote:
] aaaaaaaaaaaaaa
Unknown command "aaaaaaaaaaaaaa"
I want replace with other text before game and sm search for existance of appropriate command.

Or at least catch it.

Thank you.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 04-26-2020 at 08:39.
Dragokas is offline
Balimbanana
Member
Join Date: Jan 2017
Old 04-24-2020 , 00:40   Re: How to intercept text entered in console?
Reply With Quote #2

Similar to a registered command, this global callback will catch a majority of commands and allows for returns.
Code:
public Action OnClientCommand(int client, int args)
{
	char cmd[64];
	GetCmdArg(0,cmd,sizeof(cmd));
	if (StrContains(cmd,"aaa",false) == 0)
	{
		PrintToConsole(client,"%s not registered, but there is another similar command named <aabbcc>.",cmd);
		return Plugin_Handled;
	}
	return Plugin_Continue;
}
While it won't catch a lot of client-side commands, a majority of the unregistered commands will. You might just have to test to see if it can do what you want it to.

Last edited by Balimbanana; 04-24-2020 at 00:46.
Balimbanana is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 04-24-2020 , 03:53   Re: How to intercept text entered in console?
Reply With Quote #3

Ouuuuu, that is exactly what I want. Thanks for let me know.

And, damn it, Valve doesn't support cyrillic letters in console when the arey at 0 argument.

Always return srange 0xD0. So, looks like still required to go deep in low-level.
Attached Images
File Type: jpg cyr.jpg (4.2 KB, 68 views)
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 04-24-2020 at 04:03.
Dragokas is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 04-24-2020 , 09:54   Re: How to intercept text entered in console?
Reply With Quote #4

Just put a null terminator at the beginning of the string of the reply message?
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 04-24-2020 , 10:01   Re: How to intercept text entered in console?
Reply With Quote #5

I dunno, what you are talking about.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 04-24-2020 , 10:05   Re: How to intercept text entered in console?
Reply With Quote #6

Me nither sorry i was doing 5 things at once

https://github.com/Bara/BlockSMPlugi.../master/DHooks

You should beable to use this as a base to change cmds.
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 04-24-2020 , 10:08   Re: How to intercept text entered in console?
Reply With Quote #7

It looks like he hooks for "ClientPrintf ... function, intended to print console text.

I think that can't help me because in my case valve already broke that text.

I need to hook previous function that accept my text before handling and answering me in console.

Anyway, thanks for help.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 04-24-2020 at 10:15.
Dragokas is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 04-24-2020 , 10:29   Re: How to intercept text entered in console?
Reply With Quote #8

Ahh i see, you may wanna look at where sm does cmd listeners or the OnClientCmd func ect

https://github.com/alliedmodders/sou...pp#L1128-L1240

or move the "sm" cmd check below allow sourcemod plugins to change stuff before anywhere else and build sm with your change.
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D

Last edited by Lux; 04-24-2020 at 10:29.
Lux is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 04-24-2020 , 12:20   Re: How to intercept text entered in console?
Reply With Quote #9

Thanks, I lookup vice versa call chain.

I leave it here for myself.

sm:
PHP Code:
IServerGameClients *serverClients NULL;
...
GET_V_IFACE_CURRENT(GetServerFactoryserverClientsIServerGameClientsINTERFACEVERSION_SERVERGAMECLIENTS);
...
SH_DECL_HOOK2_void(IServerGameClientsClientCommandSH_NOATTRIB0edict_t *, const CCommand &);
...
SH_ADD_HOOK(IServerGameClientsClientCommandserverClientsSH_MEMBER(this, &PlayerManager::OnClientCommand), false); 
Valve SDK:
PHP Code:
EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CServerGameClientsIServerGameClientsINTERFACEVERSION_SERVERGAMECLIENTSg_ServerGameClients ); 
Problem should be somewhere here:

https://github.com/VSES/SourceEngine...face.cpp#L2367

PHP Code:
void CServerGameClients::ClientCommandedict_t *pEntity, const CCommand &args )
{
    
CBasePlayer *pPlayer ToBasePlayerGetContainingEntitypEntity ) );
    ::
ClientCommandpPlayerargs );

https://github.com/VSES/SourceEngine...e/cmd.cpp#L765

PHP Code:
const ConCommandBase *Cmd_ExecuteCommand( const CCommand &commandcmd_source_t srcint nClientSlot 

https://github.com/VSES/SourceEngine...lient.cpp#L995

PHP Code:
bool CGameClient::ExecuteStringCommand( const char *pCommandString 
Some sigs from L4D2 linux:
Spoiler
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 04-24-2020 at 12:28.
Dragokas is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 04-26-2020 , 08:39   Re: How to intercept text entered in console?
Reply With Quote #10

Solved. Perhaps, it is a SourceMod bug: https://github.com/alliedmodders/sourcemod/issues/1248
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas 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 18:15.


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