Skip to content

Commit eddabbd

Browse files
committed
Added GM:IncomingNetworkMessage
1 parent 6de68bf commit eddabbd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
A faster and more performance version of the Garry's Mod `net` library with additional cool features.
33

44
### Basic Changes
5+
- GM:IncomingNetworkMessage( `string` networkString, `number` length, `Player/NULL` ply ) - if return here `false` then callbacks will not be called. **[SERVER/CLIENT]**
56
- `net.Receive` - has an additional third optional argument `string` "identifier" used for multiple receive callbacks. **[SERVER/CLIENT]**
67
- `net.Start` - automatically creates network strings on the server without using `util.AddNetworkString`. **[SERVER]**
78
- `net.StartX` - default `net.Start`. **[SERVER]**

lua/includes/extensions/net.yue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ TypeID = TypeID
77
NULL = NULL
88

99
global TYPE_COLOR = 255
10+
require( "hook" )
11+
12+
-- ULib support ( I really don't like this )
13+
if file.Exists( "ulib/shared/hook.lua", "LUA" )
14+
include( "ulib/shared/hook.lua" )
1015

1116
-- Type writing
1217
typesToWrite = net.TypesToWrite
@@ -113,15 +118,18 @@ do
113118
-- Network string callback performing
114119
do
115120

116-
117121
:NetworkIDToString = util
118122
:ReadHeader = net
123+
:Run = hook
119124

120125
net.Incoming = ( length, client ) ->
121126
networkString = NetworkIDToString( ReadHeader! )
122127
if networkString == nil
123128
return
124129

130+
if Run( "IncomingNetworkMessage", networkString, length, client or NULL ) == false
131+
return
132+
125133
functions = receivers[ lower( networkString ) ]
126134
if functions == nil
127135
return

0 commit comments

Comments
 (0)