Updated auto update script 👌

Now all offsets are updated and the update check is done more precisely
This commit is contained in:
IMXNOOBX
2025-01-14 14:30:54 +01:00
parent 8db68ca144
commit 542fb3723f
2 changed files with 123 additions and 56 deletions
+21 -21
View File
@@ -1,26 +1,26 @@
{
"build_number": 14058,
"dwBuildNumber": 5450724,
"dwEntityList": 27346680,
"dwLocalPlayer": 27322792,
"dwPlantedC4": 27807648,
"dwViewMatrix": 27784736,
"m_ArmorValue": 8912,
"m_bIsDefusing": 8866,
"m_flC4Blow": 3840,
"m_flFlashOverlayAlpha": 4944,
"m_flNextBeep": 3836,
"m_flTimerLength": 3848,
"m_hPlayerPawn": 2012,
"dwBuildNumber": 5454820,
"dwEntityList": 27350984,
"dwLocalPlayer": 25599368,
"dwPlantedC4": 27811984,
"dwViewMatrix": 27789424,
"m_ArmorValue": 9244,
"m_bIsDefusing": 9194,
"m_flC4Blow": 4032,
"m_flFlashOverlayAlpha": 5120,
"m_flNextBeep": 4028,
"m_flTimerLength": 4040,
"m_hPlayerPawn": 2060,
"m_iAccount": 64,
"m_iHealth": 804,
"m_iTeamNum": 963,
"m_pClippingWeapon": 4848,
"m_pGameSceneNode": 776,
"m_pInGameMoneyServices": 1776,
"m_sSanitizedPlayerName": 1856,
"m_szName": 3112,
"m_vOldOrigin": 4724,
"m_iHealth": 836,
"m_iTeamNum": 995,
"m_pClippingWeapon": 5024,
"m_pGameSceneNode": 808,
"m_pInGameMoneyServices": 1824,
"m_sSanitizedPlayerName": 1904,
"m_szName": 3360,
"m_vOldOrigin": 4900,
"m_vecAbsOrigin": 208,
"dwLocalPlayerController": 27676304
"dwLocalPlayerController": 27680624
}
+97 -30
View File
@@ -4,49 +4,116 @@ import json
import re
import os
source_url = "https://raw.githubusercontent.com/a2x/cs2-dumper/main/output/offsets.json"
commits_url = "https://api.github.com/repos/a2x/cs2-dumper/commits"
if os.path.isfile("./offsets/offsets.json"):
dest_path = "./offsets/offsets.json"
elif os.path.isfile("./offsets.json"):
dest_path = "./offsets.json"
else:
print("Invalid path for 'offsets.json'")
exit()
urls = {
"commits": "https://api.github.com/repos/a2x/cs2-dumper/commits",
"offsets": "https://raw.githubusercontent.com/a2x/cs2-dumper/main/output/offsets.json",
"client_dll": "https://github.com/a2x/cs2-dumper/raw/refs/heads/main/output/client_dll.json",
}
# Fetch the source JSON
source_response = requests.get(source_url)
source_data = source_response.json()
# Fetch build Number
response = requests.get(commits_url)
build_number = 0
if response.status_code == 200:
def get_build_number():
response = requests.get(urls["commits"])
if response.status_code == 200:
commit_data = response.json()
if commit_data:
for commit in commit_data:
commit_message = commit['commit']['message']
build_match = re.search(r'\bGame [Uu]pdate \((\d+)(?: \(\d+\))?\b', commit_message)
if build_match:
build_number = int(build_match.group(1))
break
return int(build_match.group(1))
return 0
def get_raw_file(url):
response = requests.get(url)
if response.status_code == 200:
return response.json()
return None
def get_path():
if os.path.isfile("./offsets/offsets.json"):
return "./offsets/offsets.json"
elif os.path.isfile("./offsets.json"):
return "./offsets.json"
else:
return None
dest_path = get_path()
if not dest_path:
print("Invalid path for 'offsets.json'")
exit(1)
build_number = get_build_number()
if build_number == 0:
print("Could not find the latest build number.")
exit(1)
offsets = get_raw_file(urls["offsets"])
if not offsets:
print("Could not find the latest offsets.")
exit(1)
with open(dest_path, 'r') as dest_file:
dest_data = json.load(dest_file)
offsets_json = json.load(dest_file)
if dest_data["build_number"] == int(build_number):
print("There are no updates in the remote reposioty")
sys.exit(1) # Exit so we know that there hasnt been any updates and the current offsets are up to date
print(f"Current build number: {offsets_json['build_number']} vs Latest build number: {build_number}")
dest_data["build_number"] = int(build_number)
if offsets_json["build_number"] == int(build_number):
print(f"There are no updates in the remote repository after {build_number}.")
print("Comparing the offsets in the local offsets (dwLocalPlayer/dwViewMatrix) with the remote repository.")
dest_data["dwBuildNumber"] = source_data["engine2.dll"]["dwBuildNumber"]
dest_data["dwLocalPlayerController"] = source_data["client.dll"]["dwLocalPlayerController"]
dest_data["dwEntityList"] = source_data["client.dll"]["dwEntityList"]
dest_data["dwViewMatrix"] = source_data["client.dll"]["dwViewMatrix"]
dest_data["dwPlantedC4"] = source_data["client.dll"]["dwPlantedC4"]
valid = offsets_json["dwLocalPlayer"] == offsets["client.dll"]["dwLocalPlayerPawn"] and \
offsets_json["dwViewMatrix"] == offsets["client.dll"]["dwViewMatrix"]
# Exit so we know that there hasnt been any updates and the current offsets are up to date
if valid:
print("Local offsets are up to date.")
exit(1)
print("Local offsets (dwLocalPlayer/dwViewMatrix) are outdated, pulling the latest offsets.")
offsets_json["build_number"] = int(build_number)
offsets_json["dwBuildNumber"] = offsets["engine2.dll"]["dwBuildNumber"]
offsets_json["dwLocalPlayer"] = offsets["client.dll"]["dwLocalPlayerPawn"]
offsets_json["dwLocalPlayerController"] = offsets["client.dll"]["dwLocalPlayerController"]
offsets_json["dwEntityList"] = offsets["client.dll"]["dwEntityList"]
offsets_json["dwViewMatrix"] = offsets["client.dll"]["dwViewMatrix"]
offsets_json["dwPlantedC4"] = offsets["client.dll"]["dwPlantedC4"]
client = get_raw_file(urls["client_dll"])
if not client:
print("Could not find the latest client.dll.")
exit(1)
client_json_base = client["client.dll"]["classes"]
offsets_json["m_bIsDefusing"] = client_json_base["C_CSPlayerPawn"]["fields"]["m_bIsDefusing"]
offsets_json["m_ArmorValue"] = client_json_base["C_CSPlayerPawn"]["fields"]["m_ArmorValue"]
offsets_json["m_pClippingWeapon"] = client_json_base["C_CSPlayerPawnBase"]["fields"]["m_pClippingWeapon"]
offsets_json["m_flFlashOverlayAlpha"] = client_json_base["C_CSPlayerPawnBase"]["fields"]["m_flFlashOverlayAlpha"]
offsets_json["m_flC4Blow"] = client_json_base["C_PlantedC4"]["fields"]["m_flC4Blow"]
offsets_json["m_flNextBeep"] = client_json_base["C_PlantedC4"]["fields"]["m_flNextBeep"]
offsets_json["m_flTimerLength"] = client_json_base["C_PlantedC4"]["fields"]["m_flTimerLength"]
offsets_json["m_hPlayerPawn"] = client_json_base["CCSPlayerController"]["fields"]["m_hPlayerPawn"]
offsets_json["m_iAccount"] = client_json_base["CCSPlayerController_InGameMoneyServices"]["fields"]["m_iAccount"]
offsets_json["m_pInGameMoneyServices"] = client_json_base["CCSPlayerController"]["fields"]["m_pInGameMoneyServices"]
offsets_json["m_sSanitizedPlayerName"] = client_json_base["CCSPlayerController"]["fields"]["m_sSanitizedPlayerName"]
offsets_json["m_iHealth"] = client_json_base["C_BaseEntity"]["fields"]["m_iHealth"]
offsets_json["m_iTeamNum"] = client_json_base["C_BaseEntity"]["fields"]["m_iTeamNum"]
offsets_json["m_pGameSceneNode"] = client_json_base["C_BaseEntity"]["fields"]["m_pGameSceneNode"]
offsets_json["m_szName"] = client_json_base["CCSWeaponBaseVData"]["fields"]["m_szName"]
offsets_json["m_vOldOrigin"] = client_json_base["C_BasePlayerPawn"]["fields"]["m_vOldOrigin"]
offsets_json["m_vecAbsOrigin"] = client_json_base["CGameSceneNode"]["fields"]["m_vecAbsOrigin"]
with open(dest_path, 'w') as dest_file:
json.dump(dest_data, dest_file, indent=4)
json.dump(offsets_json, dest_file, indent=4)
print("Offsets updated in the local file.") # We dont exit so we know that the game has been updated and that we have to commit the new offsets