@echo off
setlocal
cd /d "%~dp0"
title AKMenu - Online (GTA V Legacy)
color 0A

set "GOLDEN=%~dp0AKMenu-July2-WORKING.exe"
set "VERIFY=%~dp0scripts\verify_golden_build.ps1"
set "PREP=%~dp0prep_online_launch.ps1"

echo.
echo  ============================================================
echo    AKMenu - verified before every launch
echo    Story first, then Online. BattlEye must be OFF.
echo  ============================================================
echo.

if not exist "%GOLDEN%" (
    echo [BLOCKED] Missing AKMenu-July2-WORKING.exe
    pause
    exit /b 1
)

powershell -NoProfile -ExecutionPolicy Bypass -File "%VERIFY%" -ExePath "%GOLDEN%"
if errorlevel 1 (
    echo.
    echo [BLOCKED] Verify failed. Do NOT launch. Re-download the package.
    pause
    exit /b 1
)

for %%P in (GTA5 GTA5_Enhanced PlayGTAV) do taskkill /IM %%P.exe /F >nul 2>&1
timeout /t 2 /nobreak >nul

if exist "%APPDATA%\AKMenu\cache\gta_pointers.bin" del /f /q "%APPDATA%\AKMenu\cache\gta_pointers.bin"
if exist "%APPDATA%\AKMenu\cache\sc_pointers.bin" del /f /q "%APPDATA%\AKMenu\cache\sc_pointers.bin"
if exist "%APPDATA%\AKMenu\runtime" rmdir /s /q "%APPDATA%\AKMenu\runtime"

powershell -NoProfile -ExecutionPolicy Bypass -File "%PREP%"

echo.
echo BattlEye OFF. Story ~2 min -^> Pause -^> Online.
echo Open menu in-game with INSERT.
echo.
start "" "%GOLDEN%"
pause
