Xyberviri

NukeCells.ps1

Jan 10th, 2023
1,275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 1.42 KB | Software | 0 0
  1. Function Get-FileName($initialDirectory)
  2. {
  3.     [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
  4.     #(*.bmp, *.jpg)|*.bmp;*.jpg
  5.     $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
  6.     $OpenFileDialog.initialDirectory = $initialDirectory
  7.     $OpenFileDialog.filter = "List (*.txt)| *.txt|ALL Files (*.*)| *.*"
  8.     $OpenFileDialog.ShowDialog() | Out-Null
  9.     $OpenFileDialog.filename
  10. }
  11.  
  12. function GetNextID($maxSize = 5)
  13. {
  14.     $g = [guid]::NewGuid()
  15.     $v = [string]$g
  16.     $v = $v.Replace("-", "")
  17.     return $v.substring(0, $maxSize)
  18. }
  19.  
  20. function Delete-MapData
  21. {
  22.     Param ([string]$location,[string]$chunk)    
  23.     $map = ([string]::Format("{0}\map_{1}.bin",$location,$chunk))
  24.     $datachunk = ([string]::Format("{0}\isoregiondata\datachunk_{1}.bin",$location,$chunk))
  25.     if(Test-Path -Path $map -PathType Leaf)
  26.     {
  27.         Write-Host "REMOVING " $map
  28.         Remove-Item $map
  29.     }
  30.  
  31.     if(Test-Path -Path $datachunk -PathType Leaf)
  32.     {
  33.         Write-Host "REMOVING " $datachunk
  34.         Remove-Item $datachunk
  35.     }
  36.  
  37.  
  38. }
  39.  
  40.  
  41.  
  42.  
  43. try {
  44. # Get Input
  45. $here = (Get-Location).Path
  46. $filename = Get-FileName($here)
  47. $rootfolder = "<PATHTO>\Zomboid\Saves\Multiplayer\servertest"
  48. $content = get-content ($filename)
  49.  
  50. foreach ($line in $content)
  51. {
  52.     Delete-MapData -location $rootfolder -chunk $line
  53. }
  54.  
  55. } catch {
  56. write-host "No input given."
  57. exit 0
  58. }
  59.  
Advertisement
Add Comment
Please, Sign In to add comment