Net Message Integer transfer failing to work as intended

Client code and client console print



net.Start("RequestAvailableWeapons")
	net.WriteInt(self.myRole, 4)
	print("myRole DEBUG - ", self.myRole)
net.SendToServer()

myRole DEBUG - 	8


Server code and server console print



net.Receive("RequestAvailableWeapons", function(len, ply)
    local plyRole = net.ReadInt(4)
    local availableWeaponsTable = {}

    print(plyRole)
--More stuff done underneath but cut for length's sake
end)

0


What’s going on here? How come the number is coming in as 0?

Maybe try increasing the bitcount?

I’ll give it a go, but the highest number self.myRole can ever be is 8. 2^3 is 8. Dunno why it would return 0.

[editline]21st November 2017[/editline]

Oh I see now, it has 8 values, but the first value starts at 0, so it’s 0-7 and not 1-8.