ConnectToServer: Difference between revisions

From Onset Developer Wiki
No edit summary
No edit summary
Line 9: Line 9:
{{FuncParam|Port|Server port.}}
{{FuncParam|Port|Server port.}}
{{FuncParamOptional|Password|Optional server password.}}
{{FuncParamOptional|Password|Optional server password.}}
{{FuncParamOptional|LevelMap|Optional level to load (since 1.3.0, see [[Custom_Maps]]).}}
{{FuncParamOptional|LevelMap|Optional path to a level to load (since 1.3.0, see [[Custom_Maps]]).}}


{{FuncReturnValue|This function does not return anything.}}
{{FuncReturnValue|This function does not return anything.}}

Revision as of 15:07, 19 September 2020

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

  • This function does not return anything.

Example

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

See also