Server's usermessage.lua

I have a server but it keeps saying “Buffer Overflow in Net Message” and I found out it is the usermessage. It says the error was because it was over 256 bytes. What is the coding I could put to fix it (replace the coding already there)? Or any other way. Thanks.

remove nwvars

sorry to ask this but, where is that?

I think he means you’re using networked variables (NWVars) too much.

What gamemode are you running?

Sandbox and/or darkrp

Probably DarkRP that’s doing it.

Somewhere in the DarkRP svn the author changed it so that it used no networked variables, so try running that version instead.


This is not a garrymod problem per-se. Usermessages (the things lua scripters use to send data from the server to the client) have a limit of 255 bytes.

What has happened is someone who scripted something you’re using has ignored this, and allowed their code to send a usermessage that was over 255 bytes. When this happens, the usermessage is not sent, and an error message is generated on the server.

There’s nothing you personally can do to fix this. The person who coded the script you’re using needs to fix his script.

I know only one way, but if other people know beter ways, feel free to help because I’m interested in a better solution :wink:


function ENT:SetString( str )
  local j = 0
  local len = str:len()

  for i = 1, len, 200 do
    j = j + 1
    self.Entity:SetNetworkedString( "part" .. j, str:sub( i, i + 199 ) )
  self.Entity:SetNetworkedInt( "parts", j );


function ENT:GetString()
  local j = self.Entity:GetNetworkedInt( "parts" )
  local str = ""
  for i = 1, j do
    str = string.format( "%s%s", str, self.Entity:GetNetworkedString( "part" .. i ) )
  return str


Why are you using all that NW stuff with iterating string length?

Why not do something like ent.MyString = “string lolz” in a shared lua state? Or if you need to always set it on the server, just use the SetNWString once per str, rather than make a bunch of different parts.

Because NetworkedStrings are also limited to 255 bytes, this is the only solution that I know to send unlimited length strings from server to client. But I’m beginner… Is there a better way to do that?

Multiple usermessages, or a shared table of strings and send the index of the string you want to set when a specific function on the server is called.

check out my other thread about another problem that I have no idea about: