From eddabbdb81231d50e258ccf980a020c4d3ba4067 Mon Sep 17 00:00:00 2001 From: "PrikolMen:-b" <44779902+PrikolMen@users.noreply.github.com> Date: Mon, 19 Feb 2024 08:00:59 +0400 Subject: [PATCH] Added `GM:IncomingNetworkMessage` --- README.md | 1 + lua/includes/extensions/net.yue | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e936483..fed34c8 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ A faster and more performance version of the Garry's Mod `net` library with additional cool features. ### Basic Changes +- GM:IncomingNetworkMessage( `string` networkString, `number` length, `Player/NULL` ply ) - if return here `false` then callbacks will not be called. **[SERVER/CLIENT]** - `net.Receive` - has an additional third optional argument `string` "identifier" used for multiple receive callbacks. **[SERVER/CLIENT]** - `net.Start` - automatically creates network strings on the server without using `util.AddNetworkString`. **[SERVER]** - `net.StartX` - default `net.Start`. **[SERVER]** diff --git a/lua/includes/extensions/net.yue b/lua/includes/extensions/net.yue index 654cc5a..e6b2aba 100644 --- a/lua/includes/extensions/net.yue +++ b/lua/includes/extensions/net.yue @@ -7,6 +7,11 @@ TypeID = TypeID NULL = NULL global TYPE_COLOR = 255 +require( "hook" ) + +-- ULib support ( I really don't like this ) +if file.Exists( "ulib/shared/hook.lua", "LUA" ) + include( "ulib/shared/hook.lua" ) -- Type writing typesToWrite = net.TypesToWrite @@ -113,15 +118,18 @@ do -- Network string callback performing do - :NetworkIDToString = util :ReadHeader = net + :Run = hook net.Incoming = ( length, client ) -> networkString = NetworkIDToString( ReadHeader! ) if networkString == nil return + if Run( "IncomingNetworkMessage", networkString, length, client or NULL ) == false + return + functions = receivers[ lower( networkString ) ] if functions == nil return