CounterStrikeSharp icon indicating copy to clipboard operation
CounterStrikeSharp copied to clipboard

Typing "!e" and using "bind say !e" behaves differently

Open maggiduscher opened this issue 1 year ago • 2 comments

When you register a command with the "css_" prefix, to automatically register a chat trigger, you can't use that chat trigger in a bind or even when using "say" in the console. Example:

[ConsoleCommand("css_freeze", "Freeze Command")]

Typing "!freeze" or "/freeze" in chat works. Using "say !freeze" or "say /freeze" doesn't work. Using "bind x say !freeze" or "bind x say /freeze" doesn't work.

I'm not entirely sure, but maybe it has something to do with https://github.com/roflmuffin/CounterStrikeSharp/issues/231

maggiduscher avatar May 01 '24 19:05 maggiduscher

I looked into this a while ago, it's something to do with tokenization

if you do say !!freeze in console (where iirc the first ! can be any non-space char) it will work

I think the right place to confirm / fix this is in DetourHostSay (src/core/managers/chat_manager.cpp) and looking at the value of args before/after retokenization when a !command is typed in chat vs say !command in console

Lidbetter avatar May 01 '24 19:05 Lidbetter

It is due to tokenization but I'm also not inclined to fix it at this stage as its a high impact change without compat. I would just say bind key css_freeze instead.

roflmuffin avatar May 02 '24 01:05 roflmuffin