net library net.WriteColor help


I’m probably posting to much posts today, that’s because i’m making something i’ve never done before ;3

Anyways back on topic, I have 3 variables ( CurColour1, CurColour2, CurColour3 ) and im trying to convert it so that it can be sent to the server…

I’ve tried this:

			net.WriteColor(Color(CurColour1, CurColour2, CurColour3))
			print(Color(CurColour1, CurColour2, CurColour3)) --For debug

but I get the error:

bad argument #1 to 'min' (number expected, got nil)

the debug prints out 36 34 14 255, maybe we can get commas in there?

Any help? thanks in advance

We need to see more code and the full error to help because min isn’t used in net.WriteColor or anywhere that I saw in lua/includes/modules/net.lua

The error is being caused in shared.lua

currentTeamNum = 6
net.Receive("sendteamInfoDFG", function(ply)
	team.SetUp(currentTeamNum, net.ReadString(), Color(net.ReadColor))
	currentTeamNum = currentTeamNum + 1

Im using the code from:

and this is my net.Send function:

			net.WriteColor(Color(CurColour1, CurColour2, CurColour3))
			print(Color(CurColour1, CurColour2, CurColour3))

net.ReadColor is a function like net.ReadString(). You are missing () at the end.

Thanks, that probaly fixed a future bug, but the error still occurs… is the only function with the name of “min”… And, it accepts numbers.

Where are you calling it? We need more to go on, not more of the same stuff…

net.ReadColor() returns a color table not 3 or 4 numbers

Well maybe is there a way to semd multiple strings/ints to the server?

If net.WriteColor just creates and sends a table, it should be this:

net.Receive("sendteamInfoDFG", function(ply)
	team.SetUp(currentTeamNum, net.ReadString(),  Color( unpack( net.ReadColor() ) ))
	currentTeamNum = currentTeamNum + 1

what fortune said could actully work, if i send a table instead of a colour

Ill try that soon.

net.WriteColor takes a single argument of a color.
net.ReadColor returns a single value of a color.

The Color function uses math.min on each of its parameters, you’re giving a nil value / other value that can’t be converted to a number to it.