本文 首发于 Anyeの小站,转载请取得作者同意。
感谢 嘉钰 、 寒山雨(腾讯云选购服务器:微信:mumuxi1019)大佬的安装脚本及教程。
问题解答 在文章最下方,常见问题可参考解决。如有疑问,可发送在评论区。
param (
[switch]$EnableAutoRestart,
[int]$ServerPort
)
$ErrorActionPreference = "Stop"
# 定义要检查的进程名称
$ProcessNames = @("PalServer", "PalServer-Win64-Test-Cmd")
foreach ($ProcessName in $ProcessNames) {
if (Get-Process $ProcessName -ErrorAction SilentlyContinue) {
Write-Host "$ProcessName is already running."
exit
}
}
# 初始化安装目录
$DirectoryPath = "C:\Program Files\PalServer\"
if (-not (Test-Path -Path $directoryPath)) {
New-Item -ItemType Directory -Path $directoryPath | Out-Null
}
# 下载安装 C++ 运行库
Write-Host "Start download vc_redist.x64.exe..."
$VcUrl = "https://aka.ms/vs/17/release/vc_redist.x64.exe"
$VcOutput = "C:\Program Files\PalServer\vc_redist.x64.exe"
Invoke-WebRequest -Uri $VcUrl -OutFile $VcOutput
Write-Host "Installing vc_redist.x64.exe..."
Start-Process -FilePath $VcOutput -Args '/install', '/quiet', '/norestart' -Wait
Remove-Item -Path $VcOutput
# 下载安装 DirectX 支持库
Write-Host "Start download dxwebsetup.exe..."
$DxUrl = "https://download.microsoft.com/download/1/7/1/1718CCC4-6315-4D8E-9543-8E28A4E18C4C/dxwebsetup.exe"
$DxOutput = "C:\Program Files\PalServer\dxwebsetup.exe"
Invoke-WebRequest -Uri $DxUrl -OutFile $DxOutput
$retryCount = 0
do {
Write-Host "Installing dxwebsetup.exe... $retryCount"
$process = Start-Process -FilePath $DxOutput -ArgumentList '/Q' -PassThru
$hasExited = $process.WaitForExit(180000) # 等待3分钟
if (-not $hasExited) {
$process | Stop-Process -Force
}
$retryCount++
} while ($retryCount -lt 3 -and -not $hasExited)
Remove-Item -Path $DxOutput
# 下载 Steamcmd
Write-Host "Start download steamcmd.zip..."
$StUrl = "https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip"
$StOutput = "C:\Program Files\PalServer\steamcmd.zip"
$StUnzipPath = "C:\Program Files\PalServer\steam\"
Invoke-WebRequest -Uri $StUrl -OutFile $StOutput
Expand-Archive -LiteralPath $StOutput -DestinationPath $StUnzipPath -Force
Remove-Item -Path $StOutput
# 运行 SteamCMD 更新服务器
Write-Host "Running steamcmd.exe..."
Set-Location -Path $StUnzipPath
Start-Process ".\steamcmd.exe" -ArgumentList "+login anonymous +app_update 2394010 validate +quit" -Wait
# 设置开机自启动
Write-Host "Setting scheduled task..."
$TaskName = "PalServerAutoStart"
$TaskDescription = "Automatically starts PalServer on system startup and restarts on failure."
$TaskExecutable = "C:\Program Files\PalServer\steam\steamapps\common\PalServer\PalServer.exe"
if ($PSBoundParameters.ContainsKey('ServerPort')) {
Write-Host "ServerPort is set to $ServerPort"
$TaskArguments="-port=$ServerPort"
$TaskAction = New-ScheduledTaskAction -Execute $TaskExecutable -Argument $TaskArguments
} else {
$TaskAction = New-ScheduledTaskAction -Execute $TaskExecutable
}
$TaskTrigger = New-ScheduledTaskTrigger -AtStartup
$TaskPrincipal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -LogonType ServiceAccount -RunLevel Highest
# 设置任务失败后的重启策略,失败后等待 1 分钟,最多尝试 3 次
$RestartInterval = New-TimeSpan -Minutes 1
$RestartCount = 3
$TaskSettings = New-ScheduledTaskSettingsSet -RestartInterval $RestartInterval -RestartCount $RestartCount
Register-ScheduledTask -TaskName $TaskName -Description $TaskDescription -Action $TaskAction -Trigger $TaskTrigger -Principal $TaskPrincipal -Settings $TaskSettings -Force | Out-Null
if ($PSBoundParameters.ContainsKey('EnableAutoRestart') -and $EnableAutoRestart) {
Write-Host "Install auto_restart_on_high_memory"
iex (irm 'https://pal.pet/pal-server/Windows/auto_restart_on_high_memory.ps1')
}
# 运行 PalServer
Write-Host "Running PalServer.exe..."
Start-ScheduledTask -TaskName $TaskName
Write-Host "PalServer deploy success!"
$EnableAutoRestart
:一个开关参数,用于启用或禁用自动重启功能,若不提供,默认为 false
。$ServerPort
:整数参数,用于指定服务器端口。Get-Process
检查指定的进程名称是否已经在运行,如果已经运行,则输出消息并退出脚本。vc_redist.x64.exe
,然后使用 Start-Process
启动安装,安装参数包括 /install
, /quiet
, /norestart
。dxwebsetup.exe
,然后使用 Start-Process
启动安装,安装参数包括 /Q
。steamcmd.zip
,然后使用 Expand-Archive
解压到指定目录。Start-Process
启动更新服务器的命令。$ServerPort
参数,则将端口号作为参数传递给 PalServer。auto_restart_on_high_memory.ps1
的脚本。Start-ScheduledTask
启动之前创建的定时任务,开始运行 PalServer。$DirectoryPath
:PalServer 的安装目录路径, C:\Program Files\PalServer\
$StUnzipPath
:Steamcmd 解压后的路径,即 C:\Program Files\PalServer\steam\
$VcUrl
:Visual C++ 运行库 vc_redist.x64.exe
的下载地址
$DxUrl
:DirectX 支持库 dxwebsetup.exe
的下载地址
$StUrl
:Steamcmd 客户端 steamcmd.zip
的下载地址
$VcOutput
:下载的 Visual C++ 运行库的保存路径,C:\Program Files\PalServer\vc_redist.x64.exe
$DxOutput
:下载的 DirectX 支持库的保存路径,C:\Program Files\PalServer\dxwebsetup.exe
$StOutput
:下载的 Steamcmd 客户端的保存路径,C:\Program Files\PalServer\steamcmd.zip
$TaskName = "PalServerAutoStart"
$ProcessName = "PalServer-Win64-Test-Cmd"
if (Get-Process -Name $ProcessName -ErrorAction SilentlyContinue) {
Stop-Process -Name $ProcessName -Force
Start-Sleep -Seconds 1
}
& "C:\Program Files\PalServer\steam\steamcmd.exe" +login anonymous +app_update 2394010 validate +quit
Start-ScheduledTask -TaskName $TaskName
if (Get-Process -Name $ProcessName -ErrorAction SilentlyContinue)
:通过 Get-Process
命令检查指定名称的进程是否正在运行。-ErrorAction SilentlyContinue
表示如果发生错误(例如找不到进程),则不显示错误信息。Stop-Process -Name $ProcessName -Force
:强制停止进程。Start-Sleep -Seconds 1
:暂停脚本执行 1 秒,确保进程完全停止。& "C:\Program Files\PalServer\steam\steamcmd.exe" +login anonymous +app_update 2394010 validate +quit
:使用 &
运算符运行 SteamCMD 命令来更新 PalServer。+login anonymous
表示匿名登录,+app_update 2394010 validate +quit
是 SteamCMD 的参数,用于更新 PalServer 。Start-ScheduledTask -TaskName $TaskName
:启动进程。$sourceFolderPath = "C:\Program Files\PalServer\steam\steamapps\common\PalServer\Pal\Saved" # 需要备份的文件夹路径
$backupfilespath = "C:\backup" # 备份文件存放路径
$waitTimeInSeconds = 1 * 60 * 60 # 备份间隔时间,单位:秒
$webdavUrl = "" # WebDAV 服务器地址
$webdavUsername = "" # 账号
$webdavPassword = "" # 密码
if (-not (Test-Path -Path $backupfilespath -PathType Container)) {
New-Item -ItemType Directory -Path $backupfilespath | Out-Null
Write-Host "已创建备份文件夹: $backupfilespath"
}
function Upload-FileToWebDAV {
param(
[string]$WebDAVUrl,
[string]$Username,
[string]$Password,
[string]$LocalFilePath,
[string]$RemoteFilePath
)
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("${Username}:${Password}")))
$headers = @{
Authorization = "Basic $base64AuthInfo"
}
try {
$uploadResponse = Invoke-WebRequest -Uri "$WebDAVUrl$RemoteFilePath" -Method Put -InFile $LocalFilePath -Headers $headers -UseBasicParsing
Write-Host "上传成功. 响应: $($uploadResponse.StatusCode)"
} catch {
Write-Host "上传失败. 错误: $_"
}
}
while ($true) {
$currentDateTime = Get-Date
$formattedCurrentTimeStamp = $currentDateTime.ToString("yyyyMMdd_HHmmss")
$zipFileName = $backupfilespath + "\backup_" + $formattedCurrentTimeStamp + ".zip"
Compress-Archive -Path $sourceFolderPath -DestinationPath $zipFileName
$remoteFilePath = "/backup_" + $formattedCurrentTimeStamp + ".zip"
$uploadParams = @{
WebDAVUrl = $webdavUrl
Username = $webdavUsername
Password = $webdavPassword
LocalFilePath = $zipFileName
RemoteFilePath = $remoteFilePath
}
Upload-FileToWebDAV @uploadParams
for ($i = $waitTimeInSeconds; $i -gt 0; $i--) {
$minutes = [math]::floor($i / 60)
$seconds = $i % 60
Write-Host -NoNewline "等待 $($minutes) 分钟 $($seconds) 秒..."
Start-Sleep -Seconds 1
Write-Host -NoNewline "`r"
}
Write-Host "备份完成。上传到 WebDAV 完成。等待下一次备份..."
}
该 PowerShell 脚本是用于定期备份指定文件夹并将备份文件上传到 WebDAV 服务器的自动化脚本。
$sourceFolderPath = "C:\Program Files\PalServer\steam\steamapps\common\PalServer\Pal\Saved"
:定义需要备份的文件夹路径。$backupfilespath = "C:\backup"
:定义备份文件存放路径。$waitTimeInSeconds = 1 * 60 * 60
:定义备份间隔时间,单位为秒,这里设置为1小时。$webdavUrl
、$webdavUsername
、$webdavPassword
:定义 WebDAV 服务器的地址、账号和密码。Test-Path
检查备份文件夹是否存在,如果不存在,则创建。Upload-FileToWebDAV
函数,用于上传文件到 WebDAV 服务器。while ($true)
进入一个无限循环,执行以下操作:yyyyMMdd_HHmmss
形式,用于生成备份文件名。Compress-Archive
压缩指定文件夹到一个备份文件。Upload-FileToWebDAV
函数上传备份文件到 WebDAV 服务器。for
循环等待指定的备份间隔时间,每秒输出等待信息。iex (irm 'https://pal-server-1251810746.cos.accelerate.myqcloud.com/pal-server/Windows/install.ps1')
iex (irm 'https://pal-server-1251810746.cos.accelerate.myqcloud.com/pal-server/Windows/update.ps1')
Start-ScheduledTask -TaskName "PalServerAutoStart"
Stop-Process -Name "PalServer-Win64-Test-Cmd" -Force
C:\Program Files\PalServer\steam\steamapps\common\PalServer\Pal\Saved\Config\WindowsServer\GameUserSettings.ini
中的 DedicatedServerName
C:\Program Files\PalServer\steam\steamapps\common\PalServer\Pal\Saved\Config\WindowsServer\PalWorldSettings.ini
C:\Program Files\PalServer\steam\steamapps\common\PalServer\Pal\Saved\SaveGames\0\
Administrator
#!/bin/bash
enable_zram=false
enable_auto_restart=false
server_port=""
for arg in "$@"
do
case $arg in
--enable-zram)
enable_zram=true
;;
--enable-auto-restart)
enable_auto_restart=true
;;
--server-port=*)
server_port="${arg#*=}"
;;
esac
done
steam_user=steam
log_path=/tmp/pal_server.log
sudo rm /tmp/pal_server.log
if getent passwd "$steam_user" >/dev/null 2>&1; then
echo "User $steam_user exists."
else
echo "User $steam_user does not exist.Adding $steam_user ..."
sudo useradd -m -s /bin/bash $steam_user
fi
steam_user_path=~steam
exec_start="$steam_user_path/Steam/steamapps/common/PalServer/PalServer.sh -useperfthreads -NoAsyncLoadingThread -UseMultithreadForDS"
# Apply arguments
if [ "$enable_zram" = true ]; then
echo "Enabling Zram..."
wget -O - "https://pal.pet/pal-server/Ubuntu/zram.sh" --no-check-certificate | sh
fi
if [ "$enable_auto_restart" = true ]; then
echo "Enabling auto restart on high memory usage..."
wget -O - "https://pal.pet/pal-server/Ubuntu/auto_restart_on_high_memory.sh" --no-check-certificate | sh
fi
if [ ! -z "$server_port" ]; then
echo "PAL server port set to $server_port"
exec_start="$exec_start -port=$server_port"
fi
echo "Installing SteamCMD..."
sudo add-apt-repository multiverse -y > $log_path
sudo dpkg --add-architecture i386 >> $log_path
sudo apt update -y >> $log_path
sudo apt-get remove needrestart -y >> $log_path
echo steam steam/license note '' | sudo debconf-set-selections
echo steam steam/question select "I AGREE" | sudo debconf-set-selections
sudo apt install steamcmd -y >> $log_path
steamcmd_path=$(which steamcmd)
if [ -z "$steamcmd_path" ]; then
echo "Error: Install SteamCMD failed"
exit 1
else
echo "Install SteamCMD successfully"
fi
sudo -u $steam_user mkdir -p $steam_user_path/.steam/sdk64/ >> $log_path
echo "Downloading palServer..."
sudo -u $steam_user $steamcmd_path +login anonymous +app_update 1007 validate +quit >> $log_path
sudo -u $steam_user $steamcmd_path +login anonymous +app_update 2394010 validate +quit >> $log_path
sudo cp $steam_user_path/Steam/steamapps/common/Steamworks\ SDK\ Redist/linux64/steamclient.so $steam_user_path/.steam/sdk64/
systemd_unit=pal-server
cat < $systemd_unit.service
[Unit]
Description=$systemd_unit.service
[Service]
Type=simple
User=$steam_user
Restart=on-failure
RestartSec=30s
ExecStart=$exec_start
[Install]
WantedBy=multi-user.target
EOF
sudo mv $systemd_unit.service /usr/lib/systemd/system/
echo "Starting palServer..."
sudo systemctl enable $systemd_unit
sudo systemctl restart $systemd_unit
sudo systemctl -l --no-pager status $systemd_unit
if systemctl --quiet is-active "$systemd_unit"
then
echo -e "\nPalServer is running successfully, enjoy!"
else
echo -e "\nThere were some problems with the installation, please check the log $log_path."
fi
echo "Installing zram..."
sudo apt-get install zram-config -y
sudo systemctl start zram-config.service
enable_zram
和 enable_auto_restart
是用于设置是否启用Zram和自动重启的标志。server_port
用于存储服务器端口号。--enable-zram
启用Zram,--enable-auto-restart
启用自动重启,--server-port=xxx
设置服务器端口号。#!/bin/bash
steamcmd_path=$(which steamcmd)
steam_user=steam
systemd_unit=pal-server
sudo -u $steam_user $steamcmd_path +login anonymous +app_update 2394010 validate +quit
sudo systemctl restart $systemd_unit
sudo systemctl -l --no-pager status $systemd_unit
if systemctl --quiet is-active "$systemd_unit"
then
echo -e "\nPalServer is running successfully, enjoy!"
else
echo -e "\nThere were some problems with the installation."
fi
steamcmd_path=$(which steamcmd)
: 这一行使用 which
命令来找到 steamcmd
的路径,并将其赋给变量 steamcmd_path
。steam_user=steam
: 这一行定义了 Steam 服务器使用的用户名,赋给变量 steam_user
。systemd_unit=pal-server
: 这一行定义了 systemd 单元的名称,赋给变量 systemd_unit
。sudo -u $steam_user steamcmd_path +login anonymous +app_update 2394010 validate +quit
: 这一行使用 sudo
以 steam
用户身份执行 steamcmd
命令,该命令登录匿名用户,更新 Steam App ID 为 2394010 的游戏服务器,并验证更新。sudo systemctl restart $systemd_unit
: 这一行使用 systemctl
命令重启指定的 systemd 单元。sudo systemctl -l --no-pager status $systemd_unit
: 这一行使用 systemctl
命令查看指定 systemd 单元的状态,并输出状态语句。wget -O - https://pal-server-1251810746.cos.accelerate.myqcloud.com/pal-server/Ubuntu/install_and_zram.sh|sh
wget -O - https://pal-server-1251810746.cos.accelerate.myqcloud.com/pal-server/Ubuntu/update.sh | sh
sudo systemctl status pal-server
sudo systemctl start pal-server
sudo systemctl stop pal-server
/home/steam/Steam/steamapps/common/PalServer/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
/home/steam/Steam/steamapps/common/PalServer/Pal/Saved/SaveGames/0/
Difficulty=None (难度)
DayTimeSpeedRate=1.000000 (日间速度倍率)
NightTimeSpeedRate=1.000000 (夜间速度倍率)
ExpRate=1.000000 (经验倍率)
PalCaptureRate=1.000000 (伙伴捕获倍率)
PalSpawnNumRate=1.000000 (伙伴生成数量倍率)
PalDamageRateAttack=1.000000 (伙伴攻击伤害倍率)
PalDamageRateDefense=1.000000 (伙伴防御伤害倍率)
PlayerDamageRateAttack=1.000000 (玩家攻击伤害倍率)
PlayerDamageRateDefense=1.000000 (玩家防御伤害倍率)
PlayerStomachDecreaceRate=1.000000 (玩家饥饿减少速率)
PlayerStaminaDecreaceRate=1.000000 (玩家体力减少速率)
PlayerAutoHPRegeneRate=1.000000 (玩家自动血量恢复倍率)
PlayerAutoHpRegeneRateInSleep=1.000000 (睡眠中玩家自动血量恢复倍率)
PalStomachDecreaceRate=1.000000 (伙伴饥饿减少速率)
PalStaminaDecreaceRate=1.000000 (伙伴体力减少速率)
PalAutoHPRegeneRate=1.000000 (伙伴自动血量恢复倍率)
PalAutoHpRegeneRateInSleep=1.000000 (睡眠中伙伴自动血量恢复倍率)
BuildObjectDamageRate=1.000000 (建筑物受损倍率)
BuildObjectDeteriorationDamageRate=1.000000 (建筑物劣化受损倍率)
CollectionDropRate=1.000000 (收集物掉落倍率)
CollectionObjectHpRate=1.000000 (收集物体生命值倍率)
CollectionObjectRespawnSpeedRate=1.000000 (收集物体重生速度倍率)
EnemyDropItemRate=1.000000 (敌人掉落物品倍率)
DeathPenalty=All (死亡惩罚)
bEnablePlayerToPlayerDamage=False (允许玩家对玩家造成伤害)
bEnableFriendlyFire=False (允许友军伤害)
bEnableInvaderEnemy=True (允许入侵敌人)
bActiveUNKO=False (未知)
bEnableAimAssistPad=True (启用手柄瞄准辅助)
bEnableAimAssistKeyboard=False (启用键盘瞄准辅助)
DropItemMaxNum=3000 (掉落物品最大数量)
DropItemMaxNum_UNKO=100 (掉落物品最大数量_UNKO)
BaseCampMaxNum=128 (基地最大数量)
BaseCampWorkerMaxNum=15 (基地工人最大数量)
DropItemAliveMaxHours=1.000000 (掉落物品存活最长时间(小时)
bAutoResetGuildNoOnlinePlayers=False (自动重置公会无在线玩家)
AutoResetGuildTimeNoOnlinePlayers=72.000000 (无在线玩家时自动重置公会时间(小时)
GuildPlayerMaxNum=20 (公会最大玩家数量)
PalEggDefaultHatchingTime=72.000000 (伙伴蛋默认孵化时间(小时)
WorkSpeedRate=1.000000 (工作速度倍率)
bIsMultiplay=False (多人游戏)
bIsPvP=False (PvP模式)
bCanPickupOtherGuildDeathPenaltyDrop=False (可以拾取其他公会死亡惩罚掉落)
bEnableNonLoginPenalty=True (启用非登录惩罚)
bEnableFastTravel=True (启用快速旅行)
bIsStartLocationSelectByMap=True (根据地图选择起始位置)
bExistPlayerAfterLogout=False (登出后玩家仍存在)
bEnableDefenseOtherGuildPlayer=False (启用防御其他公会玩家)
CoopPlayerMaxNum=4 (合作玩家最大数量)
ServerPlayerMaxNum=32 (服务器玩家最大数量)
ServerName="" (服务器名字)
ServerDescription="" (服务器描述)
AdminPassword="" (管理员密码)
ServerPassword="" (服务器密码)
PublicPort=8211 (公共端口号)
PublicIP="" (公共IP地址)
RCONEnabled=False (启用RCON)
RCONPort=25575 (RCON端口号)
Region="" (区域)
bUseAuth=True (使用身份验证)
BanListURL="https://api.palworldgame.com/api/banlist.txt" (封禁名单URL)
在线生成(临时开放,寒山雨大佬提供)
在线生成(Github大佬Bluefissure原作者提供,更新快,访问可能较慢)
%localappdata%\Pal\Saved\SaveGames\***************\存档ID
tools.zip
答:首先明确几种游戏的区别:
加入多人游戏(邀请码)
的方式进入,称为 本地档
。联机档
。目前可以实现的转档方案:
答:先登录一次服务器,然后退出,在文件资源管理器里输入 %localappdata%\Pal\Saved\SaveGames\
,往里找 旧存档ID
文件夹里的 LocalData.sav
文件复制到 新存档ID
文件夹
答:当前游戏版本中 PalWorldSettings.ini
的BaseCampWorkerMaxNum
修改后不生效,可使用同样的配置生成 WorldOption.sav
文件后放置到服务器steamapps/common/PalServer/Pal/Saved/SaveGames/0/.../WorldOption.sav
路径下,运行一次服务器在游戏中生效后即可删除重启服务器。
答:把据点的帕鲁放进背包里面,按 P 进入背包,然后按 R 丢弃该帕鲁,再按 F 捡起来,放回据点里面,这样帕鲁就可以互动了。
答:服务器端找到路径:
C:\Program Files\PalServer\Palworld\Pal\Saved\Config\WindowsServer\Engine.ini
(windows服务器)/home/steam/Steam/steamapps/common/PalServer/Palworld/Pal/Saved/Config/LinuxServer/Engine.ini
(Linux服务器)在该文件最下面下添加(最后的数字建议填30/60/90/120)
[/Script/OnlineSubsystemUtils.IpNetDriver]
NetServerMaxTickRate=90
保存文件,重启服务器生效。
答:查看/home/steam/Steam/steamapps/common/PalServer/Palworld/Pal/Saved/SaveGames/
路径下 新存档ID
文件夹及子文件的权限及权限组是否为 steam:steam
,若不是则修改。
参考命令:
sudo chown -R steam:steam /home/steam/Steam/steamapps/common/PalServer/Palworld/Pal/Saved/SaveGames/*
答:在新的 Windows服务器上正常安装服务端,然后关闭服务端,复制旧的 Windows 服务器上 C:\Program Files\PalServer\steam\steamapps\common\PalServer\Pal\Saved\
路径下的所有文件到新服务器上,再次开启服务端,即可无缝迁移。
**注意!**若在 PalWorldSettings.ini 设置了服务器 IP 的需要修改为的新的服务器 IP 。
答:改转档工具为 Github 项目 xNul/palworld-host-save-fix 可以修复在迁移转档过程中导致的创建新用户问题。
命令:
python fix-host-save.py
- uesave.exe 的路径
- 保存文件夹的路径
- 新服务器上玩家的 GUID
- 旧服务器上玩家的 GUID
- True 或 False,是否修复[公会错误]
示例:
python fix-host-save.py "C:\Users\John\.cargo\bin\uesave.exe" "C:\Users\John\Desktop\my_temporary_folder\2E85FD38BAA792EB1D4C09386F3A3CDA" 6E80B1A6000000000000000000000000 00000000000000000000000000000001 False