Left 4 Dead 2

Left 4 Dead 2

Left 4 Lib
Kerouha Jan 24, 2023 @ 11:35am
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")
< >
Showing 1-2 of 2 comments
Kerouha Jan 24, 2023 @ 1:19pm 
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  [developer] Jan 29, 2023 @ 12:46am 
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.
Last edited by smilzo; Jan 29, 2023 @ 12:47am
< >
Showing 1-2 of 2 comments
Per page: 1530 50