Garry's Mod Wiki

Revision Difference

net.WriteString#546552

<function name="WriteString" parent="net" type="libraryfunc"> <description>Appends a string to the current net message. The size of the string is 8 bits plus 8 bits for every ASCII character in the string. The maximum allowed length of a single written string is **65532 characters**.</description> <realm>Shared</realm> <args> <arg name="string" type="string">The string to be sent.</arg> </args> </function> ⤶ <example>⤶ <description>Sends a message to all the clients</description>⤶ <code>⤶ -- Server⤶ util.AddNetworkString( "SendMessage" )⤶ ⤶ net.Start( "SendMessage" )⤶ net.WriteString("Hello World!")⤶ net.Broadcast()⤶ ⤶ -- Client⤶ net.Receive( "SendMessage", function( len )⤶ local message = net.ReadString()⤶ ⤶ chat.AddText(Color(255,255,255), message)⤶ end )⤶ </code>⤶ </example>