• Networking Issue with the "ReadInt" function.
    2 replies, posted
Hello again! This may be have a simple solution but I can not figure it out. I am trying to make the server notify the client ( kind of ). I made a function for this. Server sided function function notifyPlayer( ply, str, typeenum )  net.Start( "notifyPlayer_net" ) net.WriteString( tostring( str ) ) net.WriteInt( typeenum ) net.Send( ply ) end Client Sided net.Receive function callback net.Receive( "notifyPlayer_net", function( len, ply ) local str = net.ReadString() local typeenum = net.ReadInt() notification.AddLegacy( str, typeenum, 5 ) end) Everything seems fine until the client receives the net message. Then this error comes up: bad argument #1 to 'ReadInt' (number expected, got no value) I get that it did not get a number, but how? In the notify player function it clearly gets a number into it when calling the function. This if how I called the function ( from server side ): notifyPlayer( meta, "test", 1 ) It seems like the string had no problems. I do now know why. I don't know what I am doing wrong, I hope you can fill me in on that part.
What does the error tell you? That it expects a number to the first argument but you are giving it nothing? What sort of number it wants you may ask? Good question. You can find out that by going to the official Garry's Mod wiki and searching up the function: http://wiki.garrysmod.com/page/net/ReadInt
Use net.WriteInt( typeenum, 32 ) And local typeenum = net.ReadInt( 32 ) As Robotboy said, you need to specify a bitcount for the number when using WriteInt.
Sorry, you need to Log In to post a reply to this thread.