@echo off
setlocal

start "" "C:\Program Files (x86)\MTA San Andreas 1.6\Multi Theft Auto.exe"

:WAIT_FOR_GTASA
tasklist | find /i "gta_sa.exe" >nul
if errorlevel 1 (
    echo [DEBUG] GTA:SA not found, retrying...
    timeout /t 2 /nobreak >nul
    goto WAIT_FOR_GTASA
)

echo [DEBUG] GTA:SA detected

timeout /t 15

:: Get process ID of gta_sa.exe
for /f "tokens=2 delims=," %%A in ('tasklist /FI "IMAGENAME eq gta_sa.exe" /FO CSV /NH') do set PID=%%A

:: Check if the process exists
if "%PID%"=="" (
    echo gta_sa.exe is not running.
    pause
    exit
)

:: Uncheck Core 0 using PowerShell
powershell -Command "& { $p = Get-Process -Id %PID%; $p.ProcessorAffinity = ($p.ProcessorAffinity -band 0xFFFFFFFE) }"

echo Core 0 unchecked for gta_sa.exe
timeout /t 3
exit