Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SendUserMessage error when calling clientside #1626

Merged
merged 2 commits into from
Mar 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 26 additions & 30 deletions garrysmod/lua/includes/modules/usermessage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,31 @@ local umsg = umsg
--]]
function SendUserMessage( name, ply, ... )

umsg.Start( name, ply )

for k, v in pairs( {...} ) do

local t = type( v )

if ( t == "string" ) then
umsg.String( v )
elseif ( IsEntity( v ) ) then
umsg.Entity( v )
elseif ( t == "number" ) then
umsg.Long( v )
elseif ( t == "Vector" ) then
umsg.Vector( v )
elseif ( t == "Angle" ) then
umsg.Angle( v )
elseif ( t == "boolean" ) then
umsg.Bool( v )
else
ErrorNoHalt( "SendUserMessage: Couldn't send type "..t.."\n" )
if ( SERVER ) then
umsg.Start( name, ply )

for k, v in ipairs( {...} ) do
local t = TypeID( v )

if ( t == TYPE_STRING ) then
umsg.String( v )
elseif ( t == TYPE_ENTITY ) then
umsg.Entity( v )
elseif ( t == TYPE_NUMBER ) then
umsg.Long( v )
elseif ( t == TYPE_VECTOR ) then
umsg.Vector( v )
elseif ( t == TYPE_ANGLE ) then
umsg.Angle( v )
elseif ( t == TYPE_BOOL ) then
umsg.Bool( v )
else
ErrorNoHalt( "SendUserMessage: Couldn't send type "..type( v ).."\n" )
end
end

umsg.End()
end

umsg.End()

end

Expand Down Expand Up @@ -64,11 +65,6 @@ end
-----------------------------------------------------------]]
function Hook( messagename, func, ... )

if ( SERVER ) then
umsg.PoolString( messagename )
return
end

Hooks[ messagename ] = {}

Hooks[ messagename ].Function = func
Expand All @@ -83,12 +79,12 @@ end
function IncomingMessage( MessageName, msg )

if ( Hooks[ MessageName ] ) then

Hooks[ MessageName ].Function( msg, unpack(Hooks[ MessageName ].PreArgs) )
return

end

Msg("Warning: Unhandled usermessage '"..MessageName.."'\n")

end
Expand Down