Revision Difference
Global.BroadcastLua#561622
<function name="BroadcastLua" parent="Global" type="libraryfunc">
<description>
Sends the specified Lua code to all connected clients and executes it.
<note>
If you need to use this function more than once, consider using <page>net</page> library.
Send net message and make the entire code you want to execute in <page>net.Receive</page> on client.
If executed **clientside** it won't do anything.
</note>
</description>
<realm>Shared</realm>
<args>
<arg name="code" type="string">The code to be executed. Capped at length of 254 characters.</arg>
</args>
</function>
<example>
<description>Print "Hello World!" in the clients' console</description>
<code>BroadcastLua( "print( 'Hello World!' )" )</code>
<output>Hello World!</output>
⤶
</example></example>⤶
⤶
⤶
<example>⤶
<description>If you try to send more than 254 characters, the function won't error, but an engine message will be printed to the console</description>⤶
<code>BroadcastLua( string.rep( "a", 256 ) )</code>⤶
<output>_(Printed to console)_ `DLL_MessageEnd: Refusing to send user message LuaCmd of 256 bytes to client, user message size limit is 255 bytes`</output>⤶
</example>