Skip to content

Commit

Permalink
Added GM:IncomingNetworkMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown-gd committed Feb 19, 2024
1 parent 6de68bf commit eddabbd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]**
Expand Down
10 changes: 9 additions & 1 deletion lua/includes/extensions/net.yue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit eddabbd

Please sign in to comment.