Skip to content

Instantly share code, notes, and snippets.

@quonic
Last active September 3, 2022 22:16
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quonic/279da005187df6e611b1b31859d91eeb to your computer and use it in GitHub Desktop.
Save quonic/279da005187df6e611b1b31859d91eeb to your computer and use it in GitHub Desktop.
For the game SCUM. This sets stats too 5 and skills to 4 for specified character.
#Requires -Module PSSQLite
param(
[Alias('Name', '')]
[string]
$ProfileName
)
<#
Updated for 9/2 patch
Updated by request of Truth91
#>
<#
For the game SCUM. This sets stats too 5 and skills to 4 for specified character.
Singleplayer only and run when the game isn't running
Requirements:
Install the module PSSQLite
Copy the line below and run it in powershell
Install-Module -Name "PSSQLite" -Scope CurrentUser
Then run this script from powershell. Replace ThisProfileName with your character in single player
.\scum_sqlite.ps1 -ProfileName 'ThisProfileName'
or if you want to update all profiles just run the following
.\scum_sqlite.ps1
#>
$Skill_Level = 4
$Attributes = 5
$Experience_Points = 10000000
$sqlsplat = @{
Datasource = "C:\Users\$($env:USERNAME)\AppData\Local\SCUM\Saved\SaveFiles\SCUM.db"
}
# Get all profiles from SQLite database file
$userprofiles = Invoke-SqliteQuery @sqlsplat -Query "select * from user_profile"
if ($ProfileName) {
# Get the prisoner_id from the database
$prisoner_id = ($userprofiles | Where-Object { $_.name -eq $ProfileName }).prisoner_id
}
else {
# Get each prisoner_id from the database and create an array of those id's
$prisoner_id = $userprofiles.prisoner_id
}
# Loop through each id, or only one if a profile name was provided
$prisoner_id | ForEach-Object {
$This_prisoner_id = $_
# Get the row of data where the id matches $This_prisoner_id
$prisoner = Invoke-SqliteQuery @sqlsplat -Query "select * from prisoner where id = $This_prisoner_id"
# Remove the null characters from the xml column as it messes with processing of the xml
[xml]$prisoner_xml = $prisoner.xml -replace "`0", ''
# Set the attribues to 5 as a string
$prisoner_xml.Prisoner.LifeComponent.CharacterAttributes._strength = "$Attributes"
$prisoner_xml.Prisoner.LifeComponent.CharacterAttributes._constitution = "$Attributes"
$prisoner_xml.Prisoner.LifeComponent.CharacterAttributes._intelligence = "$Attributes"
$prisoner_xml.Prisoner.LifeComponent.CharacterAttributes._dexterity = "$Attributes"
# Set the attribues' history to 5 as a strings, I don't know if this affects how thing calulate. This is just in case it does.
$prisoner_xml.Prisoner.LifeComponent.AttributeHistoryStrength.Attribute | ForEach-Object { $_._value = "$Attributes" }
$prisoner_xml.Prisoner.LifeComponent.AttributeHistoryConstitution.Attribute | ForEach-Object { $_._value = "$Attributes" }
$prisoner_xml.Prisoner.LifeComponent.AttributeHistoryDexterity.Attribute | ForEach-Object { $_._value = "$Attributes" }
$prisoner_xml.Prisoner.LifeComponent.AttributeHistoryIntelligence.Attribute | ForEach-Object { $_._value = "$Attributes" }
# Update the row in the database with the changes we made
$prisoner = Invoke-SqliteQuery @sqlsplat -Query "update prisoner set xml = '$($prisoner_xml.OuterXml)' where id = $This_prisoner_id;"
# Get the skills associated with $This_prisoner_id
$prisoner_skill = Invoke-SqliteQuery @sqlsplat -Query "select * from prisoner_skill where prisoner_id = $This_prisoner_id"
# Loop through each skill
$prisoner_skill | Where-Object { $_.level -ne "$Skill_Level" } | ForEach-Object {
# Remove the null characters from the xml column as it messes with processing of the xml
[xml]$prisoner_skill_xml = $_.xml -replace "`0", ''
# Set the _level to the $Skill_Level variable
$prisoner_skill_xml.Skill._level = "$Skill_Level"
# Set the _experiencePoints to $Experience_Points
$prisoner_skill_xml.Skill._experiencePoints = "$Experience_Points"
# Build the where part of the SQL query
$sqlwhere = "where prisoner_id = $This_prisoner_id and name = '$($prisoner_skill_xml.Skill.'#text')'"
# Build the rest of the SQL query
$Query = "update prisoner_skill set level = $Skill_Level, experience = '$Experience_Points', xml = '$($prisoner_skill_xml.OuterXml)' $sqlwhere;"
try {
# Update the prisoner's skills
Invoke-SqliteQuery @sqlsplat -Query $Query
}
catch {
# Something broke!
throw "error"
}
}
}
@D40G
Copy link

D40G commented Aug 28, 2020

how much trouble would it be to update this? to match latest and all skills?

@quonic
Copy link
Author

quonic commented Aug 28, 2020

how much trouble would it be to update this? to match latest and all skills?

I don't play it much anymore, mostly as I can't host my own private server on my own hardware.

As for updating, if someone where able to provide a sample SCUM.db file, then I'll update the script. That or someone else can take the concept and build a proper saved game editor.

@D40G
Copy link

D40G commented Aug 28, 2020

how much trouble would it be to update this? to match latest and all skills?

I don't play it much anymore, mostly as I can't host my own private server on my own hardware.

As for updating, if someone where able to provide a sample SCUM.db file, then I'll update the script. That or someone else can take the concept and build a proper saved game editor.

https://puu.sh/GmKq0.db

I've uploaded this SCUM.db

The script works, however, it only updates DEX skills to max with 10mil exp nothing else.
I tried fiddling with it... I didn't know how to fix it.

@quonic
Copy link
Author

quonic commented Aug 31, 2020

how much trouble would it be to update this? to match latest and all skills?

I don't play it much anymore, mostly as I can't host my own private server on my own hardware.
As for updating, if someone where able to provide a sample SCUM.db file, then I'll update the script. That or someone else can take the concept and build a proper saved game editor.

https://puu.sh/GmKq0.db

I've uploaded this SCUM.db

The script works, however, it only updates DEX skills to max with 10mil exp nothing else.
I tried fiddling with it... I didn't know how to fix it.

Updated, but I didn't functionally change anything. SCUM must be doing other checks that I can't figure out. Maybe it's expecting the null characters or there is some checksum that I don't know about?

I did add comments to help explain what the code is doing.

You can also use SQLiteStudio to edit the SCUM.db file by hand. Make backups before changing anything.

@CCLink501st
Copy link

Where do I put the file? Thanks.

@quonic
Copy link
Author

quonic commented Nov 14, 2020

@CCLink501st You can run the script from anywhere from within a PowerShell terminal.

@CCLink501st
Copy link

How do I do that?

@CCLink501st
Copy link

Sorry been playing with a few friends.

@CCLink501st
Copy link

so when I open powershell as admin I can not run the script. As non-admin it doesn't work.

@quonic
Copy link
Author

quonic commented Nov 14, 2020

@CCLink501st Open a PowerShell window. cd to where you have the script. Then run the script from there.

If that doesn't work, run Get-ChildItem "C:\Users\$($env:USERNAME)\AppData\Local\SCUM\Saved\SaveFiles\" . Is there is a file called SCUM.db ?

@CCLink501st
Copy link

The file I downloaded has squlite at the end of Scum

@quonic
Copy link
Author

quonic commented Nov 14, 2020

@CCLink501st Is there a file called SCUM.sqlite ?

If that is the case then changing the line from:

Datasource = "C:\Users\$($env:USERNAME)\AppData\Local\SCUM\Saved\SaveFiles\SCUM.db"

To:

Datasource = "C:\Users\$($env:USERNAME)\AppData\Local\SCUM\Saved\SaveFiles\SCUM.sqlite"

Might work, but if the devs changed the format of the data inside then my script won't work.

@CCLink501st
Copy link

Okay will try that thanks.

@CCLink501st
Copy link

It comes up with a bunch of not found errors.

@quonic
Copy link
Author

quonic commented Nov 15, 2020

Then the SCUM devs must have updated the game, or you don't have a single player save.

@CCLink501st
Copy link

Updated the game.

@andrewhun955
Copy link

andrewhun955 commented Aug 6, 2021

Tested in singeplayer and it still mostly works, but the attributes themselves won't save. They recently updated metabolism and changed how attributes work, so it probably has something to do with that. This is the only way I've been able to max out skills though, so thank you for making this :)

Edit: if you're curious heres the full error log (4 different saves)

The property '_strength' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:50 char:5

  • $prisoner_xml.Prisoner.LifeComponent.CharacterAttributes._strengt ...
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_constitution' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:51 char:5

  • $prisoner_xml.Prisoner.LifeComponent.CharacterAttributes._constit ...
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_intelligence' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:52 char:5

  • $prisoner_xml.Prisoner.LifeComponent.CharacterAttributes._intelli ...
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_dexterity' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:53 char:5

  • $prisoner_xml.Prisoner.LifeComponent.CharacterAttributes._dexteri ...
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_value' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:55 char:96

  • ... toryStrength.Attribute | ForEach-Object { $_._value = "$Attributes" }
  •                                           ~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_value' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:56 char:100

  • ... Constitution.Attribute | ForEach-Object { $_._value = "$Attributes" }
  •                                           ~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_value' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:57 char:97

  • ... oryDexterity.Attribute | ForEach-Object { $_._value = "$Attributes" }
  •                                           ~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_value' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:58 char:100

  • ... Intelligence.Attribute | ForEach-Object { $_._value = "$Attributes" }
  •                                           ~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_strength' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:50 char:5

  • $prisoner_xml.Prisoner.LifeComponent.CharacterAttributes._strengt ...
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_constitution' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:51 char:5

  • $prisoner_xml.Prisoner.LifeComponent.CharacterAttributes._constit ...
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_intelligence' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:52 char:5

  • $prisoner_xml.Prisoner.LifeComponent.CharacterAttributes._intelli ...
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_dexterity' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:53 char:5

  • $prisoner_xml.Prisoner.LifeComponent.CharacterAttributes._dexteri ...
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_value' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:55 char:96

  • ... toryStrength.Attribute | ForEach-Object { $_._value = "$Attributes" }
  •                                           ~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_value' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:56 char:100

  • ... Constitution.Attribute | ForEach-Object { $_._value = "$Attributes" }
  •                                           ~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_value' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:57 char:97

  • ... oryDexterity.Attribute | ForEach-Object { $_._value = "$Attributes" }
  •                                           ~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_value' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:58 char:100

  • ... Intelligence.Attribute | ForEach-Object { $_._value = "$Attributes" }
  •                                           ~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_strength' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:50 char:5

  • $prisoner_xml.Prisoner.LifeComponent.CharacterAttributes._strengt ...
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_constitution' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:51 char:5

  • $prisoner_xml.Prisoner.LifeComponent.CharacterAttributes._constit ...
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_intelligence' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:52 char:5

  • $prisoner_xml.Prisoner.LifeComponent.CharacterAttributes._intelli ...
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_dexterity' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:53 char:5

  • $prisoner_xml.Prisoner.LifeComponent.CharacterAttributes._dexteri ...
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_value' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:55 char:96

  • ... toryStrength.Attribute | ForEach-Object { $_._value = "$Attributes" }
  •                                           ~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_value' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:56 char:100

  • ... Constitution.Attribute | ForEach-Object { $_._value = "$Attributes" }
  •                                           ~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_value' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:57 char:97

  • ... oryDexterity.Attribute | ForEach-Object { $_._value = "$Attributes" }
  •                                           ~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

The property '_value' cannot be found on this object. Verify that the property exists and can be set.
At I:\scum_sqlite.ps1:58 char:100

  • ... Intelligence.Attribute | ForEach-Object { $_._value = "$Attributes" }
  •                                           ~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyNotFound

@Alpha0m3ga
Copy link

I am new to this. can someone tell me how to initiate this command. i have verified all locations and just dont know how to execute. Have tried finding this in the DB and cannot.

@quonic
Copy link
Author

quonic commented Aug 23, 2021

I am new to this. can someone tell me how to initiate this command. i have verified all locations and just dont know how to execute. Have tried finding this in the DB and cannot.

They seemed to changed some things in the DB and I don't play the game any more.

To answer you question, you have to run it from a PowerShell console.

@jh0ker
Copy link

jh0ker commented May 6, 2022

If anyone is still looking for a solution for this, i made a Python version of this script that works with the current version of SCUM (Build 0.7.5.46714 at the time of writing).
https://gist.github.com/jh0ker/1b8dd16f113b7ddc7b90e617ac0851c4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment