ConnectToServer

From Onset Developer Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
ConnectToServer

Type: Function
Context: Client
Introduced: v1.0

Description

Connects the game to another server. The connection will happen on the next game tick.

Syntax

ConnectToServer(Address, Port [, Password, LevelMap])

Parameters

  • Address
    Server IP or hostname.
  • Port
    Server port.
  • Password (optional)
    Optional server password.
  • LevelMap (optional)
    Optional path to a level to load (since 1.3.0, see Custom_Maps).

Return Value

  • Returns false if this function was already called. If LevelMap was set but is an invalid (non existent) map this function will return false and no connection will happen. Returns true on success.

Example

function OnKeyPress(key)
    if key == "J" then
        ConnectToServer("127.0.0.1", 7777, "")
    end
end
AddEvent("OnKeyPress", OnKeyPress)

See also