Why can't I draw in net.Recieve()?

I can’t draw anything in a net.Recieve().
So how can I draw something, with arguments from net.Recieve, only when it happens, for example text at a certain coordinates gotten from net.Recieve()…

You would have to save what you receive in net.Receive, and draw it in the HUDPaint hook. You could even create said hook inside the net.Receive if you wanted.

Yeah net.Receive is called once when the message is receieved, not tons of times per second like the draw functions

It’s being sent from the server every Think. And the message is being recieved that much too.

I don’t think sending stuff every tick is a good idea. You should really send it when data changes/some event happens.

Sending stuff every tick is a bad idea, depending on what you are trying to do, use networked vars to send info, or a time regulated net message that saves vars to the client to be used to draw info

It’s something normally only the server has access too, it’s being changed 99% of the time, and it must be updated every frame.

What is it that needs to be networked every tick, lol?

Something like this



if SERVER then

	AddCSLuaFile()
	util.AddNetworkString( "tickmessage")

	hook.Add( "Tick", "tickWriteMessage", function()

		net.Start( "tickmessage" )
			net.WriteInt( math.random( 1, 32767 ), 16 )
		net.Broadcast()

	end )

else

	local tickInt

	net.Receive( "tickmessage", function()

		tickInt = net.ReadInt( 16 )

	end )

	hook.Add( "HUDPaint", "drawHelloWorld", function()

		if tickInt ~= nil then

			draw.SimpleText( "Integer: " .. tickInt, "HudHintTextLarge", ScrW() / 2, ( ScrH() / 2 ) - 30, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_BOTTOM )

		end  

	end )

end


I’m also on the “for what purpose?” train

How about you draw it in the HUDPaint and insert checks if you want it to run at a specific time?

Edit- Whoops, didnt read the post above. Yeah just do it that way.

The purpose is, using GetPos() clientside for a player doesn’t work 90% of the time. So I have to send all their positions.

Let’s say you have a 32 player server running at 66 tick. A loop through each player, to send their position would be 2,112 net messages a second. Think about that.

I haven’t had any issues with GetPos() clientside here. Are you sure nothing is interfering (or the target isn’t out of your PVS, that applies IIRC)



lua_run for I=1, 5 do print( Player(2):GetPos() ) end
> for I=1, 5 do print( Player(2):GetPos() ) end...
-335.558411 75.723976 -12287.968750
-335.558411 75.723976 -12287.968750
-335.558411 75.723976 -12287.968750
-335.558411 75.723976 -12287.968750
-335.558411 75.723976 -12287.968750
] lua_run_cl for I=1, 5 do print( Player(2):GetPos() ) end
-335.558411 75.723976 -12287.968750
-335.558411 75.723976 -12287.968750
-335.558411 75.723976 -12287.968750
-335.558411 75.723976 -12287.968750
-335.558411 75.723976 -12287.968750
] lua_run_cl for I=1, 5 do print( LocalPlayer():GetPos() ) end
-335.558411 75.723976 -12287.968750
-335.558411 75.723976 -12287.968750
-335.558411 75.723976 -12287.968750
-335.558411 75.723976 -12287.968750
-335.558411 75.723976 -12287.968750


He’s probably mis-understanding how GetPos works on entities that aren’t in the same PVS as the player. You don’t received updated position info (as often) for entities you can’t see. Now you do get updates every 30 seconds (by default) for all entities.

That’s what I mean. I need their position regardless of PVS…

Please don’t act like you know what you’re taking about, you obviously have no clue, this may help you:

Every time i see you, you’re hacking around something.

I know that exists. What I don’t know is how I’m supposed to apply that on players.

??

What I don’t understand is why you don’t look for an answer instead of having it spoonfed to you.

Linking to wiki pages is not spoonfeeding…
I HAVE searched. And I didn’t know that it was possible to override functions for a player in OnEntityCreated.

Its possible to override and detour anything you like.

The TRANSMIT enums can’t be used on players. Use the SetupPlayerVisibility hook and AddOriginToPVS.