Left 4 Dead 2

Left 4 Dead 2

Left 4 Lib
Kerouha 24. jan. 2023 kl. 11:35
Adding custom chat/damage hooks
Since this addon seems to provide hijack? hook functionality, it would be great to know how to add custom chat checks and whatever.

The piece of code below does not seem to do anything on dedicated server if a player connects and types in chat. If you "say" through server console, it only complains about "InterceptChat with null speaker"

::Dir_Query <- function (msg, speaker) { Msg("=====HELLO====="); local steamid = speaker.GetNetworkIDString(); printl(steamid); if ( msg.find("dirq") != null ) { printl("he said the thing"); } return true; } HooksHub.SetInterceptChat("DQ", ::Left4Bots.InterceptChat); printl("i ran")
< >
Viser 1-2 af 2 kommentarer
Kerouha 24. jan. 2023 kl. 13:19 
nvm, i commited the big dumb

If anyone's interested, here's an example of how you do chat hooks:

::My_Custom_Func <- function (msg, speaker) { if ( msg.find("qdir") != null ) //we have magic word? { local ply_name = speaker.GetPlayerName(); printl(ply_name + " said the magic word!!!"); return false; } else { return true; } } HooksHub.SetInterceptChat("MyFunc", ::My_Custom_Func);
smilzo  [udvikler] 29. jan. 2023 kl. 0:46 
Yes you can add your own hooks if you want. The required addon is just Left 4 Lib, Left 4 Bots isn't even needed for that. Just make sure to use a unique "MyFunc" name in SetInterceptChat, so you don't replace someone else's hook.
Sidst redigeret af smilzo; 29. jan. 2023 kl. 0:47
< >
Viser 1-2 af 2 kommentarer
Per side: 1530 50