diff --git a/.github/workflows/update_offsets.yml b/.github/workflows/update_offsets.yml new file mode 100644 index 0000000..57f082a --- /dev/null +++ b/.github/workflows/update_offsets.yml @@ -0,0 +1,47 @@ +name: Update Offsets + +on: + schedule: + - cron: '0 * * * *' # Runs every hour + +jobs: + update_offsets: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install requests + shell: bash + + - name: Run Python Script + id: run-python-script + run: | + python ./offsets/update_offsets.py + continue-on-error: true + + - name: Check Python Script Exit Code + if: steps.run-python-script.outcome == 'failure' + run: | + echo "Repository has no updates" + exit 0 + + - name: Commit and push changes + if: steps.run-python-script.outcome == 'success' + run: | + git config --global user.email ${{ secrets.GIT_USER_EMAIL }} + git config --global user.name ${{ secrets.GIT_USER_NAME }} + git remote set-url origin https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} + git add offsets/offsets.json + git commit -m "Automatically updated offsets from https://github.com/a2x/cs2-dumper" + git push + shell: bash diff --git a/README.md b/README.md index 7cea3c0..522b60d 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ Simple external esp using gdi overlay to render esp boxes on top of cs2 highligh ## 💫 Credits * [UnnamedZ03](https://github.com/UnnamedZ03) for providing [offsets](https://www.unknowncheats.me/forum/3846642-post734.html) and guide with his [CS2-external-base](https://github.com/UnnamedZ03/CS2-external-base) +* [a2x](https://github.com/a2x) for his [offset dumper](https://github.com/a2x/cs2-dumper) and constant updates to it * [Bekston](https://github.com/Bekston) for his [contributions](https://github.com/IMXNOOBX/cs2-external-esp/pull/20) to the project and ideas * [Apxaey](https://github.com/Apxaey) for releasing an easy way to implement [handle hijacking](https://github.com/Apxaey/Handle-Hijacking-Anti-Cheat-Bypass) * Unknowncheats comunity for their reseach! diff --git a/offsets/update_offsets.py b/offsets/update_offsets.py new file mode 100644 index 0000000..757473d --- /dev/null +++ b/offsets/update_offsets.py @@ -0,0 +1,39 @@ +import sys +import requests +import json + +source_url = "https://github.com/a2x/cs2-dumper/raw/main/generated/offsets.json" +commits_url = "https://api.github.com/repos/a2x/cs2-dumper/commits" +dest_path = "./offsets/offsets.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: + commit_data = response.json() + if commit_data: + last_commit_message = commit_data[0]['commit']['message'] + build_number = last_commit_message.split()[-1] + +with open(dest_path, 'r') as dest_file: + dest_data = 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 + +dest_data["build_number"] = int(build_number) + +dest_data["dwBuildNumber"] = source_data["engine2_dll"]["dwBuildNumber"] +dest_data["dwLocalPlayer"] = source_data["client_dll"]["dwLocalPlayerPawn"] +dest_data["dwEntityList"] = source_data["client_dll"]["dwEntityList"] +dest_data["dwViewMatrix"] = source_data["client_dll"]["dwViewMatrix"] + +with open(dest_path, 'w') as dest_file: + json.dump(dest_data, 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 \ No newline at end of file