Advertisement
Combreal

New-Mapcycle.ps1

Mar 10th, 2024 (edited)
943
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2. .DESCRIPTION
  3. Generates a random mapcycle.txt for Halo PC SAPP server from the mapList.txt and gametypeList.txt.
  4. Creates mapList.txt and gametypeList.txt with originals maps and gametypes if they don't exist.
  5. #>
  6.  
  7. $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
  8. $mapListPath = "$scriptPath\mapList.txt"
  9. $gametypeListPath = "$scriptPath\gametypeList.txt"
  10. $mapcyclePath = "$scriptPath\mapcycle.txt"
  11.  
  12. $mapcycleSize = 7
  13.  
  14. $mapList = @(
  15.     "bloodgulch",
  16.     "beavercreek",
  17.     "boardingaction",
  18.     "carousel",
  19.     "chillout",
  20.     "dangercanyon",
  21.     "deathisland",
  22.     "direlict",
  23.     "gephyrophobia",
  24.     "hangemhigh",
  25.     "icefield",
  26.     "infinity",
  27.     "longest",
  28.     "prisoner",
  29.     "putput",
  30.     "ratrace",
  31.     "sidewinder",
  32.     "timberland",
  33.     "wizard"
  34. )
  35.  
  36. $gametypeList = @(
  37.     "oddball",
  38.     "slayer",
  39.     "juggernaut",
  40.     "king",
  41.     "crazy king",
  42.     "race",
  43.     "ctf",
  44.     "assault",
  45.     "team slayer",
  46.     "team oddball",
  47.     "team race"
  48. )
  49.  
  50. If (-Not (Test-Path -Path $mapListPath)) {
  51.     Out-File -FilePath $mapListPath -InputObject $mapList
  52. }
  53.  
  54. If (-Not (Test-Path -Path $gametypeListPath)) {
  55.     Out-File -FilePath $gametypeListPath -InputObject $gametypeList
  56. }
  57.  
  58. $finalMapList = Get-Content $mapListPath
  59. $finalGametypeList = Get-Content $gametypeListPath
  60.  
  61. $mapcycle = ""
  62. For ($i=0; $i -lt $mapcycleSize;$i++) {
  63.     $mapcycle = $mapcycle + "$($finalMapList[$(Get-Random -Minimum 0 -Maximum $finalMapList.Length)]):$($finalGametypeList[$(Get-Random -Minimum 0 -Maximum $finalGametypeList.Length)]):0:16`n"
  64. }
  65.  
  66. $mapcycle = $mapcycle.Trim()
  67. [System.IO.File]::WriteAllText($mapcyclePath, $mapcycle)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement