Skip to content
New issue

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

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

Already on GitHub? # to your account

User messages are obsolete #92

Open
dvdvideo1234 opened this issue Jul 12, 2024 · 0 comments
Open

User messages are obsolete #92

dvdvideo1234 opened this issue Jul 12, 2024 · 0 comments

Comments

@dvdvideo1234
Copy link

dvdvideo1234 commented Jul 12, 2024

Consider user messages being deprecated:

function AdvDupe.SendClientError(ply, errormsg, NoSound)
	if ( !IsValid(ply) or !ply:IsPlayer() or !errormsg ) then return end
	MsgN("AdvDupe: Sending this ErrorMsg to ",tostring(ply),"\nAdvDupe-ERROR: \"",tostring(errormsg).."\"")
	umsg.Start("AdvDupeCLError", ply)
		umsg.String(errormsg)
		umsg.Bool(NoSound)
	umsg.End("AdvDupeCLError")
end

usermessage.Hook("AdvDupeCLError", AdvDupeCLError)

To become:

if(SERVER) then
  util.AddNetworkString("AdvDupeCLError")
else
  
  function AdvDupeCLError(len, ply) 
    AdvDupeClient.Error( net.ReadString(), net.ReadBool() )
  end

  net.Receive("AdvDupeCLError", AdvDupeCLError)
end

--- Somewhere in the server code

function AdvDupe.SendClientError(ply, errormsg, NoSound)
  if ( not (IsValid(ply) and ply:IsPlayer()) ) then return end -- Validate player only to check for empty error messages
  MsgN("AdvDupe: Sending this error message to ",ply:Nick(),"\nAdvDupe-ERROR: \"",tostring(errormsg ).."\"")
    net.Start("AdvDupeCLError")
      net.WriteString(errormsg)
      net.WriteBool(NoSound)
    net.Send(ply)
end

AdvDupe1 better switch to the net library.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant