Left 4 Dead 2

Left 4 Dead 2

Left 4 Lib
Kerouha 2023 年 1 月 24 日 上午 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")
< >
正在显示第 1 - 2 条,共 2 条留言
Kerouha 2023 年 1 月 24 日 下午 1: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  [开发者] 2023 年 1 月 29 日 上午 12: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.
最后由 smilzo 编辑于; 2023 年 1 月 29 日 上午 12:47
< >
正在显示第 1 - 2 条,共 2 条留言
每页显示数: 1530 50