LAN Server/zh: Difference between revisions

From DDraceNetwork
(Created page with "* Windows系统:位于 AppData/Roaming/Teeworlds 路径下。 * Linux系统:(地址待定)。 * Mac系统:(地址待定)。")
(Created page with "=== 服务器自动执行部分 ===")
Line 129: Line 129:




<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="Server_Autoexecutables"></span>
=== Server Autoexecutables ===
=== 服务器配置文件 ===
</div>


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

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


服務器設置與地圖

您可以在 Teeworlds 文件夾中找到設置和地圖引導。

  • Windows系統:位於 AppData/Roaming/Teeworlds 路徑下。
  • Linux系統:(地址待定)。
  • Mac系統:(地址待定)。


服務器配置文件

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


另見