Last active
June 20, 2024 22:47
-
-
Save VIRUXE/6347504fa9d84cff52b202425cae01f1 to your computer and use it in GitHub Desktop.
Fetch a comma-separated resource list from a FiveM server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
$serverCode = $args[0] | |
if (-not $serverCode) { $serverCode = Read-Host -Prompt 'Please enter the server code' } | |
$json = Invoke-RestMethod -Uri "https://servers-frontend.fivem.net/api/servers/single/$serverCode" | |
$serverResources = $json.Data.resources | Sort-Object | |
Write-Host "Server resources:" | |
Write-Host ($serverResources -join ', ') | |
} catch { | |
Write-Host "An error occurred while retrieving server resources: $_" | |
} finally { | |
Write-Host | |
Write-Host "Press any key to exit..." | |
[System.Console]::ReadKey($true) | Out-Null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment