Garry's Mod Wiki

Revision Difference

Player:SendLua#527150

<function name="SendLua" parent="Player" type="classfunc"> <description> Executes a simple Lua string on the player. <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.</note> <note>The string is limited to 254 bytes. Consider using the <page text="net library">Net_Library_Usage</page> for more advanced server-client interaction.</note> </description> <realm>Server</realm> <args> <arg name="script" type="string">The script to execute.</arg> </args> </function> <example> <description>Sends "Hello World" to the client's console.</description> <code>⤶ local pl = Entity( 1 ) pl:SendLua( "print( 'Hello World' )" )⤶ <code> ⤶ Entity( 1 ):SendLua( "print( 'Hello World' )" ) </code> </example>