{"name":"connectToServer","operator":null,"title":"connectToServer","type":"command","url":"https://community.bistudio.com/wiki/connectToServer","revid":373150,"updated":"2025-04-04T09:14:53Z","groups":["System"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"2.00"}],"since":{"game":"arma3","name":"Arma 3","version":"2.00"},"arma3_since":"2.00","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Connects the client to the provided server.\n\n> [!NOTE]\n> - only works on the Main Menu.\n> - must be executed from UI context, such as *onButtonDown* or similar events (see User Interface Event Handlers).\n\n> [!NOTE]\n> **Since Arma 3 v2.20:** If port is 0, the IP will be resolved as a SRV DNS Record.\n>\n> [\"domain.com\", 0, \"password\"] will be resolved as \"_arma3._udp.domain.com\".\n>\n> Only the first found record will be used, there is no support for multiple records with priority/weights.","syntaxes":[{"syntax":"connectToServer [ip, port, password]","since":null,"effect":null,"exec":null,"params":[{"name":"ip","type":"String","optional":false,"default":null,"description":"IP in <https://en.wikipedia.org/wiki/IPv4> format or Arma 3 v2.20 domain name","types":["String"],"since":null,"text":"ip: String - IP in <https://en.wikipedia.org/wiki/IPv4> format or Arma 3 v2.20 domain name"},{"name":"port","type":"Number","optional":false,"default":null,"description":null,"types":["Number"],"since":null,"text":"port: Number"},{"name":"password","type":"String","optional":false,"default":null,"description":"\"\" if no password","types":["String"],"since":null,"text":"password: String - \"\" if no password"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"unary","operator":null,"left":null,"right":{"text":"[ip, port, password]","types":["Array"]}}],"examples":[{"text":"```sqf\nconnectToServer [\"192.168.0.2\", 2302, \"test\"];\n```","code":["connectToServer [\"192.168.0.2\", 2302, \"test\"];"]},{"text":"```sqf\nconnectToServer [\"publicserver.mydomain.com\", 2302, \"\"];\n```","code":["connectToServer [\"publicserver.mydomain.com\", 2302, \"\"];"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["serverCommand","getSteamFriendsServers"],"notes":[],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: System","Introduced with Arma 3 version 2.00","Scripting Commands"]}