Refusing to send user message TextMsg of 256 bytes to client

I have been getting this error (no I’m not using the usermsg library, unless PrintMessage does) every tick when running this test gamemode I’ve been brewing up.
I’m fairly new to making gamemodes so please be open minded when viewing.

(Note: The sniper rifle has been replaced with a pistol for testing purpouses.)

Join Message: (Uses ply:PrintMessage() )
“Welcome to Sniper Party! Crowbars will kill instantly, but the same can only be said with your sniper if you hit your target’s head. Otherwise, they will be able to see you through walls! During the first 40 seconds (you will be spectating this round if you joined afterwards) you are invincible!” (Maybe a culprit for the error)

init.lua



sniperparty_isinvincible = true;

local aliveplayers = {};
local deadplayercount = 0;
local start_time = CurTime()
local game_time = 0;
local dev = true;
local dotimesend = false;

local function endgamesequence(ply)
	local player = ply;
	local winnerexists = true;
	if ply == nil then
		winnerexists = false;
	elseif !ply:IsValid() then
		winnerexists = false;
	end
	if winnerexists then
		PrintMessage(HUD_PRINTCENTER, ply:Nick() .. " is victorious! Restarting in 10 seconds...")
	else
		PrintMessage(HUD_PRINTCENTER, "Time is up! Nobody has won. Boo Hoo. Restarting in 10 seconds...")
	end
	sniperparty_isinvincible = true;
	timer.Simple(10, function()
		local maplist = file.Find("../maps/*.bsp");
		local size = #maplist
		local text = ("changelevel " .. maplist[math.random(1, size)] .. "
")
		game.ConsoleCommand(text)
	end )
end

function playerSetSpeed(ply)
  givethings(ply)
  ply:SetMaxSpeed(130)
end

function playerSetSpeedNorm(ply)
  ply:SetMaxSpeed(500)
end

util.AddNetworkString("playerwallthru")
util.AddNetworkString("SetTime")
	

function GM:PlayerLoadout(ply)
	givethings(ply)
end

function givethings(ply)
  ply:StripWeapons()
  ply:Give("weapon_crowbar")
  ply:Give("weapon_pistol")
end

local invincibilitytimer = start_time + 40
hook.Add("InitPostEntity", "DoTimers", function()
	timer.Simple(40, function()
		sniperparty_isinvincible = false;
		PrintMessage( HUD_PRINTCENTER, "Players are no longer invincible!'")
		invincibilitytimer = nil;
	end )
end )

hook.Add("Think", "sniperpartychecks", function()
	for k,v in pairs(player.GetAll()) do
		if !v:Alive() then return end
		local typeam = v:GetActiveWeapon():GetPrimaryAmmoType()
		v:SetAmmo(20, typeam)
		if !table.HasValue( aliveplayers, v ) then
			table.Add( aliveplayers, {v} )
		end
	end
	deadplayercount = table.Count( player.GetAll() ) - table.Count( aliveplayers )
	if table.Count(aliveplayers) == 1 then
		endgamesequence(aliveplayers[1])
	end
	if (invincibilitytimer == 20) then
		PrintMessage( HUD_PRINTCENTER, "20 Seconds of Invincibility left!")
	end
	if (invinicibilitytimer == 5) then
		timer.Create("5secinvincibility", 1, 4, function() 
			local text = ( tostring(invincibilitytimer) .. " Seconds of Invincibility left!" )
			PrintMessage( HUD_PRINTCENTER, "20 Seconds of Invincibility left!")
		end )
	end
	if (invincibilitytimer == nil) then
		game_time = ( CurTime() + 180 )
		timer.Create("gametimer", 1, 0, function()
			if (game_time == CurTime()) then 
				game_time = nil;
				timer.Remove("gametimer")
			return end
			if dotimesend then
			net.Start("SetTime")
			net.WriteInt(game_time, 32)
			net.Send( player.GetAll() )
			end
		end )
	end
	if (game_time == nil) then
		endgamesequence(nil)
	end
end )


hook.Add("SetupMove", "GiveInfoSniperParty", function(ply, mv, cmd)
	ply:PrintMessage( HUD_PRINTCENTER, "Welcome to Sniper Party! Crowbars will kill instantly, but the same can only be said with your sniper if you hit your target's head. Otherwise, they will be able to see you through walls! During the first 40 seconds (you will be spectating this round if you joined afterwards) you are invincible!")
	if (sniperparty_isinvincible == false) then
		ply:Spectate(OBS_MODE_ROAMING)
	end
end )

hook.Add("PlayerSay", "forcerespawn", function(sen, txt, tchat)
	if dev then
	if (txt=="frspawn") then
			sen:UnLock()
			sen:Spawn()
	end
	end
end )

hook.Add( "PlayerSpawn", "playerSetSpeedtest", playerSetSpeed )
function revealply(att, vic)
  if !vic:Alive() then return end
  net.Start("playerwallthru")
  net.WriteEntity(att)
  net.Send(vic)
  playerSetSpeedNorm(vic)
  att:ChatPrint("You have been seen!")
end

hook.Add("PlayerInitialSpawn", "modelsethitbox", function(ply)
	ply:SetModel("models/player/police.mdl")
end )

function ScaleDamage( ply, hitgroup, dmginfo )
         if sniperparty_isinvincible then 
			dmginfo:ScaleDamage( -1 )
		 return end
         local att = dmginfo:GetAttacker()
         if att:IsPlayer() then
           revealply(att, ply)
         else
            dmginfo:ScaleDamage( 9999999 )
            
         return end
	 if ( hitgroup == HITGROUP_HEAD || att:GetClass() == "npc_zombie" ) then
 
		dmginfo:ScaleDamage( 9999999 )
 
	 elseif !(att:GetActiveWeapon():GetClass() == "weapon_crowbar") then
                dmginfo:ScaleDamage( -1 )
         else
                dmginfo:ScaleDamage( 9999999 )
    end
 
end

hook.Add("ScaleNPCDamage","ScaleNPCHeadshotDAM",function(npc,hit,inf)
	local att = inf:GetAttacker()
	if hit == HITGROUP_HEAD or (att:GetActiveWeapon():GetClass() == "weapon_crowbar")  then
		inf:ScaleDamage( 9999999 )
	else
		inf:ScaleDamage( -1 )
	end
end)
 
hook.Add("ScalePlayerDamage","ScaleDamage",ScaleDamage)

function GM:DoPlayerDeath( ply, attacker, dmginfo )

    ply:Lock()
 
	ply:CreateRagdoll()
 
	ply:AddDeaths( 1 )
	
	table.remove( aliveplayers, ply )
 
	if ( attacker:IsValid() && attacker:IsPlayer() ) then
 
	if !( attacker == ply ) then
			attacker:AddFrags( 1 )
		else
            ply:KillSilent()
			ply:UnLock()
        return end
 
	else
		if attacker:IsValid() && !attacker:IsWorld() then
		ply:Spectate(OBS_MODE_CHASE)
		ply:SpectateEntity(attacker)
		end
		ply:UnLock()
	return end

        ply:Spectate(OBS_MODE_IN_EYE)
        ply:SpectateEntity(attacker)
        
        timer.Simple(2, function()
		  if ply:IsValid() then
          ply:SetObserverMode(OBS_MODE_ROAMING)
		  end
        end )

end


cl_init.lua



net.Receive("playerwallthru", function()
	halo.Add( {net.ReadEntity()}, Color( 255, 0, 0 ), 5, 5, 1, true, true )
end )

local msgtime = nil;

net.Receive("SetTime", function()
	msgtime = net.ReadInt(32)
end )

surface.CreateFont( "coolvetica", ScreenScale(30), 400, true, false, "HUDFONT" ) -- You don't have to create it on every frame.
local function TimeHud()

	if !IsValid( msgtime ) then return end
		
	local time = msgtime - CurTime() -- The current time minus the time the player got when the usermessage was sent.
		
	surface.SetTextColor( 255, 255, 255, 255 )
	surface.SetTextPos( 34, ( ScrH() / 12 ) + ( ScrH() / 14 ) )
	surface.SetFont( "HUDFONT" )
	surface.DrawText( time )
		
end
hook.Add( "HUDPaint", "draw_time", TimeHud )


–snip–

Yes, as stated here

“This uses the archaic user message system (umsg library) and hence is limited to ≈250 characters.”

Just make something that networks it into something drawn in HUDPaint if you really want to use HUD_PRINTCENTER.

If you read the wiki page for

PrintMessage, you’ll see

[editline]17th September 2017[/editline]

ninja’d

I think he means normal net library – his code doesn’t use user messages.

[editline]17th September 2017[/editline]

But PrintMessage as well.

Thanks you three.

Anywho, I have one more point of inquiry. I have been getting this error every tick, does the hook “SetupMove” get called every tick? (I’m using that because I hear it is called when the user is fully loaded, hence actually displaying the message unlike when it’s only sending client data) If so, I’ll just have to make sure it only gets called once, no problem.

Thanks for being open minded, too

SetupMove is called every tick. Used to, the first SetupMove call equated to the player being fully loaded in, but not anymore.

Thanks! Now I can finally close this thread.

[editline]18th September 2017[/editline]

Quick note on how I acheived this, I remembered not to leave the thread unsolved to people other than me.

init.lua



util.AddNetworkString("AdministerStartInfo")
local sentstartmessagelist = {};
hook.Add("SetupMove", "GiveInfoSniperParty", function(ply, mv, cmd)
	if table.HasValue( sentstartmessagelist, ply ) then return end
	net.Start("AdministerStartInfo")
	net.Send(ply)
	if (sniperparty_isinvincible == false) then
		ply:Spectate(OBS_MODE_ROAMING)
	end
	table.Add( sentstartmessagelist, {ply} )
end )


cl_init.lua



net.Receive("AdministerStartInfo", function(leng, ply)
	local text_normal = Color(100, 100, 255)
	local text_gm = Color(255, 255, 0)
	local text_weapon = Color(255, 100, 100)
	chat.AddText( text_normal, "Welcome to " text_gm, "Sniper Party", text_normal, "!", text_weapon, " Crowbars", text_normal, " will kill instantly, but the same can only be said with your ", text_weapon, "sniper rifle", text_normal, " if you hit your target's head. Otherwise, they will be able to see you through walls! During the first 40 seconds (you will be spectating this round if you joined afterwards) you are invincible!")
end )