Skip to content

Commit

Permalink
3.8 release
Browse files Browse the repository at this point in the history
  • Loading branch information
GlennnM committed Sep 9, 2024
1 parent 6675bad commit 48f7b5a
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 6 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ There are different methods of running the PowerShell script. The methods are as
4) Next, to run the script, enter in the following:
`.\FlashClient.ps1`

### Second Method
### Second Method(does not work on Windows 11)

1) Right-click the PowerShell file that you'd like to run and click on "Run With PowerShell"
2) This will allow the script to run without having to do the above steps but Powershell will ask if you're sure you want to run this script.

### Third Method

1) Instead of the powershell file, download 'FlashClient.bat'(windows) or 'FlashClient.sh'(Mac) and run it. You might receive a warning since the application isn't signed.

<br>That's it! Next time you start BTD Battles, BTD5, SAS3, Countersnipe, or SAS4 on the archive they will be modded to link to the private server, allowing you to play online with other players.<br><b>Enjoy!!</b><br>
<br>Since the games are fairly inactive, you can play "solo" multiplayer with the following methods:<br>
Expand Down
141 changes: 141 additions & 0 deletions client/FlashClient.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<#:
@echo off
powershell /nologo /noprofile /command ^
"&{[ScriptBlock]::Create((cat """%~f0""") -join [Char[]]10).Invoke(@(&{$args}%*))}"
exit /b
#>

"Checking for Ninja Kiwi Archive..."
if ($IsWindows -or $ENV:OS) {
$cache = $env:APPDATA + '\Ninja Kiwi Archive\Cache'
$zippath = 'https://github.com/GlennnM/FlashPrivateServer/releases/download/v3.8/cache_windows.zip'
$filename = 'cache_windows.zip'
$FULL_SIZE = 45118579
} else {
$cache = $HOME + '/Library/Application Support/Ninja Kiwi Archive/Cache'
$zippath = 'https://github.com/GlennnM/FlashPrivateServer/releases/download/v3.8/cache_osx.zip'
$filename = 'cache_osx.zip'
$FULL_SIZE = 44935496
}
[int]$FULL_MB = $FULL_SIZE / 0.1MB
$FULL_MB_FLOAT = $FULL_MB / 10
$downloadpath = $cache + "/install.zip"
if (Test-Path -Path $cache) {
"Flash Private Server Installer by glenn m"
"The following mods will be installed:"
"Battles Flash Private Server"
"SAS4 Flash Private Server"
"BTD5 Flash Co-op/Challenges/Missions Private Server"
"SAS3 Flash Private Server"
"Countersnipe Private Server"
"Approx data size: $FULL_MB_FLOAT MB"
"==============================="

$X = Read-Host "Please ensure all Ninja Kiwi Archive windows(INCLUDING THE LAUNCHER!!!) are closed, then press ENTER to begin installation..."
$N = (New-Object Net.WebClient)
"Clearing archive cache..."
try {
Remove-Item $cache'/*' -Recurse
} catch {
$Q = Read-Host "Clearing cache failed, exiting."
exit
}
"Archive cache cleared!"
try {
"Checking version..."
$N.DownloadFile('https://github.com/GlennnM/FlashPrivateServer/raw/main/v3.8.txt',$cache + '/test.txt')
Remove-Item $cache'/test.txt'
"Version check successful!"
} catch {
"ERROR: script is not up to date, or you don't have an internet connection. Please update it at https://github.com/GlennnM/NKFlashServers"
$Q = Read-Host "Press enter to exit..."
exit
}
try {
Set-Location $cache
Write-Host -NoNewline "Downloading $filename ... "
$E = $N.DownloadFileTaskAsync($zippath,$downloadpath)
while (!($E.IsCompleted)) {
Start-Sleep -Seconds 1
try {
$size = (Get-Item -Path $downloadpath).Length
if ($size -eq 0) {
continue
}
[int]$percent = ($size / $FULL_SIZE * 1000)
[int]$mb = $size / 0.1MB
$percent_float = $percent / 10
$mb_float = $mb / 10
#Write-Progress -Activity "Downloading cache_windows.zip:" -Status "$percent_float% complete.." -PercentComplete $percent_float
Write-Host -NoNewline "`rDownloading $filename ... $percent_float% ($mb_float MB/$FULL_MB_FLOAT MB) "
} catch {

}
}
if ($size -lt $FULL_SIZE) {
"`n"
throw
}
Write-Host -NoNewline "`rDownloading $filename complete! "
#Invoke-RestMethod -ContentType "application/octet-stream" $zippath -OutFile $cache'/install.zip'
#Start-BitsTransfer -Source "$zippath" -Destination "$downloadpath"
"`nExtracting..."
try {
"Attempting unzip method 1(powershell 5+)..."
Expand-Archive -Path "$cache/install.zip" -DestinationPath "$cache/"

} catch {
try {
"Attempting unzip method 2(.NET)..."
Add-Type -AssemblyName System.IO.Compression.FileSystem
function Unzip
{
param([string]$zipfile,[string]$outpath)

[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile,$outpath)
}

Unzip "$cache/install.zip" "$cache/"
} catch {
try {
"Attempting unzip method 3(tar -xvf)"
Start-Process tar -Wait -NoNewWindow -ArgumentList -WorkingDirectory "$cache" @("-xvf","install.zip")

} catch {
if ($IsWindows -or $ENV:OS) {
"Attempting unzip method 4(7zip)"
Start-Process -Wait -FilePath "C:\Program Files\7-Zip\7z.exe" -NoNewWindow -WorkingDirectory "$cache" -ArgumentList @("e","install.zip")
} else {
"Attempting unzip method 4(unzip)"
Start-Process Unzip -Wait -NoNewWindow -WorkingDirectory "$cache" -ArgumentList @("install.zip")
}
}

}
}
Remove-Item "$cache/install.zip"

if (Test-Path -Path $cache'/index') {

"Mod installation successful!!!! You can play on private servers through Ninja Kiwi Archive."
"Note: Cache files are temporary; if it stops working after a few days simply run this script again."
} else {
"Mod installation failed."
}
$X = Read-Host "Press enter to exit..."
} catch {
$Q = Read-Host "One or more files failed to download, exiting."
} finally {
try {
$N.CancelAsync();
} catch {

}
$N.Dispose();
}
#Write-Progress -Activity "Downloading cache_windows.zip:" -Completed
} else {
"Ninja Kiwi Archive not found. Please install it from ninjakiwi.com or on Steam, and open it to generate the cache folder."
$Q = Read-Host "Press enter to exit..."
exit
}
10 changes: 5 additions & 5 deletions client/FlashClient.ps1
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"Checking for Ninja Kiwi Archive..."
if ($IsWindows -or $ENV:OS) {
$cache = $env:APPDATA + '\Ninja Kiwi Archive\Cache'
$zippath = 'https://github.com/GlennnM/FlashPrivateServer/releases/download/v3.7/cache_windows.zip'
$zippath = 'https://github.com/GlennnM/FlashPrivateServer/releases/download/v3.8/cache_windows.zip'
$filename = 'cache_windows.zip'
$FULL_SIZE = 45361249
$FULL_SIZE = 45118579
} else {
$cache = $HOME + '/Library/Application Support/Ninja Kiwi Archive/Cache'
$zippath = 'https://github.com/GlennnM/FlashPrivateServer/releases/download/v3.7/cache_osx.zip'
$zippath = 'https://github.com/GlennnM/FlashPrivateServer/releases/download/v3.8/cache_osx.zip'
$filename = 'cache_osx.zip'
$FULL_SIZE = 45178267
$FULL_SIZE = 44935496
}
[int]$FULL_MB = $FULL_SIZE / 0.1MB
$FULL_MB_FLOAT = $FULL_MB / 10
Expand Down Expand Up @@ -36,7 +36,7 @@ if (Test-Path -Path $cache) {
"Archive cache cleared!"
try {
"Checking version..."
$N.DownloadFile('https://github.com/GlennnM/FlashPrivateServer/raw/main/v3.7.txt',$cache + '/test.txt')
$N.DownloadFile('https://github.com/GlennnM/FlashPrivateServer/raw/main/v3.8.txt',$cache + '/test.txt')
Remove-Item $cache'/test.txt'
"Version check successful!"
} catch {
Expand Down
8 changes: 8 additions & 0 deletions client/FlashClient.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
curl https://github.com/GlennnM/FlashPrivateServer/raw/main/v3.8.txt > /dev/null && \
cd "$HOME/Library/Application Support/Ninja Kiwi Archive/Cache" && \
rm -r * && \
curl -sS -L https://github.com/GlennnM/FlashPrivateServer/releases/download/v3.8/cache_osx.zip > file.zip && \
unzip file.zip && \
rm file.zip && \
echo "Installation successful!"
File renamed without changes.

0 comments on commit 48f7b5a

Please sign in to comment.