LAN Server/zh: Difference between revisions

From DDraceNetwork
No edit summary
No edit summary
Line 92: Line 92:
10.游玩
10.游玩


详情请看[https://github.com/ddnet/ddnet github]
更多内容参阅[https://github.com/ddnet/ddnet github]
|}
|}



Revision as of 02:09, 28 July 2023

本地伺服器是玩家在本地網絡(比如家庭wifi)中建立的伺服器,建立伺服器的玩家擁有對這個伺服器的完全控制權。

使用本地伺服器的原因有很多。它能夠讓你做到:

  • 和朋友一起遊玩時不受別人打擾
  • 遊玩官方伺服器中沒有的地圖
  • 用管理員指令和工具對地圖進行測試
  • 以及更多!

然而,建立本地伺服器仍然有許多缺點。你需要一些特殊的方法來讓你的朋友加入你的伺服器,並且相比起官方伺服器,其他玩家在你建立的本地伺服器中會遭受更多網絡的影響。注意本地伺服器只會在本地保存過圖記錄,這意味著你在本地伺服器中完成地圖並不會將記錄同步到官方伺服器。


建立和加入本地伺服器

在新版DDNet客戶端中,建立本地伺服器非常簡單。

  1. 找到遊戲的開始菜單
  2. 點擊「運行伺服器」
    • 一個黑底白字的命令行窗口會彈出(這可能需要一小段時間)。從這個窗口中複製rcon的密碼(也可以在遊戲路徑的autoexecserver.cfg文件中查看並設置)。
  3. 打開遊戲客戶端的瀏覽伺服器界面,在上方選擇區域網,刷新後即可加入。
  4. 進入遊戲後,按f2打開伺服器控制台rcon,然後輸入密碼來獲得管理員指令的使用權限。

然而,這樣建立的伺服器只能夠讓處在同一區域網中的玩家加入。如果其他玩家不在你身旁,那麼想要讓他們加入就需要更多步驟。


讓本地伺服器連接至公網

這一步需要你進行埠映射,其方式取決於你的路由器品牌和類型。

  1. 在路由器上映射或者轉發UDP埠8303。
    • 瀏覽器上一般都有關於埠映射或者轉發的教程。內容通常會涉及到登錄瀏覽器接口,不同的家庭各有所異。
    • 確保設置中使用了UDP協議而不是TCP或者兩者共用。
    • DDNet默認使用8303埠,如果您對於伺服器足夠熟悉,也可以通過更改伺服器配置文件中的sv_port參數來使用其它埠。
  2. 在 F2 伺服器控制台或者伺服器配置文件中使用sv_register 1可以讓您的伺服器出現在遊戲伺服器界面的網際網路列表中。注意這麼做會公開您的家庭網絡IP,具有一定風險。

一些網絡運營商會使用電信級NAT而不提供本地 IPv4 地址的完整級別保護,因此可能無法使用埠轉發,以上將伺服器聯網的方法變得不可用。(關於 IPV6 的方法此處不涉及。)

在Linux上設置伺服器

Linux

方法 1 (編譯伺服器)
[展開 / 摺疊]
1.上傳伺服器
  • sudo apt update && apt upgrade

2. 安裝git

  • sudo apt install git

3. 創建目錄

  • mkdir DDNet-Server

4. 複製Github上的庫

  • git clone --recursive --depth=1 https://github.com/ddnet/ddnet

5. 安裝依賴包

  • sudo apt install build-essential cmake git libcurl4-openssl-dev libssl-dev libfreetype6-dev libglew-dev libnotify-dev libogg-dev libopus-dev libopusfile-dev libpnglite-dev libsdl2-dev libsqlite3-dev libwavpack-dev python google-mock

5. 進入 DDNet 文件夾

  • cd ddnet

6. 編譯 DDNet

  • mkdir build
  • cd build
  • cmake -DCLIENT=OFF ..
  • make -j$(nproc)

7. 伺服器,啟動!

  • ./DDNet-Server

8. 轉發伺服器埠(默認為8303)

9. 使用 IP 通過客戶端連接

  • Press F1
  • connect "Server-IP"

10.遊玩

更多內容參閱github

Method 2 (Using precompiled binaries)
[Show/Hide]
1. Download binaries from DDNet download page

2. Extract into folder

3. Open Server

  • ./DDNet-Server

4. Forward a port to the server (default is 8303)

5. Connect via Client on the IP

  • Press F1
  • connect "Server-IP"

6. Play

More Information about Port forwarding are available at http://portforward.com/


Server Settings and Maps

Everything settings and map-wise can be found in your Teeworlds folder.

  • On Windows, you can find it in AppData/Roaming/Teeworlds.
  • On Linux, you can find it in (insert location here).
  • On Mac, you can find it in (insert location here).


Server Autoexecutables

Server autoexecutables are files containing server settings that are automatically run every time you start your server. For example, this can be helpful if you want to keep a single rcon password to log in with every time.

To create an autoexecutable, navigate to your Teeworlds folder (not your DDNet folder!), and create a file by the name of "autoexec_server.cfg". Make sure it is a .cfg extension file and not a .txt file or anything similar.

To add commands, simply edit the autoexec_server.cfg file and add each command on a new line. Here are examples of commonly used commands:

  • sv_rcon_password <rcon password>
  • sv_password <password to join>
  • sv_name <server name>
  • sv_register 1 (shows the server on the Internet tab)
  • sv_test_cmds 1 (allows the use of cheat commands)


Server Maps

Server maps can be found in Teeworlds/maps. To load a map ingame, use the server command sv_map <mapname>.


另見