Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- param(
- [string]$SteamPath = "${env:ProgramFiles(x86)}\Steam",
- [string]$GamePath = "${env:ProgramFiles(x86)}\Steam\steamapps\common\ProjectZomboid"
- )
- $ColorSuccess = "Green"
- $ColorError = "Red"
- $ColorWarning = "Yellow"
- $ColorInfo = "Cyan"
- function Write-ColoredMessage {
- param(
- [string]$Message,
- [string]$Color
- )
- Write-Host $Message -ForegroundColor $Color
- }
- function Test-PathExists {
- param(
- [string]$Path,
- [string]$Description
- )
- if (Test-Path $Path) {
- Write-ColoredMessage "✓ $Description found: $Path" $ColorSuccess
- return $true
- } else {
- Write-ColoredMessage "✗ $Description not found: $Path" $ColorError
- return $false
- }
- }
- $ModsConfig = @(
- @{
- ID = "2909035179"
- Name = "Better Car Physics"
- SourcePath = "\mods\BetterCarPhysics\41\zombie"
- DestinationPath = "\zombie"
- IsFile = $false
- },
- @{
- ID = "3119788162"
- Name = "Every Texture Optimized"
- SourcePath = "\mods\Every Texture Optimized\media"
- DestinationPath = "\media"
- IsFile = $false
- },
- @{
- ID = "3022543997"
- Name = "BetterFPS (4K optimized version)"
- SourcePath = "\mods\BetterFPS\media\4k\zombie"
- DestinationPath = "\zombie"
- IsFile = $false
- },
- @{
- ID = "3456462930"
- Name = "Commandline FPS+++"
- SourcePath = "\mods\Commandline FPS+++\media\common\commandline.txt"
- DestinationPath = "\media\common\commandline.txt"
- IsFile = $true
- }
- )
- Write-ColoredMessage "=== Project Zomboid Mods Auto-Installer ===" $ColorInfo
- Write-ColoredMessage "Starting checks..." $ColorInfo
- Write-Host ""
- $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
- if (-not $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
- Write-ColoredMessage "⚠️ WARNING: Running without administrator privileges." $ColorWarning
- Write-ColoredMessage " Some operations may fail if insufficient permissions." $ColorWarning
- Write-Host ""
- }
- $WorkshopPath = "$SteamPath\steamapps\workshop\content\108600"
- Write-ColoredMessage "Checking base paths..." $ColorInfo
- $steamExists = Test-PathExists $SteamPath "Steam"
- $workshopExists = Test-PathExists $WorkshopPath "Project Zomboid Workshop"
- $gameExists = Test-PathExists $GamePath "Project Zomboid"
- if (-not ($steamExists -and $workshopExists -and $gameExists)) {
- Write-ColoredMessage "" $ColorError
- Write-ColoredMessage "ERROR: Base paths not found!" $ColorError
- Write-ColoredMessage "Please verify that:" $ColorError
- Write-ColoredMessage "1. Steam is installed in the default path" $ColorError
- Write-ColoredMessage "2. Project Zomboid is installed" $ColorError
- Write-ColoredMessage "3. Mods have been downloaded from Steam Workshop" $ColorError
- Write-Host ""
- Write-ColoredMessage "Paths checked:" $ColorInfo
- Write-ColoredMessage "Steam: $SteamPath" $ColorInfo
- Write-ColoredMessage "Workshop: $WorkshopPath" $ColorInfo
- Write-ColoredMessage "Game: $GamePath" $ColorInfo
- Read-Host "Press Enter to exit"
- exit 1
- }
- Write-Host ""
- Write-ColoredMessage "Checking mods..." $ColorInfo
- $AllModsExist = $true
- $ModsToInstall = @()
- foreach ($mod in $ModsConfig) {
- $modPath = "$WorkshopPath\$($mod.ID)"
- $sourcePath = "$modPath$($mod.SourcePath)"
- Write-ColoredMessage "Checking mod: $($mod.Name)" $ColorInfo
- if (Test-Path $modPath) {
- if (Test-Path $sourcePath) {
- Write-ColoredMessage " ✓ Mod files found" $ColorSuccess
- $ModsToInstall += $mod
- } else {
- Write-ColoredMessage " ✗ Specific mod files not found: $sourcePath" $ColorError
- $AllModsExist = $false
- }
- } else {
- Write-ColoredMessage " ✗ Mod not found: $modPath" $ColorError
- Write-ColoredMessage " Make sure the mod is subscribed on Steam Workshop" $ColorWarning
- $AllModsExist = $false
- }
- }
- if (-not $AllModsExist) {
- Write-Host ""
- Write-ColoredMessage "ERROR: Not all mods were found!" $ColorError
- Write-ColoredMessage "Subscribe to the mods on Steam Workshop and try again." $ColorError
- Read-Host "Press Enter to exit"
- exit 1
- }
- if ($ModsToInstall.Count -eq 0) {
- Write-ColoredMessage "No valid mods found for installation." $ColorWarning
- Read-Host "Press Enter to exit"
- exit 1
- }
- Write-Host ""
- Write-ColoredMessage "All mods found! ($($ModsToInstall.Count) mods)" $ColorSuccess
- Write-Host ""
- Write-ColoredMessage "Mods to be installed:" $ColorInfo
- foreach ($mod in $ModsToInstall) {
- Write-ColoredMessage " • $($mod.Name)" $ColorInfo
- }
- Write-Host ""
- $confirmation = Read-Host "Do you want to continue with installation? (Y/N)"
- if ($confirmation -notmatch '^[Yy]$') {
- Write-ColoredMessage "Installation cancelled by user." $ColorWarning
- exit 0
- }
- Write-Host ""
- Write-ColoredMessage "Starting mod installation..." $ColorInfo
- $SuccessCount = 0
- $ErrorCount = 0
- foreach ($mod in $ModsToInstall) {
- Write-Host ""
- Write-ColoredMessage "Installing: $($mod.Name)" $ColorInfo
- try {
- $sourcePath = "$WorkshopPath\$($mod.ID)$($mod.SourcePath)"
- $destinationPath = "$GamePath$($mod.DestinationPath)"
- if ($mod.IsFile) {
- $destinationDir = Split-Path $destinationPath -Parent
- if (-not (Test-Path $destinationDir)) {
- New-Item -ItemType Directory -Path $destinationDir -Force | Out-Null
- Write-ColoredMessage " Created directory: $destinationDir" $ColorInfo
- }
- }
- if ($mod.IsFile) {
- Copy-Item -Path $sourcePath -Destination $destinationPath -Force
- Write-ColoredMessage " ✓ File replaced successfully" $ColorSuccess
- } else {
- if (-not (Test-Path $destinationPath)) {
- New-Item -ItemType Directory -Path $destinationPath -Force | Out-Null
- Write-ColoredMessage " Destination folder created" $ColorInfo
- }
- Copy-Item -Path "$sourcePath\*" -Destination $destinationPath -Recurse -Force
- Write-ColoredMessage " ✓ Mod content merged successfully" $ColorSuccess
- }
- $SuccessCount++
- } catch {
- Write-ColoredMessage " ✗ Error installing mod: $($_.Exception.Message)" $ColorError
- $ErrorCount++
- }
- }
- Write-Host ""
- Read-Host "Press Enter to exit"
Advertisement
Add Comment
Please, Sign In to add comment