LAN Server/zh: Difference between revisions

From DDraceNetwork
(Created page with "关于端口转发可以参阅 http://portforward.com/ 。")
(Created page with "== 服务器设置与地图 ==")
Line 119: Line 119:




<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="Server_Settings_and_Maps"></span>
== Server Settings and Maps ==
== 服务器设置与地图 ==
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">

Revision as of 02:21, 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

6. 進入 DDNet 文件夾

  • cd ddnet

7. 編譯 DDNet

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

8. 伺服器,啟動!

  • ./DDNet-Server

9. 轉發伺服器端口(默認為8303)

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

  • Press F1
  • connect "Server-IP"

11.遊玩

更多內容參閱 github

方法 2 (使用預編譯的二進制文件)
[展開 / 摺疊]
1. 從DDNet 下載頁面(download page)上下載二進制文件

2. 解壓到文件夾

3. 啟動伺服器

  • ./DDNet-Server

4. 轉發伺服器端口(默認為8303)

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

  • Press F1
  • connect "Server-IP"

6. 遊玩

關於端口轉發可以參閱 http://portforward.com/


伺服器設置與地圖

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>.


另見