roflmuffin / CounterStrikeSharp

CounterStrikeSharp allows you to write server plugins in C# for Counter-Strike 2/Source2/CS2
https://docs.cssharp.dev
Other
714 stars 111 forks source link

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

Open maggiduscher opened 2 months ago

maggiduscher commented 2 months ago

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

Lidbetter commented 2 months ago

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

roflmuffin commented 2 months ago

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.