ConnectToServer: Difference between revisions

From Onset Developer Wiki
(Created page with "{{Info|Function|Client|1.0}} {{FuncDescription|Connects the game to another server. The connection will happen on the next game tick.}} {{FuncSyntax|ConnectToServer(Address,...")
 
No edit summary
Line 13: Line 13:


== Example ==
== Example ==
__EDIT_ME__
<syntaxhighlight lang="Lua">
function OnKeyPress(key)
    if key == "J" then
        ConnectToServer("127.0.0.1", 7777, "")
    end
end
AddEvent("OnKeyPress", OnKeyPress)
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
__EDIT_ME__
*[[GetGameVersion]]
*[[IsGameDevMode]]
*[[IsPlayerInMainMenu]]
*[[InvokeDamageFX]]
*[[UpdateDiscordActivity]]
*[[ConnectToServer]]

Revision as of 18:58, 30 August 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])

Parameters

  • Address
    Server IP or hostname.
  • Port
    Server port.
  • Password (optional)
    Optional server password.

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