Skip to content

Instantly share code, notes, and snippets.

@quonic

quonic/scum_sqlite.ps1

Last active Nov 15, 2020
Embed
What would you like to do?
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"
}
}
}
@Truth91

This comment has been minimized.

Copy link

@Truth91 Truth91 commented Aug 28, 2020

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

@quonic

This comment has been minimized.

Copy link
Owner Author

@quonic 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.

@Truth91

This comment has been minimized.

Copy link

@Truth91 Truth91 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

This comment has been minimized.

Copy link
Owner Author

@quonic 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

This comment has been minimized.

Copy link

@CCLink501st CCLink501st commented Nov 14, 2020

Where do I put the file? Thanks.

@quonic

This comment has been minimized.

Copy link
Owner Author

@quonic quonic commented Nov 14, 2020

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

@CCLink501st

This comment has been minimized.

Copy link

@CCLink501st CCLink501st commented Nov 14, 2020

How do I do that?

@CCLink501st

This comment has been minimized.

Copy link

@CCLink501st CCLink501st commented Nov 14, 2020

Sorry been playing with a few friends.

@CCLink501st

This comment has been minimized.

Copy link

@CCLink501st CCLink501st commented Nov 14, 2020

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

@quonic

This comment has been minimized.

Copy link
Owner Author

@quonic 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

This comment has been minimized.

Copy link

@CCLink501st CCLink501st commented Nov 14, 2020

The file I downloaded has squlite at the end of Scum

@quonic

This comment has been minimized.

Copy link
Owner Author

@quonic 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

This comment has been minimized.

Copy link

@CCLink501st CCLink501st commented Nov 14, 2020

Okay will try that thanks.

@CCLink501st

This comment has been minimized.

Copy link

@CCLink501st CCLink501st commented Nov 15, 2020

It comes up with a bunch of not found errors.

@quonic

This comment has been minimized.

Copy link
Owner Author

@quonic quonic commented Nov 15, 2020

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

@CCLink501st

This comment has been minimized.

Copy link

@CCLink501st CCLink501st commented Nov 15, 2020

Updated the game.

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