Network.sendToServer

Sends a network event from the client to the server. This will run the callback method on the server with optional arguments.

Kind: Function

Environments: Game

Game

network:sendToServer( callbackMethod, args )

Open the full Game reference

Availability: Client only

-- Example of calling server function over network, called function receives the optional argument and the sending player
function MySwitch.client_onInteract( self ) 
    self.network:sendToServer( 'server_setSwitch', { active = true } )
end

function MySwitch.server_setSwitch( self, args, player ) 
    -- Set state of switch
    self.interactable.active = args.active
end

Parameters:

Name Type Description
network Network The network.
callbackMethod string The server function name.
args (optional) any Optional arguments to be sent to the server.