Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Checks the DMP reputation files and whenever reputation decreases it resets the value to the last known higher one
- #
- #Just copy this into a textfile and call it whatever.ps1 in the DMP main directory next to the updater
- #Start best before the server since it needs to get a good reputation value once
- $folders = Get-ChildItem .\Universe\Scenarios | ?{ $_.PSIsContainer }
- $players = @{}
- function getIni
- {
- param (
- [parameter(mandatory=$true,position=0)][String]$FilePath
- )
- $Ini = @{}
- if(Test-Path -Path $FilePath)
- {
- Get-Content $FilePath | foreach {
- $line = $_.split("=")
- $Ini.($line[0].Trim()) = $line[1].Trim()
- }
- }
- return $Ini
- }
- function getReputation
- {
- param (
- [parameter(mandatory=$true,position=0)]$PlayerFolder
- )
- [double]$rv = -99999
- [string]$repFilePath = $PlayerFolder + '\Reputation.txt'
- if(Test-Path -Path $repFilePath)
- {
- $repIni = getIni $repFilePath
- [double]$rv = [convert]::ToDouble($repIni.'rep')
- }
- return $rv
- }
- function setReputation
- {
- param (
- [parameter(mandatory=$true,position=0)]$PlayerFolder,
- [parameter(mandatory=$true,position=1)][double]$newRep
- )
- [string]$repFilePath = $PlayerFolder + '\Reputation.txt'
- if(Test-Path -Path $repFilePath)
- {
- $rawS = (get-content $repFilePath) -replace "rep =.*", "rep = $newRep"
- $rawS | Out-File $repFilePath
- }
- }
- function checkReputation
- {
- foreach ($player in $players.Values)
- {
- $currentRep = getReputation $player.myFolder
- if($currentRep -lt $player.reputation)
- {
- setReputation $player.myFolder $lastRep
- }
- }
- }
- $i = 0
- foreach ($folder in $folders)
- {
- $rep = getReputation $folder.FullName
- if($rep -ne -99999)
- {
- $player = [pscustomobject]@{myFolder=$folder.FullName; reputation=$rep}
- #$players.Add($folder.Name [$i] = $player
- $players.Add($folder.Name, $player)
- $i++
- }
- }
- While(1){
- checkReputation
- sleep(5)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement