Garry's Mod Wiki

Revision Difference

net.SendToServer#545995

<function name="SendToServer" parent="net" type="libraryfunc"> <description>Sends the current message to the server.</description>⤶ <description>Sends the current message to the server. <note>You need to declare a message name serverside using <page>util.AddNetworkString</page> before. You **cannot** send messages to non-existent network names.</note>⤶ </description>⤶ <realm>Client</realm> </function> <example> <description>Sends a simple "hello_world" message with the string "Hi" to the server</description> <code> net.Start( "hello_world" ) net.WriteString( "Hi" ) net.SendToServer() </code> <output> The netmessage "hello_world" is sent to the server. The server can handle this with <page>net.Receive</page>. Remember that any client has the potential to send any net message at any time. On your server-side <page>net.Receive</page>, make sure to verify the message sender's permissions whenever you can and prevent expensive functions from being run too often. Remember that any client has the potential to send any net message at any time. **Don't trust the clientside!** On your server-side <page>net.Receive</page>, make sure to verify the message sender's permissions whenever you can and prevent expensive functions from being run too often. </output> </example>