AuthRemoved open source
WizV4Menu.lua Macho LUA
Download
12,000 lines · updated 4 hours ago
Preview shortened for your browser. Download the file for the full source.
if GetResourceState('WaveShield') == 'started' or GetResourceState('zacy') == 'started' then
    return MachoMenuNotification('Wiz', 'cannot inject because WaveShield or zacy is running')
end

MachoLockLogger(1)
isAuthenticated = true
isPrivate = true


local bit = bit or bit32
if not bit then
    local func = load([[
        return {
            bor = function(a,b) return a | b end,
            band = function(a,b) return a & b end,
            bxor = function(a,b) return a ~ b end,
            rshift = function(a,b) return a >> b end,
            lshift = function(a,b) return a << b end,
            bnot = function(a) return ~a end
        }
    ]])
    if func then
        bit = func()
    end
end

local function md5(str)
    local K = {
        0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
        0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
        0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
        0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
        0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
        0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05, 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
        0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
        0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
    }

    local function leftrotate(x, c)
        return bit.bor(bit.band(bit.lshift(x, c), 0xFFFFFFFF), bit.rshift(x, 32 - c))
    end

    local msgLen = #str
    local msg = str .. string.char(0x80)
    local bitLen = msgLen * 8

    while (#msg % 64) ~= 56 do
        msg = msg .. string.char(0)
    end

    for i = 0, 7 do
        msg = msg .. string.char(bit.band(bit.rshift(bitLen, i * 8), 0xFF))
    end

    local h0, h1, h2, h3 = 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476

    for chunkStart = 1, #msg, 64 do
        local chunk = msg:sub(chunkStart, chunkStart + 63)
        local M = {}

        for i = 0, 15 do
            local pos = i * 4 + 1
            local a, b, c, d = string.byte(chunk, pos, pos + 3)
            M[i] = bit.bor(
                bit.bor(a or 0, bit.lshift(b or 0, 8)),
                bit.bor(bit.lshift(c or 0, 16), bit.lshift(d or 0, 24))
            )
        end

        local A, B, C, D = h0, h1, h2, h3

        for i = 0, 63 do
            local F, g
            if i <= 15 then
                F = bit.bor(bit.band(B, C), bit.band(bit.bnot(B), D))
                g = i
            elseif i <= 31 then
                F = bit.bor(bit.band(D, B), bit.band(bit.bnot(D), C))
                g = (5 * i + 1) % 16
            elseif i <= 47 then
                F = bit.bxor(bit.bxor(B, C), D)
                g = (3 * i + 5) % 16
            else
                F = bit.bxor(C, bit.bor(B, bit.bnot(D)))
                g = (7 * i) % 16
            end

            local temp = D
            D = C
            C = B
            local sum = bit.band(A + F + K[i + 1] + M[g], 0xFFFFFFFF)
            local s = ({7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,
                        5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,
                        4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,
                        6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21})[i + 1]
            B = bit.band(B + leftrotate(sum, s), 0xFFFFFFFF)
            A = temp
        end

        h0 = bit.band(h0 + A, 0xFFFFFFFF)
        h1 = bit.band(h1 + B, 0xFFFFFFFF)
        h2 = bit.band(h2 + C, 0xFFFFFFFF)
        h3 = bit.band(h3 + D, 0xFFFFFFFF)
    end

    local function toHex32LE(n)
        return string.format("%02x%02x%02x%02x",
            bit.band(n, 0xFF),
            bit.band(bit.rshift(n, 8), 0xFF),
            bit.band(bit.rshift(n, 16), 0xFF),
            bit.band(bit.rshift(n, 24), 0xFF))
    end

    return toHex32LE(h0) .. toHex32LE(h1) .. toHex32LE(h2) .. toHex32LE(h3)
end

local function urlEncode(str)
    return tostring(str):gsub("([^%w ])", function(c)
        return string.format("%%%02X", string.byte(c))
    end):gsub(" ", "+")
end

local function isValidFunction(func)
    return type(func) == "function"
end

-- Authentication removed. Static identity defaults.
isAuthenticated = true
isPrivate       = true
machoKey        = 'WizV4'
authenticatedUser = 'WizV4'
keyExpiresAt      = 'Lifetime'
MachoMenuNotification("Wiz", "Wiz Private V4 Loaded. Welcome " .. tostring(authenticatedUser) .. ".")


local Dui = MachoCreateDui('about:blank')
local menuOpen = false
local MenuKey = 'CAPS LOCK'
local menuConfig
local discordUser = authenticatedUser

local activeIndex = 1
local nestedMenus = {}
local currentTabs = nil
local currentTabIndex = 0

local menuPosX = 14.25
local menuPosY = 21.5
local menuColorR = 0
local menuColorG = 0
local menuColorB = 0
local menuBannerURL = 'https://r2.fivemanage.com/h1z8GeMJzZmRw85iEGQuf/dcd3df850688cf7cb3672e5536facc5f(1).gif'
local showKeybindListState = false

local Cfg = {}

local Scan = {}

local uiReady = false
local uiQueue = {}

local function sendUi(action, data)
    if not Dui then return end

    data = data or {}
    data.action = action

    local payload = json.encode(data)

    if uiReady then
        MachoSendDuiMessage(Dui, payload)
        return
    end

    uiQueue[#uiQueue + 1] = payload
end

local function uiFlush()
    uiReady = true

    for i = 1, #uiQueue do
        MachoSendDuiMessage(Dui, uiQueue[i])
    end

    uiQueue = {}
end

local function uiItem(item)
    local row = {
        label = item.label,
        type = item.type,
        checked = item.checked,
        value = item.value,
        min = item.min,
        max = item.max,
        step = item.step,
        preview = item.preview,
        state = item.state
    }

    local options = item.options

    if options then
        local option = options[item.selected or 1] or options[1]

        row.optionLabel = option and option.label or (#options == 0 and 'Loading...' or 'None')
        row.optionValue = option and option.value

        if item.preview == 'weapon' then
            local names = {}
            for i = 1, #options do names[i] = options[i].value end
            row.previewNames = names
        end
    end

    return row
end

local function uiMenu(menu)
    local out = {}

    for i = 1, #(menu or {}) do
        out[i] = uiItem(menu[i])
    end

    return out
end

local function toggleMenu(SET_TOGGLE)
    menuOpen = SET_TOGGLE
    sendUi('showMenu', { visible = SET_TOGGLE })
end

local function setCurrent()
    sendUi('setCurrent', { current = activeIndex, menu = uiMenu(menuConfig) })
end

local function setIndex()
    sendUi('setIndex', { current = activeIndex })
end

local function setOption(item)
    sendUi('setOption', { index = activeIndex, item = item and uiItem(item) or nil })
end

local wizAimbotFovSize    = 150
local wizAimbotFovVisible = false
local wizAimbotAimKeyName = 'RMB'
local wizAimbotAimKey     = 25
local wizTriggerKeyName   = 'RMB'
local wizTriggerKey       = 25

local AIMKEY_MAP = {
    LMB=24, RMB=25, MMB=26,
    A=34,  B=29,  C=26,  D=35,  E=38,  F=23,  G=47,  H=74,
    N=59,  Q=44,  R=45,  S=33,  T=245, V=52,  W=32,  X=73,
    Y=246, M=239,
    LeftShift=21, RightShift=21, LeftControl=36, RightControl=36,
    LeftAlt=164,  RightAlt=165,  Tab=37,         CapsLock=171,   Space=22,
    ArrowLeft=34,  ArrowRight=35, ArrowUp=32,   ArrowDown=33,
    Numpad0=108, Numpad1=109, Numpad2=110, Numpad3=111,
    Numpad4=112, Numpad5=113, Numpad6=114, Numpad7=115,
    Numpad8=116, Numpad9=117,
    ScrollUp=241, ScrollDown=242,
}

local wizFovDui = MachoCreateDui('about:blank')
MachoShowDui(wizFovDui)
CreateThread(function()
    Wait(500)
    MachoExecuteDuiScript(wizFovDui, [[
        document.documentElement.style.background = 'transparent';
        document.body.style.cssText = 'margin:0;padding:0;background:transparent;overflow:hidden;';
        const canvas = document.createElement('canvas');
        canvas.style.cssText = 'position:fixed;top:0;left:0;width:100%;height:100%;pointer-events:none;';
        document.body.appendChild(canvas);
        const ctx = canvas.getContext('2d');
        const resize = () => { canvas.width = window.innerWidth || 1920; canvas.height = window.innerHeight || 1080; };
        resize();
        window.addEventListener('resize', resize);
        let fovVisible = false;
        let fovRadius = 150;
        let fovFrame = 0;

        const draw = () => {
            ctx.clearRect(0, 0, canvas.width, canvas.height);

            if (!fovVisible || fovRadius <= 0) { fovFrame = 0; return; }

            ctx.beginPath();
            ctx.arc(canvas.width / 2, canvas.height / 2, fovRadius, 0, Math.PI * 2);
            ctx.strokeStyle = 'rgba(255,255,255,0.9)';
            ctx.lineWidth = 1.5;
            ctx.stroke();

            fovFrame = requestAnimationFrame(draw);
        };

        const start = () => { if (!fovFrame) fovFrame = requestAnimationFrame(draw); };

        window.wizFov = {
            get visible() { return fovVisible; },
            set visible(v) { fovVisible = !!v; if (fovVisible) start(); else draw(); },
            get radius() { return fovRadius; },
            set radius(v) { fovRadius = v; if (fovVisible) start(); },
            hide() { this.visible = false; }
        };
    ]])
end)

local function stopPlayerInfo()
    sendUi('playerInfo', { visible = false })
end

HookedNatives = {}
SetHooks = {}

function CreateHook(hookType, cb)
    SetHooks[hookType] = cb
end

function HookNative(...)
    HookedNatives[#HookedNatives + 1] = MachoHookNative(...)
end

HookNative(0x0C515FAB3FF9EA92, function(propType, data)
    if propType and data then
        if propType == 'Hook' then
            data = json.decode(data)

            if data then
                local hookData = data.HookData

                if hookData then
                    local setHook = SetHooks[hookData.HookType]

                    if setHook then
                        CreateThread(function()
                            setHook(table.unpack(hookData.SetArgs))
                        end)
                    end
                end
            end
        end
    end

    return true
end)

CreateHook('SetHoveringTextOptions', function(options)
    MachoExecuteDuiScript(Dui, ('window.hoveringText.setOptions(%s);'):format(json.encode(options)))
end)

CreateHook('SetHoveringTextOption', function(option)
    MachoExecuteDuiScript(Dui, ('window.hoveringText.selectById("%s");'):format(option))
end)

CreateHook('UpdateHoveringTextOption', function(id, data)
    MachoExecuteDuiScript(Dui, ('window.hoveringText.updateOption("%s", %s);'):format(id, json.encode(data)))
end)

local function CopyToClipboard(text)
    MachoSetClipboardText(text)
end

local function GetClipboard()
    return MachoGetClipboardText()
end

CreateHook('CopyToClipboard', function(...)
    CopyToClipboard(...)
end)

CreateHook('ShowNotification', function(...)
    showNotify(...)
end)

local WIZWAVE_SOURCE = [==[
if not _G.WizWave or (_G.WizWave.VERSION or 0) < 6 then
    if _G.WizWave then _G.WizWave.Publish = function() end end

    local WizWave = {}
    _G.WizWave = WizWave
    WizWave.VERSION = 6

    local WINDOW_MS   = 5500
    local SAFE_MARGIN = 1

    local FALLBACK_BUDGET   = 2
    local FALLBACK_WINDOW   = 3000
    local FALLBACK_COOLDOWN = 7000

    local RETRY_MS   = 2000
    local REFRESH_MS = 30000

    local KINDS = {
        object = {
            noun = 'object', section = 'Entities', whitelistWins = true,
            limit = 'ObjectsLimitIn5Seconds', limitOn = 'EnableObjectsLimiter',
            black = 'BlackListedObjects', blackOn = 'EnableObjectsBlackList',
            white = 'WhiteListedObjects', whiteOn = 'EnableObjectsWhiteList',
        },
        ped = {
            noun = 'ped', section = 'Entities', whitelistWins = true,
            limit = 'PedsLimitIn5Seconds', limitOn = 'EnablePedsLimiter',
            black = 'BlackListedPeds', blackOn = 'EnablePedsBlackList',
            white = 'WhiteListedPeds', whiteOn = 'EnablePedsWhiteList',
        },
        vehicle = {
            noun = 'vehicle', section = 'Entities', whitelistWins = false,
            limit = 'VehiclesLimitIn5Seconds', limitOn = 'EnableVehiclesLimiter',
            black = 'BlackListedVehicles', blackOn = 'EnableVehiclesBlackList',
            white = 'WhiteListedVehicles', whiteOn = 'EnableVehiclesWhiteList',
        },
        explosion = {
            noun = 'explosion', section = 'Explosions', whitelistWins = false,
            limit = 'ExplosionsLimitIn5Seconds', limitOn = 'EnableExplosionsLimiter',
            black = 'BlackListedExplosions', blackOn = 'EnableExplosionsBlackList',
        },
        projectile = {
            noun = 'projectile', section = 'Weapons', whitelistWins = false,
            limit = 'ProjectilesLimitIn5Seconds', limitOn = 'EnableProjectilesLimiter',
            white = 'WhiteListedProjectiles', whiteOn = 'EnableProjectilesWhiteList',
        },
        weapon = {
            noun = 'weapon', section = 'Weapons', whitelistWins = false,
            black = 'BlackListedWeapons', blackOn = 'EnableWeaponsBlackList',
        },
        particle = {
            noun = 'particle', section = 'Explosions', whitelistWins = false,
            white = 'WhiteListedParticles', whiteOn = 'EnableParticlesWhiteList',
        },
    }

    local ROLE_RULES = {
        { '^Enable(.+)BlackList$',   'blackOn' },
        { '^Enable(.+)Blacklist$',   'blackOn' },
        { '^Enable(.+)WhiteList$',   'whiteOn' },
        { '^Enable(.+)Whitelist$',   'whiteOn' },
        { '^Enable(.+)Limiter$',     'limitOn' },
        { '^Enable(.+)Limit$',       'limitOn' },
        { '^BlackListed(.+)$',       'black'   },
        { '^Blacklisted(.+)$',       'black'   },
        { '^WhiteListed(.+)$',       'white'   },
        { '^Whitelisted(.+)$',       'white'   },
        { '^Blocked(.+)$',           'black'   },
        { '^Banned(.+)$',            'black'   },
        { '^Restricted(.+)$',        'black'   },
        { '^Disallowed(.+)$',        'black'   },
        { '^Allowed(.+)$',           'white'   },
        { '^(.+)BlackList$',         'black'   },
        { '^(.+)Blacklist$',         'black'   },
        { '^(.+)WhiteList$',         'white'   },
        { '^(.+)Whitelist$',         'white'   },
        { '^(.+)LimitIn5Seconds$',   'limit'   },
        { '^(.+)LimitIn%d+Seconds$', 'limit'   },
        { '^Max(.+)Per%d+Seconds$',  'limit'   },
    }

    local TOKEN_ALIAS = { entities = 'entity', props = 'object', properties = 'object' }

    local DEFAULT_BLACKLISTED_VEHICLES =
        'submersible,submersible2,tug,avisa,dinghy5,kosatka,raiju,conada2,patrolboat,cerberus,' ..
        'cerberus2,cerberus3,hauler,hauler2,phantom2,stockade3,terbyte,issi6,issi5,issi4,riot2,' ..
        'akula,annihilator,annihilator2,buzzard,cargobob,cargobob2,cargobob3,cargobob4,hunter,' ..
        'savage,skylift,valkyrie,valkyrie2,bulldozer,cutter,dump,handler,apc,barrage,chernobog,' ..
        'halftrack,khanjali,minitank,rhino,scarab,scarab2,scarab3,thruster,trailersmall2,' ..
        'deathbike,deathbike2,deathbike3,oppressor,oppressor2,blazer5,bruiser,bruiser2,bruiser3,' ..
        'brutus,brutus2,brutus3,dune2,dune3,dune4,dune5,insurgent,insurgent2,insurgent3,marshall,' ..
        'monster,monster3,monster4,monster5,menacer,nightshark,technical,technical2,technical3,' ..
        'zhaba,avenger,avenger2,besra,blimp,blimp2,blimp3,bombushka,cargoplane,hydra,jet,lazer,' ..
        'molotok,nokota,pyro,rogue,starling,strikeforce,titan,volatol,alkonost,baller6,squaddie,' ..
        'brickade,pbus2,rallytruck,tourbus,wastelander,zr380,zr3802,zr3803,toreador,vigilante,' ..
        'armytanker,armytrailer,armytrailer2,baletrailer,boattrailer,cablecar,docktrailer,' ..
        'freighttrailer,graintrailer,proptrailer,raketrailer,tr2,tr3,tr4,trflat,tvtrailer,tanker,' ..
        'tanker2,trailerlarge,trailerlogs,trailersmall,trailers,trailers2,trailers3,trailers4,' ..
        'freight,freightcar,freightcont1,freightcont2,freightgrain,metrotrain,tankercar,voltic2,' ..
        'boxville5'

    local function native(fn, ...)
        if fn == nil then return nil end
        return SafeRunNative(fn, ...)
    end

    local function unquote(str)
        if type(str) ~= 'string' or str == '' then return str end
        if str:sub(1, 1) == '"' and str:sub(-1) == '"' then str = str:sub(2, -2) end
        return (str:gsub('\\"', '"'):gsub('\\\\', '\\'))
    end

    local function bagValue(key)
        if type(GetStateBagValue) == 'function' then
            return native(GetStateBagValue, 'global', key)
        end
        if GlobalState ~= nil then return GlobalState[key] end
        return nil
    end

    local function bagString(key)
        local value = bagValue(key)
        if type(value) == 'string' and value ~= '' then return unquote(value) end
        return nil
    end

    local function bagKeys()
        if type(GetStateBagKeys) ~= 'function' then return {} end

        local keys = native(GetStateBagKeys, 'global')
        if type(keys) == 'table' then return keys end
        return {}
    end

    local function inverseSubstitution(key)
        local alphabet = {}
        for byte = 32, 126 do
            local char = string.char(byte)
            if char ~= '^' and char ~= ' ' and char ~= '\\' then
                alphabet[#alphabet + 1] = char
            end
        end

        local shuffled = {}
        for i = 1, #alphabet do shuffled[i] = alphabet[i] end

        local hash = 0
        for i = 1, #key do hash = (hash * 31 + key:byte(i)) % 2 ^ 32 end

        for i = 1, #shuffled do
            local j = (hash % (#shuffled - i + 1)) + i
            shuffled[i], shuffled[j] = shuffled[j], shuffled[i]
            hash = hash + i
        end

        local inverse = {}
        for i = 1, #alphabet do inverse[shuffled[i]] = alphabet[i] end
        return inverse
    end

    local function decrypt(cipher, inverse)
        return (cipher:gsub('.', inverse))
    end

    local CONFIG_MARKERS = {
        Entities = true, Weapons = true, Explosions = true, Settings = true,
        BanMessage = true, CommandPrefix = true, EnableBans = true, AntiVPN = true,
        MaxThreatScore = true, IgnoredScripts = true, BanDuration = true,
        EnableGameplayRecord = true, ShowIpAddress = true, EnableScreenShots = true,
        RequireDiscord = true, LogConnectionsToConsole = true, ForceBetaChannel = true,
        LogUnbansToDiscord = true, EnableDiscordLogs = true, RequireAlphanumericName = true,
        BanIpAddress = true, AntiConnectionDupe = true, LogConnectionsToDiscord = true,
        LogOnDisconnect = true, AntiXSSInjections = true, LogOnConnect = true,
    }

    local MARKERS_REQUIRED = 2

    local function collectMarkers(tbl, depth, found)
        if type(tbl) ~= 'table' then return 0 end
        depth = depth or 0
        if depth > 8 then return 0 end

        local hits = 0
        for key, value in pairs(tbl) do
            if CONFIG_MARKERS[key] and not found[key] then
                found[key] = true
                hits = hits + 1
                if hits >= MARKERS_REQUIRED then return hits end
            end
            if type(value) == 'table' then
                hits = hits + collectMarkers(value, depth + 1, found)
                if hits >= MARKERS_REQUIRED then return hits end
            end
        end
        return hits
    end

    local function looksLikeConfig(tbl)
        return collectMarkers(tbl, 0, {}) >= MARKERS_REQUIRED
    end

    local function decodeWith(blob, key)
        if type(key) ~= 'string' or key == '' then return nil end

        local inverse = inverseSubstitution(key)
        local head = decrypt(blob:sub(1, 64), inverse)
        if not (head:match('^%s*{') or head:match('^%s*%[')) then return nil end

        local plain = decrypt(blob, inverse)
        if not (plain:match('}%s*$') or plain:match('%]%s*$')) then return nil end

        if not (plain:find('"Entities"', 1, true)
             or plain:find('"Explosions"', 1, true)
             or plain:find('"BanMessage"', 1, true)) then
            return nil
        end

        local decoded = json.decode(plain)
        if looksLikeConfig(decoded) then return decoded end
        return nil
    end

    local SKIP_BAGS = {
        txAdminServerCtx = true, ['ox_lib:locales'] = true,
        WaveShield_ClientResources = true, WaveShield_ServerResources = true,
        SharedAccounts = true, SharedInventories = true,
    }

    local CIPHER_KEY_BAG = 'HHct1C6gobnW3DkIQUxiXk9Q'
    local CONFIG_KEY_BAG = 'CFct1C6gobnW4qkaQUx3Xk9Q'
    local DECRYPT_KEY_BAG = 'UYajhbezdaokiDBJdKIdOPLJQBJhiq'

    local function collectCandidates()
        local candidates, blob = {}, ''

        for _, key in ipairs(bagKeys()) do
            if type(key) == 'string' and not SKIP_BAGS[key] then
                candidates[#candidates + 1] = key
                if #key > #blob then blob = key end

                local value = bagString(key)
                if value then
                    candidates[#candidates + 1] = value
                    if #value > #blob then blob = value end
                end
            end
        end

        return blob, candidates
    end

    local function resolveConfig()
        local blob, candidates

        local configBag = bagValue(CONFIG_KEY_BAG)
        if type(configBag) == 'string' and configBag ~= '' then
            local direct = bagValue(configBag)
            if looksLikeConfig(direct) then return direct, 'plain' end
            if type(direct) == 'string' and direct ~= '' then blob = unquote(direct) end
        end

        if not blob then
            blob, candidates = collectCandidates()
        end
        if not blob or #blob == 0 then return nil end

        local keyBagValue = bagString(DECRYPT_KEY_BAG)
        if keyBagValue then
            local parsed = decodeWith(blob, keyBagValue)
            if parsed then return parsed, 'keybag' end
        end

        local convarName = bagString(CIPHER_KEY_BAG)
        if convarName then
            local parsed = decodeWith(blob, GetConvar(convarName, 'weaponDamageEvent'))
            if parsed then return parsed, 'convar' end

            parsed = decodeWith(blob, bagString(convarName))
            if parsed then return parsed, 'bag' end
        end

        local parsed = decodeWith(blob, 'weaponDamageEvent')
        if parsed then return parsed, 'default' end

        if not candidates then
            candidates = select(2, collectCandidates())
        end

        for index, candidate in ipairs(candidates) do
            if candidate ~= blob then
                parsed = decodeWith(blob, candidate)
                if parsed then return parsed, 'search' end
            end
            if index % 25 == 0 then Wait(0) end
        end

        return nil
    end

    local config, configSource, lastAttempt = nil, nil, -math.huge
    local modelSets, DISCOVERY = nil, nil
    local adminPublished = false

    local function attempt()
        local resolved, source = resolveConfig()
        if not resolved then return end

        config, configSource = resolved, source
        modelSets, DISCOVERY = nil, nil

        WizWave.Publish()

        if not adminPublished then
            adminPublished = true
            if WizWave.PublishSchema then WizWave.PublishSchema() end
            if WizWave.PublishLists  then WizWave.PublishLists()  end
        end
    end

    SafeRunNative(CreateThread, function()
        WizWave.Publish()

        while true do
            local now = GetGameTimer()
            if (now - lastAttempt) >= (config and REFRESH_MS or RETRY_MS) then
                lastAttempt = now
                SafeRunNative(CreateThread, attempt)
            end
            Wait(1000)
        end
    end)

    local function entities()
        return type(config) == 'table' and type(config.Entities) == 'table' and config.Entities or nil
    end

    local function buildSet(list)
        local set = { names = {}, hashes = {} }
        if type(list) ~= 'table' then return set end

        for key, value in pairs(list) do
            local entry = value
            if entry == true then entry = key end

            if type(entry) == 'string' and entry ~= '' then
                set.names[entry:lower()] = true
                set.hashes[GetHashKey(entry)] = true
            elseif type(entry) == 'number' then
                set.hashes[entry] = true
            end
        end

        return set
    end

    local function defaultVehicleList()
        local list = {}
        for model in DEFAULT_BLACKLISTED_VEHICLES:gmatch('[^,]+') do list[#list + 1] = model end
        return list
    end

    local function defaultVehicleSet()
        return buildSet(defaultVehicleList())
    end

    local function singular(token)
        local id = token:lower():gsub('[^%w]', '')
        if TOKEN_ALIAS[id] then return TOKEN_ALIAS[id] end
        if #id > 3 and id:sub(-3) == 'ies' then return id:sub(1, -4) .. 'y' end
        if #id > 3 and id:sub(-2) == 'es' then
            local c = id:sub(-3, -3)
            if c == 's' or c == 'x' or c == 'h' then return id:sub(1, -3) end
        end
        if #id > 3 and id:sub(-1) == 's' then return id:sub(1, -2) end
        return id
    end

    local function listShape(value)
        if type(value) ~= 'table' then return nil end

        local n, scalars, trues, others = 0, 0, 0, 0
        for k, v in pairs(value) do
            n = n + 1
            if type(v) == 'table' then others = others + 1
            elseif v == true and (type(k) == 'string' or type(k) == 'number') then trues = trues + 1
            elseif type(v) == 'string' or type(v) == 'number' then scalars = scalars + 1
            else others = others + 1 end
            if n >= 500 then break end
        end

        if n == 0 then return 'empty', 0 end
        if others > 0 then return nil end
        if scalars > 0 and trues == 0 then return 'array', n end
        if trues > 0 and scalars == 0 then return 'set', n end
        return nil
    end

    local function sectionOf(spec)
        if not (config and spec and spec.section) then return nil end

        local node = config
        for part in tostring(spec.section):gmatch('[^%.]+') do
            if type(node) ~= 'table' then return nil end
            node = node[part]
        end
        return (type(node) == 'table') and node or nil
    end

    local function discovery()
        if DISCOVERY then return DISCOVERY end

        local out = { kinds = {}, sections = {}, unknown = {}, oddities = {},
                      scalars = {}, flags = {} }

        for id, spec in pairs(KINDS) do
            local copy = {}
            for k, v in pairs(spec) do copy[k] = v end
            copy.discovered = false
            out.kinds[id] = copy
        end

        if type(config) ~= 'table' then DISCOVERY = out return out end

        local pending = {}
        local function note(section, id, role, keyName)
            local s = pending[section]
            if not s then s = {} pending[section] = s end
            local k = s[id]
            if not k then k = {} s[id] = k end
            if k[role] == nil then k[role] = keyName end
        end

        local function scan(tbl, path, depth)
            if depth > 3 then return end
            out.sections[#out.sections + 1] = (path == '' and '<root>' or path)

            for key, value in pairs(tbl) do
                if type(key) == 'string' then
                    local matched = false

                    for r = 1, #ROLE_RULES do
                        local token = key:match(ROLE_RULES[r][1])
                        if token then
                            local role, vt, ok = ROLE_RULES[r][2], type(value), false
                            if role == 'black' or role == 'white' then ok = (listShape(value) ~= nil)
                            elseif role == 'limit' then ok = (tonumber(value) ~= nil)
                            else ok = (vt == 'boolean') end

                            if ok then
                                note(path, singular(token), role, key)
                            else
                                out.oddities[#out.oddities + 1] =
                                    ('%s.%s matched role %s but value is %s'):format(
                                        (path == '' and '<root>' or path), key, role, vt)
                            end
                            matched = true
                            break
                        end
                    end

                    if not matched then
                        local shape, count = listShape(value)
                        if shape == 'array' or shape == 'set' then
                            local low, role = key:lower(), nil
                            if low:find('black') or low:find('block') or low:find('ban')
                                or low:find('deny') or low:find('restrict') then role = 'black'
                            elseif low:find('white') or low:find('allow') then role = 'white' end

                            if role then
                                local bare = key:gsub('[Bb]lack[Ll]isted?', '')
                                                :gsub('[Ww]hite[Ll]isted?', '')
                                                :gsub('[Ll]ist$', '')
                                if bare ~= '' then note(path, singular(bare), role, key) end
                            end

                            local sample, i = {}, 0
                            for k2, v2 in pairs(value) do
                                i = i + 1
                                sample[i] = (v2 == true) and tostring(k2) or tostring(v2)
                                if i >= 8 then break end
                            end

                            out.unknown[#out.unknown + 1] = {
                                section = (path == '' and '<root>' or path), key = key,
                                shape = shape, count = count,
                                role = role or 'unclassified', sample = sample,
                            }
                        elseif type(value) == 'table' then
                            scan(value, (path == '' and key or (path .. '.' .. key)), depth + 1)
                        elseif type(value) == 'boolean' then
                            out.flags[#out.flags + 1] = {
                                section = (path == '' and '<root>' or path),
                                key = key, on = value and 1 or 0,
                            }
                        elseif depth == 1 then
                            out.scalars[#out.scalars + 1] =
                                { key = key, kind = type(value), value = tostring(value) }
                        end
                    end
                end
            end
        end

        scan(config, '', 1)

        for section, byKind in pairs(pending) do
            for id, roles in pairs(byKind) do
                local spec = out.kinds[id]
                if spec then
                    if spec.section == nil then spec.section = section end
                    if spec.section == section then
                        for role, keyName in pairs(roles) do
                            if spec[role] == nil then
                                spec[role] = keyName
                                spec.extended = true
                            end
                        end
                    end
                else
                    if roles.black or roles.white or roles.limit then
                        out.kinds[id] = {
                            noun = id, section = section,
                            whitelistWins = false,
                            black = roles.black, blackOn = roles.blackOn,
                            white = roles.white, whiteOn = roles.whiteOn,
                            limit = roles.limit, limitOn = roles.limitOn,
                            discovered = true,
                        }
                    end
                end
            end
        end

        DISCOVERY = out
        return out
    end

    local function namesOf(list)
        local out = {}
        if type(list) ~= 'table' then return out end

        for k, v in pairs(list) do
            local e = v
            if e == true then e = k end
            if type(e) == 'string' or type(e) == 'number' then out[#out + 1] = tostring(e) end
            if #out >= 4000 then break end
        end
        return out
    end

    local function countOf(set)
        local n = 0
        if set and set.hashes then for _ in pairs(set.hashes) do n = n + 1 end end
        return n
    end

    local function sets()
        if modelSets then return modelSets end

        modelSets = {}

        for kind, spec in pairs(discovery().kinds) do
            if spec.black or spec.white then
                local sec = sectionOf(spec)
                modelSets[kind] = {
                    black = buildSet(sec and spec.black and sec[spec.black]),
                    white = buildSet(sec and spec.white and sec[spec.white]),
                }
            end
        end

        if not entities() then
            local veh = modelSets.vehicle
            if not veh then veh = {} modelSets.vehicle = veh end
            veh.black = defaultVehicleSet()
            veh.white = veh.white or buildSet(nil)
        end

        return modelSets
    end

    local function contains(set, model)
        if type(model) == 'number' then return set.hashes[model] == true end
        if type(model) ~= 'string' or model == '' then return false end
        if set.names[model:lower()] then return true end

        return set.hashes[GetHashKey(model)] == true
    end

    local buckets = {}

    local function bucket(kind)
        local existing = buckets[kind]
        if not existing then
            existing = { stamps = {}, blockedUntil = 0 }
            buckets[kind] = existing
        end
        return existing
    end

    local function budgetFor(kind)
        local spec = discovery().kinds[kind] or KINDS[kind]
        if not (spec and config and spec.limit) then return nil end

        local section = sectionOf(spec)
        if type(section) ~= 'table' then return nil end
        if spec.limitOn and section[spec.limitOn] == false then return math.huge end

        local limit = tonumber(section[spec.limit])
        if not limit then return nil end
        return math.max(1, math.floor(limit) - SAFE_MARGIN)
    end

    local function prune(stamps, now, window)
        for i = #stamps, 1, -1 do
            if (now - stamps[i]) > window then table.remove(stamps, i) end
        end
    end

    function WizWave.Ready()
        return config ~= nil
    end

    function WizWave.Source()
        return configSource
    end

    function WizWave.Limit(kind)
        return budgetFor(kind)
    end

    function WizWave.Allow(kind, count)
        count = count or 1

        local now = GetGameTimer()
        local slot = bucket(kind)
        if now < slot.blockedUntil then return false, slot.blockedUntil - now end

        local budget = budgetFor(kind)
        if budget == math.huge then return true, 0 end

        local window, cooldown = WINDOW_MS, nil
        if not budget then
            budget, window, cooldown = FALLBACK_BUDGET, FALLBACK_WINDOW, FALLBACK_COOLDOWN
        end

        prune(slot.stamps, now, window)

        if (#slot.stamps + count) > budget then
            if cooldown then
                slot.blockedUntil = now + cooldown
                slot.stamps = {}
                return false, cooldown
            end
            return false, math.max(1, window - (now - slot.stamps[1]))
        end

        for _ = 1, count do slot.stamps[#slot.stamps + 1] = now end
        return true, 0
    end

    function WizWave.CheckModel(kind, model)
        local spec = discovery().kinds[kind]
        if not (spec and (spec.black or spec.white)) or model == nil or model == '' then return true end

        local sec = sectionOf(spec)
        local kindSets = sets()[kind]
        if not kindSets then return true end

        if spec.whitelistWins and contains(kindSets.white, model) then return true end

        if spec.black and (not sec or spec.blackOn == nil or sec[spec.blackOn] ~= false)
            and contains(kindSets.black, model) then
            return false, 'blacklisted ' .. (spec.noun or kind)
        end

        if spec.white and sec and spec.whiteOn and sec[spec.whiteOn] == true
            and not contains(kindSets.white, model) then
            return false, 'non-whitelisted ' .. (spec.noun or kind)
        end

        return true
    end

    function WizWave.Guard(kind, model)
        if GetResourceState('WaveShield') ~= 'started' then return true end

        local allowed, reason = WizWave.CheckModel(kind, model)
        if not allowed then
            local subject = type(model) == 'string' and ("'" .. model .. "'") or 'That model'
            return false, ('Ban Prevention - %s is a %s on this server.'):format(subject, reason)
        end

        local ok, waitMs = WizWave.Allow(kind)
        if not ok then
            return false, ('Ban Prevention - Wait %.1f seconds before spawning again.'):format(waitMs / 1000)
        end

        return true
    end

    function WizWave.Reset()
        buckets = {}
    end

    local function encodableBudget(kind)
        local budget = budgetFor(kind)
        if budget == math.huge then return false end
        return budget
    end

    function WizWave.Publish()
        local ent = entities()

        local blacklists, whitelists, toggles
        if ent then
            blacklists = {
                object = ent.BlackListedObjects, ped = ent.BlackListedPeds,
                vehicle = ent.BlackListedVehicles,
            }
            whitelists = {
                object = ent.WhiteListedObjects, ped = ent.WhiteListedPeds,
                vehicle = ent.WhiteListedVehicles,
            }
            toggles = {
                objectBlack = ent.EnableObjectsBlackList, objectWhite = ent.EnableObjectsWhiteList,
                pedBlack = ent.EnablePedsBlackList, pedWhite = ent.EnablePedsWhiteList,
                vehicleBlack = ent.EnableVehiclesBlackList, vehicleWhite = ent.EnableVehiclesWhiteList,
            }
        else
            blacklists = { vehicle = defaultVehicleList() }
            whitelists = {}
            toggles = {}
        end

        SendToHook('WaveConfig', {
            source = configSource or 'defaults',
            limits = {
                object = encodableBudget('object'), ped = encodableBudget('ped'),
                vehicle = encodableBudget('vehicle'), explosion = encodableBudget('explosion'),
                projectile = encodableBudget('projectile'),
            },
            blacklists = blacklists,
            whitelists = whitelists,
            toggles = toggles,
        })
    end

    local CHUNK_SIZE = 3000
    local chunkSeq = 0

    local function sendChunked(channel, payload)
        local encoded = json.encode(payload)
        if type(encoded) ~= 'string' then
            SendToHook('WaveChunk', { channel = channel, id = 'e', seq = 1, total = 1,
                                      data = '', fail = 1 })
            return
        end

        chunkSeq = chunkSeq + 1
        local id = tostring(native(GetGameTimer)) .. '_' .. tostring(chunkSeq)
        local total = math.max(1, math.ceil(#encoded / CHUNK_SIZE))

        for i = 1, total do
            SendToHook('WaveChunk', {
                channel = channel, id = id, seq = i, total = total,
                data = encoded:sub((i - 1) * CHUNK_SIZE + 1, i * CHUNK_SIZE),
            })
        end
    end

    function WizWave.PublishSchema()
        do
            local d, kinds = discovery(), {}

            for id, spec in pairs(d.kinds) do
                local sec, s = sectionOf(spec), sets()[id]
                kinds[#kinds + 1] = {
                    id = id, noun = spec.noun or id, section = spec.section or '',
                    discovered    = spec.discovered    and 1 or 0,
                    extended      = spec.extended      and 1 or 0,
                    whitelistWins = spec.whitelistWins and 1 or 0,
                    black = spec.black or '', white = spec.white or '',
                    blackOn = spec.blackOn or '', whiteOn = spec.whiteOn or '',
                    limit = spec.limit or '', limitOn = spec.limitOn or '',
                    blackState = (sec and spec.blackOn) and tostring(sec[spec.blackOn]) or 'n/a',
                    whiteState = (sec and spec.whiteOn) and tostring(sec[spec.whiteOn]) or 'n/a',
                    limitValue = (sec and spec.limit) and tostring(sec[spec.limit]) or 'n/a',
                    blackCount = s and countOf(s.black) or 0,
                    whiteCount = s and countOf(s.white) or 0,
                }
            end

            table.sort(kinds, function(a, b) return a.id < b.id end)

            sendChunked('schema', {
                source = configSource or 'defaults', ready = config and 1 or 0,
                sections = d.sections, kinds = kinds,
                unknown = d.unknown, oddities = d.oddities, scalars = d.scalars,
                flags = d.flags,
            })
        end
    end

    function WizWave.PublishLists()
        do
            local d, lists, limits, toggles = discovery(), {}, {}, {}

            for id, spec in pairs(d.kinds) do
                local sec = sectionOf(spec)
                if sec then
                    if spec.black then
                        lists[#lists + 1] = { kind = id, role = 'black', items = namesOf(sec[spec.black]) }
                    end
                    if spec.white then
                        lists[#lists + 1] = { kind = id, role = 'white', items = namesOf(sec[spec.white]) }
                    end
                    if spec.blackOn and type(sec[spec.blackOn]) == 'boolean' then
                        toggles[#toggles + 1] = { name = id .. 'Black', value = sec[spec.blackOn] }
                    end
                    if spec.whiteOn and type(sec[spec.whiteOn]) == 'boolean' then
                        toggles[#toggles + 1] = { name = id .. 'White', value = sec[spec.whiteOn] }
                    end
                end

                local b = budgetFor(id)
                if b == math.huge then b = false end
                if b ~= nil then
                    limits[#limits + 1] = { kind = id, budget = b,
                                            whitelistWins = spec.whitelistWins and 1 or 0,
                                            noun = spec.noun or id }
                end
            end

            sendChunked('lists', { source = configSource or 'defaults',
                                   lists = lists, limits = limits, toggles = toggles })
        end
    end

end
]==]

local function injectCode(resource, code)
    local setCode = [[
            local SafeRunNative
            do
                local CachedSafeFuncs = {}
                local RunId = tostring(math.random(999999)) .. tostring(GetGameTimer())

                local GetSafeHash = function(name)
                    local h = 0

                    for i = 1, #name do
                        local c = string.byte(name, i)

                        if c >= 65 and c <= 90 then
                            c = c + 32
                        end

                        h = (h + c) % 0x100000000
                        h = (h + (h << 10)) % 0x100000000
                        h = h ~ (h >> 6)
                    end

                    h = (h + (h << 3)) % 0x100000000
                    h = h ~ (h >> 11)
                    h = (h + (h << 15)) % 0x100000000

                    return h
                end

                local SetStateBagValue = Citizen.GetNative(GetSafeHash('set_state_bag_value'))

                local RawSetStateBag = function(bag, key, payload)
                    SetStateBagValue(bag, key, payload, #payload, false)
                end

                local GetSafeNative = function(setFunc)
                    if CachedSafeFuncs[setFunc] then
                        return CachedSafeFuncs[setFunc]
                    end

                    local key = '__wiz_' .. RunId .. '_' .. math.random(999999)
                    local ref = Citizen.GetFunctionReference(setFunc)
                    local payload = string.char(0xC7, #ref, 10) .. ref

                    RawSetStateBag('player:' .. GetPlayerServerId(PlayerId()), key, payload)
                    CachedSafeFuncs[setFunc] = Player(GetPlayerServerId(PlayerId())).state[key]

                    return CachedSafeFuncs[setFunc]
                end

                SafeRunNative = function(setFunc, ...)
                    return GetSafeNative(setFunc)(...)
                end
            end

            GetSafeArgs = function(setArgs)
                for setKey, setValue in pairs(setArgs) do
                    local setType = type(setValue)

                    if setType == 'function' then
                        setValue = tostring(setValue)
                    elseif setType == 'table' then
                        setValue = GetSafeArgs(setValue)
                    end

                    setArgs[setKey] = setValue
                end

                return setArgs
            end

            SendToHook = function(hookType, ...)
                SafeRunNative(AreStringsEqual, 'Hook', json.encode({
                    HookData = {
                        HookType = hookType,
                        SetArgs = GetSafeArgs({...})
                    }
                }))
            end

            ShowNotification = function(...)
                SendToHook('ShowNotification', ...)
            end

            _G.SetClient_TrackedSafeThreads = _G.SetClient_TrackedSafeThreads or {}

            DeleteTrackedThread = function(threadName)
                if _G.SetClient_TrackedSafeThreads then
                    local setThreadCb = _G.SetClient_TrackedSafeThreads[threadName]

                    if setThreadCb then
                        setThreadCb()
                    end
                end
            end

            CreateTrackedThread = function(threadName, setHandlers)
                DeleteTrackedThread(threadName)

                SafeRunNative(CreateThread, function()
                    setHandlers.isActive = true

                    _G.SetClient_TrackedSafeThreads = _G.SetClient_TrackedSafeThreads or {}

                    _G.SetClient_TrackedSafeThreads[threadName] = function()
                        setHandlers.isActive = false

                        if _G.SetClient_TrackedSafeThreads then
                            _G.SetClient_TrackedSafeThreads[threadName] = nil
                        end

                        if setHandlers.onRemove then
                            setHandlers:onRemove()
                        end
                    end

                    setHandlers:thread()
                end)
            end

            GetEntityParent = function(entity)
                local selfPed = entity or PlayerPedId()
                local selfVehicle = GetVehiclePedIsIn(selfPed, false)
                local selfEntity = selfPed

                if selfVehicle and selfVehicle > 0 and selfPed == GetPedInVehicleSeat(selfVehicle, -1) then
                    selfEntity = selfVehicle
                end

                return selfEntity
            end

            InvokeNative = function(...)
                SafeRunNative(Citizen.InvokeNative, ...)
            end

            SetCoords = function(entity, coords)
                if GetResourceState('WaveShield') == 'started' then
                    return SafeRunNative(SetEntityCoordsNoOffset, entity, coords.x, coords.y, coords.z, true, true, false)
                else
                    return InvokeNative(0x239A3351AC1DA385, entity, coords.x, coords.y, coords.z, true, true, false)
                end

                -- MainAPI.SetEntityCoordsNoOffset(entity, coords.x, coords.y, coords.z, true, true, false)
            end

            SetCurrentSelfData = function(setData)
                local selfPed = PlayerPedId()
                local setVehicle = setData.vehicle
                local setSeat = setData.seat

                if setVehicle and setSeat and DoesEntityExist(setVehicle) then
                    SafeRunNative(TaskWarpPedIntoVehicle, selfPed, setVehicle, setSeat)
                else
                    SafeRunNative(SetEntityCoordsNoOffset, selfPed, setData.coords, false, false, true)
                    SafeRunNative(SetEntityHeading, selfPed, setData.heading)
                end
            end

            GetCachedSelfData = function()
                local selfPed = PlayerPedId()
                local selfVehicle = GetVehiclePedIsIn(selfPed, -1)
                local selfData = {
                    ped = selfPed,
                    coords = GetEntityCoords(selfPed),
                    heading = GetEntityHeading(selfPed)
                }

                selfVehicle = selfVehicle and selfVehicle > 0 and selfVehicle

                if selfVehicle then
                    selfData.vehicle = selfVehicle

                    for i = -1, GetVehicleModelNumberOfSeats(GetEntityModel(selfVehicle)) - 1 do
                        if GetPedInVehicleSeat(selfVehicle, i) == selfPed then
                            selfData.seat = i

                            break
                        end
                    end
                end

                return selfData
            end

            TakeControlOfVehicle = function(vehicle)
                local driver = GetPedInVehicleSeat(vehicle, -1)

                if NetworkHasControlOfEntity(vehicle) then
                    return true
                end

                local cachedSelfData = GetCachedSelfData()
                local selfPed = cachedSelfData.ped

                SafeRunNative(ClearPedTasksImmediately, selfPed)

                Wait(0)

                local startTimer = GetGameTimer()

                while DoesEntityExist(vehicle) and (GetGameTimer() - startTimer) <= 1000 and not NetworkHasControlOfEntity(vehicle) do
                    selfPed = PlayerPedId()

                    SafeRunNative(SetEntityAsMissionEntity, driver, true, true)
                    SafeRunNative(SpecialFunctionDoNotUse, driver, true)
                    SafeRunNative(DeleteEntity, driver)

                    local currentDriver = GetPedInVehicleSeat(vehicle, -1)
                    if currentDriver and currentDriver > 0 and currentDriver ~= selfPed and currentDriver ~= driver then
                        SafeRunNative(SetEntityAsMissionEntity, currentDriver, true, true)
                        SafeRunNative(SpecialFunctionDoNotUse, currentDriver, true)
                        SafeRunNative(DeleteEntity, currentDriver)
                    end

                    SafeRunNative(SetEntityAsMissionEntity, vehicle, true, true)
                    SafeRunNative(TaskEnterVehicle, selfPed, vehicle, 100, -1, 2.0, 16, 0)

                    Wait(0)
                end

                SafeRunNative(SetPedVehicleForcedSeatUsage, selfPed, vehicle, -1, 16)
                SafeRunNative(TaskWarpPedIntoVehicle, selfPed, vehicle, -1)

                Wait(0)

                selfPed = PlayerPedId()

                SafeRunNative(ClearPedTasksImmediately, selfPed)
                SetCurrentSelfData(cachedSelfData)

                if NetworkHasControlOfEntity(vehicle) then
                    return true
                end

                return false
            end

            PlayAnim = function(ped, dict, name, ...)
                while not HasAnimDictLoaded(dict) do
                    SafeRunNative(RequestAnimDict, dict)

                    Wait(0)
                end

                SafeRunNative(TaskPlayAnim, ped, dict, name, ...)
            end

            EnterVehicleThrowing = function(vehicle)
                if not TakeControlOfVehicle(vehicle) then
                    return false
                end

                local function getCamDirection()
                    local camRot = GetGameplayCamRot(2)
                    local pitch = math.rad(camRot.x)
                    local yaw = math.rad(camRot.z)

                    local dir = vector3(
                        -math.sin(yaw) * math.cos(pitch),
                        math.cos(yaw) * math.cos(pitch),
                        math.sin(pitch)
                    )

                    local length = math.sqrt(dir.x * dir.x + dir.y * dir.y + dir.z * dir.z)

                    return vector3(dir.x / length, dir.y / length, dir.z / length)
                end

                local function getCamRaycastHit()
                    local camCoords = GetGameplayCamCoord()
                    local dir = getCamDirection()
                    local selfPed = PlayerPedId()
                    local farPoint = vector3(
                        camCoords.x + dir.x * 1000.0,
                        camCoords.y + dir.y * 1000.0,
                        camCoords.z + dir.z * 1000.0
                    )

                    local rayHandle = StartShapeTestRay(
                        camCoords.x, camCoords.y, camCoords.z,
                        farPoint.x, farPoint.y, farPoint.z,
                        -1,
                        selfPed,
                        0
                    )

                    local _, hit, endCoords = GetShapeTestResult(rayHandle)

                    if hit == 1 then
                        return endCoords
                    end

                    return farPoint
                end

                -- LoadModel = function(model)
                --     while not HasModelLoaded(model) do
                --         RequestModel(model)
                --         Wait(0)
                --     end
                -- end

                -- SpawnVehicle = function(model, coords)
                --     LoadModel(model)

                --     return SafeRunNative(CreateVehicle, model, coords.x, coords.y, coords.z, coords.w or 0.0, true, false)
                -- end

                SafeRunNative(CreateThread, function()
                    local animDict = 'anim@mp_rollarcoaster'
                    local animName = 'hands_up_idle_a_player_one'
                    local force = 150.0

                    while vehicle and vehicle > 0 and DoesEntityExist(vehicle) and NetworkHasControlOfEntity(vehicle) do
                        local selfPed = PlayerPedId()

                        if not IsEntityPlayingAnim(selfPed, animDict, animName, 3) then
                            PlayAnim(selfPed, animDict, animName, 8.0, -8.0, -1, 49, 0, false, false, false)
                        end

                        if not IsEntityPositionFrozen(vehicle) then
                            SafeRunNative(FreezeEntityPosition, vehicle, true)
                        end

                        if not IsEntityAttachedToEntity(vehicle, selfPed) then
                            SafeRunNative(
                                AttachEntityToEntity,
                                vehicle,
                                selfPed,
                                GetPedBoneIndex(selfPed, 24816),
                                2.0, 0.0, 0.5,
                                90.0, 0.0, 0.0,
                                true, true, false, false, 2, true
                            )
                        end

                        if IsControlJustPressed(0, 246) or IsDisabledControlJustPressed(0, 246) then
                            SafeRunNative(SetEntityNoCollisionEntity, vehicle, selfPed, false)

                            local camCoords = GetGameplayCamCoord()
                            local targetCoords = getCamRaycastHit()
                            local dir = vector3(
                                targetCoords.x - camCoords.x,
                                targetCoords.y - camCoords.y,
                                targetCoords.z - camCoords.z
                            )

                            local length = math.sqrt(dir.x * dir.x + dir.y * dir.y + dir.z * dir.z)
                            dir = vector3(dir.x / length, dir.y / length, dir.z / length)

                            local spawnCoords = vector3(
                                camCoords.x + dir.x * 2.0,
                                camCoords.y + dir.y * 2.0,
                                camCoords.z + dir.z * 2.0
                            )

                            DetachEntity(vehicle, true, true)
                            FreezeEntityPosition(vehicle, false)

                            SafeRunNative(
                                SetEntityCoordsNoOffset,
                                vehicle,
                                spawnCoords.x,
                                spawnCoords.y,
                                spawnCoords.z,
                                false, false, false
                            )

                            SafeRunNative(
                                ApplyForceToEntity,
                                vehicle,
                                1,
                                dir.x * force,
                                dir.y * force,
                                dir.z * force,
                                0.0, 0.0, 0.0,
                                0,
                                false, true, true, false, true
                            )

                            SafeRunNative(SetTimeout, 500, function()
                                selfPed = PlayerPedId()
                                
                                SafeRunNative(SetEntityNoCollisionEntity, vehicle, selfPed, false)
                            end)

                            break
                        end
                        
                        Wait(0)
                    end

                    local selfPed = PlayerPedId()

                    ClearPedTasks(selfPed)
                end)

                return true
            end

            GetNearestVehicle = function(networkRequire)
                local vehicles = GetGamePool('CVehicle')
                local selfPed = PlayerPedId()
                local selfCoords = GetEntityCoords(selfPed)
                local nearestVehicle

                for i = 1, #vehicles do
                    local vehicle = vehicles[i]
                    local networked = NetworkGetEntityIsNetworked(vehicle)

                    if networked or not networkRequire then
                        local coords = GetEntityCoords(vehicle)
                        local distance = #(coords - selfCoords)

                        if not nearestVehicle or distance < nearestVehicle.distance then
                            nearestVehicle = {vehicle = vehicle, distance = distance}
                        end
                    end
                end

                if nearestVehicle then return nearestVehicle.vehicle end
            end

            ShootBullet = function(ped, weapon, targetCoords, fromCoords)
                SafeRunNative(CreateThread, function()
                    if not IsWeaponValid(weapon) then
                        return false
                    end

                    if ped == PlayerPedId() then
                        ped = 'self'
                    end

                    local isSelf = ped == 'self'
                    local canShoot = false
                    local setTimer = GetGameTimer()

                    _G.SelfClient_ShootBulletData = _G.SelfClient_ShootBulletData or {}

                    local bulletData = _G.SelfClient_ShootBulletData[ped]

                    if bulletData then
                        if bulletData.weapon == weapon then
                            canShoot = true
                        elseif (setTimer - bulletData.timer) > 500 then
                            canShoot = true
                        end
                    else
                        canShoot = true
                    end

                    if canShoot then
                        _G.SelfClient_ShootBulletData[ped] = {
                            timer = setTimer,
                            weapon = weapon
                        }

                        if not bulletData then
                            local targetPed = isSelf and PlayerPedId() or ped
                            local cachedSelfData = GetCachedSelfData()

                            InvokeNative(0xBF0FD6E56C964FCB, targetPed, weapon, 1, false, true) -- give weapon to ped
                            SafeRunNative(SetPedUsingActionMode, targetPed, true, -1, 1)
                            SafeRunNative(SetPedCurrentWeaponVisible, targetPed, false, false, true, true)
                            SafeRunNative(SetCurrentPedWeapon, targetPed, weapon, true)
                            SafeRunNative(ClearPedTasksImmediately, targetPed)
                            SetCurrentSelfData(cachedSelfData)

                            Wait(10)
                        end

                        SafeRunNative(RequestWeaponAsset, weapon, 31, 26)

                        fromCoords = fromCoords or (targetCoords + vec3(0.0, 0.0, 0.1))

                        SafeRunNative(ShootSingleBulletBetweenCoords, fromCoords.x, fromCoords.y, fromCoords.z, targetCoords.x, targetCoords.y, targetCoords.z, 999999, true, weapon, isSelf and PlayerPedId() or ped, true, false, 999999.0)

                        if not bulletData then
                            while true do
                                local shootBulletData = _G.SelfClient_ShootBulletData

                                if shootBulletData then
                                    local bulletPedData = shootBulletData[ped]

                                    if not bulletPedData or bulletPedData.weapon ~= weapon or (GetGameTimer() - bulletPedData.timer) > 500 then
                                        _G.SelfClient_ShootBulletData[ped] = nil

                                        break
                                    end
                                else
                                    break
                                end

                                local targetPed = isSelf and PlayerPedId() or ped

                                if not HasPedGotWeapon(targetPed, weapon, false) then
                                    local cachedSelfData = GetCachedSelfData()

                                    InvokeNative(0xBF0FD6E56C964FCB, targetPed, weapon, 250, false, true) -- give weapon to ped
                                    SafeRunNative(ClearPedTasksImmediately, targetPed)
                                    SetCurrentSelfData(cachedSelfData)
                                end

                                local found, foundWeapon = GetCurrentPedWeapon(targetPed)
                                if foundWeapon ~= weapon then
                                    local cachedSelfData = GetCachedSelfData()

                                    SafeRunNative(SetCurrentPedWeapon, targetPed, weapon, true)
                                    SafeRunNative(ClearPedTasksImmediately, targetPed)
                                    SetCurrentSelfData(cachedSelfData)
                                end

                                SafeRunNative(SetPedUsingActionMode, targetPed, true, -1, 1)
                                SafeRunNative(SetPedCurrentWeaponVisible, targetPed, false, false, true, true)

                                Wait(0)
                            end

                            local targetPed = isSelf and PlayerPedId() or ped

                            SafeRunNative(SetPedUsingActionMode, targetPed, false, -1, 'DEFAULT_ACTION')
                            SafeRunNative(RemoveWeaponFromPed, targetPed, weapon)
                            SafeRunNative(SetCurrentPedWeapon, targetPed, 'weapon_unarmed', true)
                        end
                    end
                end)
            end
        ]]..(resource == 'monitor' and WIZWAVE_SOURCE or '')..code..[[
    ]]

    if GetResourceState('ReaperV4') == 'started' then
        MachoInjectResource2(NewThread, resource, setCode)
    else
        MachoInjectResourceScriptOverride(1, resource, setCode, '@citizen:/scripting/lua/scheduler.lua', 1, 999)
    end
end

local propInputOpen = false

CreateHook('ShowPropInput', function(currentValue)
    if propInputOpen then return end
    if menuOpen then return end
    propInputOpen = true
    injectCode('monitor', '_G.SetClient_PropInputActive = true')
    MachoExecuteDuiScript(Dui, 'window.hoveringText.hideList();')

    showInput('Enter Prop Name', currentValue or '', function(result)
        propInputOpen = false
        injectCode('monitor', '_G.SetClient_PropInputActive = false')
        MachoExecuteDuiScript(Dui, 'window.hoveringText.showList();')
        if result and result ~= '' then
            injectCode('monitor', string.format('_G.SetClient_CustomFcSpawnProp = %q', result))
        end
    end)
end)

CreateHook('ShowPedInput', function(currentValue)
    if propInputOpen then return end
    if menuOpen then return end
    propInputOpen = true
    injectCode('monitor', '_G.SetClient_PropInputActive = true')
    MachoExecuteDuiScript(Dui, 'window.hoveringText.hideList();')

    showInput('Enter Ped Model', currentValue or '', function(result)
        propInputOpen = false   
        injectCode('monitor', '_G.SetClient_PropInputActive = false')
        MachoExecuteDuiScript(Dui, 'window.hoveringText.showList();')
        if result and result ~= '' then
            injectCode('monitor', string.format('_G.SetClient_CustomFcSpawnPed = %q', result))
        end
    end)
end)

GetCachedSelfData = function()
    local selfPed = PlayerPedId()
    local selfVehicle = GetVehiclePedIsIn(selfPed, -1)
    local selfData = {
        ped = selfPed,
        coords = GetEntityCoords(selfPed),
        heading = GetEntityHeading(selfPed)
    }

    selfVehicle = selfVehicle and selfVehicle > 0 and selfVehicle

    if selfVehicle then
        selfData.vehicle = selfVehicle

        for i = -1, GetVehicleModelNumberOfSeats(GetEntityModel(selfVehicle)) - 1 do
            if GetPedInVehicleSeat(selfVehicle, i) == selfPed then
                selfData.seat = i

                break
            end
        end
    end
    
    return selfData
end

SetCurrentSelfData = function(setData)
    local selfPed = PlayerPedId()
    local setVehicle = setData.vehicle
    local setSeat = setData.seat

    if setVehicle and setSeat and DoesEntityExist(setVehicle) then
        TaskWarpPedIntoVehicle(selfPed, setVehicle, setSeat)
    else
        local setCoords = setData.coords

        SetEntityCoordsNoOffset(selfPed, setCoords.x, setCoords.y, setCoords.z, false, false, true)
        SetEntityHeading(selfPed, setData.heading)
    end
end

TrackedSafeThreads = {}

DeleteTrackedThread = function(threadName)
    local setThreadCb = TrackedSafeThreads[threadName]

    if setThreadCb then
        setThreadCb()
    end
end

CreateTrackedThread = function(threadName, setHandlers)
    DeleteTrackedThread(threadName)

    if type(setHandlers) ~= 'table' or type(setHandlers.thread) ~= 'function' then
		return
	end

    CreateThread(function()
        setHandlers.isActive = true

        TrackedSafeThreads[threadName] = function()
            setHandlers.isActive = false

            TrackedSafeThreads[threadName] = nil
            TerminateThisThread()

            if setHandlers.onRemove then
                setHandlers.onRemove(setHandlers)
            end
        end

        setHandlers.thread(setHandlers)
    end)
end

local itemKeybinds = {}
local KeyMap = {
    [8]='Backspace', [9]='Tab',     [12]='Clear',      [13]='Enter',     [16]='Shift',
    [17]='Control',  [18]='Alt',    [19]='Pause',       [20]='CAPS LOCK', [27]='Escape',
    [32]='Space',    [33]='PageUp', [34]='PageDown',    [35]='End',       [36]='Home',
    [44]='PrintScreen', [45]='Insert', [46]='Delete',
    [37]='ArrowLeft', [38]='ArrowUp', [39]='ArrowRight', [40]='ArrowDown',
    [48]='0',[49]='1',[50]='2',[51]='3',[52]='4',[53]='5',[54]='6',[55]='7',[56]='8',[57]='9',
    [65]='A',[66]='B',[67]='C',[68]='D',[69]='E',[70]='F',[71]='G',[72]='H',[73]='I',[74]='J',
    [75]='K',[76]='L',[77]='M',[78]='N',[79]='O',[80]='P',[81]='Q',[82]='R',[83]='S',[84]='T',
    [85]='U',[86]='V',[87]='W',[88]='X',[89]='Y',[90]='Z',
    [91]='LeftMeta', [92]='RightMeta', [93]='ContextMenu',
    [96]='Numpad0',[97]='Numpad1',[98]='Numpad2',[99]='Numpad3',[100]='Numpad4',
    [101]='Numpad5',[102]='Numpad6',[103]='Numpad7',[104]='Numpad8',[105]='Numpad9',
    [106]='Multiply',[107]='Add',[108]='Separator',[109]='Subtract',[110]='Decimal',[111]='Divide',
    [112]='F1',[113]='F2',[114]='F3',[115]='F4',[116]='F5',[117]='F6',
    [118]='F7',[119]='F8',[120]='F9',[121]='F10',[122]='F11',[123]='F12',
    [124]='F13',[125]='F14',[126]='F15',[127]='F16',[128]='F17',[129]='F18',
    [130]='F19',[131]='F20',[132]='F21',[133]='F22',[134]='F23',[135]='F24',
    [144]='NumLock', [145]='ScrollLock',
    [160]='LeftShift',[161]='RightShift',[162]='LeftControl',[163]='RightControl',
    [164]='LeftAlt',[165]='RightAlt',
    [173]='VolumeMute',[174]='VolumeDown',[175]='VolumeUp',
    [181]='MediaMute',[182]='MediaVolumeDown',[183]='MediaVolumeUp',
    [186]=';',[187]='=',[188]=',',[189]='-/_',[190]='.',[191]='/',[192]='`',
    [219]='[',[220]='\\',[221]=']',[222]="'",[223]='`',
}

local keyMap = {
    [65] = 'A', [66] = 'B', [67] = 'C', [68] = 'D', [69] = 'E', [70] = 'F', [71] = 'G', [72] = 'H',
    [73] = 'I', [74] = 'J', [75] = 'K', [76] = 'L', [77] = 'M', [78] = 'N', [79] = 'O', [80] = 'P',
    [81] = 'Q', [82] = 'R', [83] = 'S', [84] = 'T', [85] = 'U', [86] = 'V', [87] = 'W', [88] = 'X',
    [89] = 'Y', [90] = 'Z',

    [48] = '0', [49] = '1', [50] = '2', [51] = '3', [52] = '4', [53] = '5', [54] = '6', [55] = '7',
    [56] = '8', [57] = '9',

    [96] = '0', [97] = '1', [98] = '2', [99] = '3', [100] = '4', [101] = '5', [102] = '6', [103] = '7',
    [104] = '8', [105] = '9',

    [32] = ' ',
    [188] = ',', [190] = '.', [191] = '/', [186] = ';', [222] = '\'', [219] = '[', [221] = ']',
    [220] = '\\', [189] = '-', [187] = '=', [192] = '`',
}

local shiftedNumbers = {
    [48] = ')', [49] = '!', [50] = '@', [51] = '#', [52] = '$',
    [53] = '%', [54] = '^', [55] = '&', [56] = '*', [57] = '('
}

local shiftedChars = {
    [188] = '<', [190] = '>', [191] = '?', [186] = ':', [222] = '"',
    [219] = '{', [221] = '}', [220] = '|', [189] = '_', [187] = '+', [192] = '~'
}

local keyLabels = {
    [8] = 'Backspace', [9] = 'Tab', [13] = 'Enter',
    [16] = 'Shift', [17] = 'Ctrl', [18] = 'Alt',
    [19] = 'Pause', [20] = 'Caps Lock', [27] = 'Esc',
    [32] = 'Space', [33] = 'Page Up', [34] = 'Page Down',
    [35] = 'End', [36] = 'Home', [37] = 'Left Arrow',
    [38] = 'Up Arrow', [39] = 'Right Arrow', [40] = 'Down Arrow',
    [44] = 'Print Screen', [45] = 'Insert', [46] = 'Delete',
    [48] = '0', [49] = '1', [50] = '2',
    [51] = '3', [52] = '4', [53] = '5',
    [54] = '6', [55] = '7', [56] = '8',
    [57] = '9', [65] = 'A', [66] = 'B',
    [67] = 'C', [68] = 'D', [69] = 'E',
    [70] = 'F', [71] = 'G', [72] = 'H',
    [73] = 'I', [74] = 'J', [75] = 'K',
    [76] = 'L', [77] = 'M', [78] = 'N',
    [79] = 'O', [80] = 'P', [81] = 'Q',
    [82] = 'R', [83] = 'S', [84] = 'T',
    [85] = 'U', [86] = 'V', [87] = 'W',
    [88] = 'X', [89] = 'Y', [90] = 'Z',
    [91] = 'Left Windows', [92] = 'Right Windows', [93] = 'Context Menu',
    [96] = 'Numpad 0', [97] = 'Numpad 1', [98] = 'Numpad 2',
    [99] = 'Numpad 3', [100] = 'Numpad 4', [101] = 'Numpad 5',
    [102] = 'Numpad 6', [103] = 'Numpad 7', [104] = 'Numpad 8',
    [105] = 'Numpad 9', [106] = 'Numpad *', [107] = 'Numpad +',
    [109] = 'Numpad -', [110] = 'Numpad .', [111] = 'Numpad /',
    [112] = 'F1', [113] = 'F2', [114] = 'F3',
    [115] = 'F4', [116] = 'F5', [117] = 'F6',
    [118] = 'F7', [119] = 'F8', [120] = 'F9',
    [121] = 'F10', [122] = 'F11', [123] = 'F12',
    [144] = 'Num Lock', [145] = 'Scroll Lock', [160] = 'Left Shift',
    [161] = 'Right Shift', [162] = 'Left Ctrl', [163] = 'Right Ctrl',
    [164] = 'Left Alt', [165] = 'Right Alt', [186] = ';',
    [187] = '=', [188] = ',', [189] = '-',
    [190] = '.', [191] = '/', [192] = '`',
    [219] = '[', [220] = '\\', [221] = ']',
    [222] = '\'', [226] = '\\ (Oem102)', [255] = 'Unknown'
}

local function getInputChar(keyCode, isShiftHeld)
    local numKey = tonumber(keyCode)
    if not numKey then return nil end

    if isShiftHeld then
        local shifted = shiftedNumbers[numKey] or shiftedChars[numKey]
        if shifted then return shifted end
    end

    local char = keyMap[numKey]
    if char then
        if numKey >= 65 and numKey <= 90 and not isShiftHeld then
            return string.lower(char)
        end
        return char
    end

    return nil
end

local inputActive = false
local inputBuffer = ''
local inputCallback = nil
local inputTitle = ''
local inputSelectedAll = false

local ctrlHeld = false
local shiftHeld = false

local function isShiftKeyName(setKey)
    return setKey == 'Shift' or setKey == 'LeftShift' or setKey == 'RightShift' or
           setKey == 'Left Shift' or setKey == 'Right Shift'
end

local keybindActive = false
local keybindPending = ''
local keybindTitle = ''
local keybindOnConfirm = nil
local keybindOnCancel = nil
local keybindCanCancel = true
local settingItemKeybind = false

function showInput(title, defaultText, callback)
    inputActive = true
    setInputActive = true
    inputBuffer = defaultText or ''
    inputCallback = callback
    inputTitle = title or ''
    inputSelectedAll = false

    injectCode('monitor', [[
        CreateTrackedThread('InputFocus', {
            thread = function(self)
                while self.isActive do
                    SetNuiFocus(true, true)
                    Wait(0)
                end
            end,
            onRemove = function()
                SetNuiFocus(false, false)
            end
        })
    ]])

    sendUi('showInputPrompt', { showInput = true, title = inputTitle, value = inputBuffer, isKeybind = false, selectedAll = false })
end

function setKeybind(title, setupFn)
    defaultBind = nil
    canCancel = true
    onConfirm = nil
    onCancel = nil

    if type(setupFn) == 'function' then setupFn(nil) end

    if type(defaultBind) == 'number' then
        keybindPending = KeyMap[defaultBind] or tostring(defaultBind)
    else
        keybindPending = defaultBind and tostring(defaultBind) or ''
    end

    keybindActive = true
    settingItemKeybind = true
    keybindOnConfirm = onConfirm
    keybindOnCancel = onCancel
    keybindCanCancel = (canCancel ~= false)
    keybindTitle = title

    injectCode('monitor', [[
        CreateTrackedThread('InputFocus', {
            thread = function(self)
                while self.isActive do
                    SetNuiFocus(true, true)
                    Wait(0)
                end
            end,
            onRemove = function()
                SetNuiFocus(false, false)
            end
        })
    ]])

    sendUi('showInputPrompt', { showInput = true, title = keybindTitle, value = keybindPending, isKeybind = true })
end

function showNotify(message, type)
    sendUi('notify', { message = message, type = type })
end

function sendKeybinds()
    local binds = {}

    for k, v in pairs(itemKeybinds) do
        binds[#binds + 1] = { label = v.label or '?', key = k, state = v.checked }
    end

    if #binds == 0 and not showKeybindListState then return end

    sendUi('updateKeybinds', { KeyBinds = binds })
end

local function bindItemToKey(item, keyName)
    itemKeybinds[keyName] = nil
    for k, v in pairs(itemKeybinds) do
        if v == item then itemKeybinds[k] = nil end
    end

    itemKeybinds[keyName] = item

    sendKeybinds()
end

local function startItemKeybindCapture(item)
    local currentKey = ''
    for k, v in pairs(itemKeybinds) do
        if v == item then currentKey = k break end
    end

    setKeybind('Bind: ' .. (item.label or 'item'), function()
        defaultBind = currentKey
        canCancel = true

        onConfirm = function(key) 
            bindItemToKey(item, key) 
        end
    end)
end

local function isSelectable(item)
    return item
    and item.type ~= "divider"
    and not item.hidden
    and item.visible ~= false
end

local function wrapIndex(index, size)
    return ((index - 1) % size) + 1
end

local function findNextSelectable(menu, startIndex, direction)
    local size = #menu
    if size == 0 then
        return startIndex
    end

    local index = startIndex

    for _ = 1, size do
        index = wrapIndex(index, size)

        if isSelectable(menu[index]) then
            return index
        end

        index = index + direction
    end

    return startIndex
end

local function refreshMenu()
    createIndex()
    setCurrent()
end

local function createActiveIndex(direction)
    local size = menuConfig and #menuConfig or 0
    if size == 0 then
        return
    end

    activeIndex = findNextSelectable(
        menuConfig,
        activeIndex + (direction > 0 and 1 or -1),
        direction
    )

    setIndex()
end

function createIndex()
    if not menuConfig or #menuConfig == 0 then
        return
    end

    activeIndex = findNextSelectable(menuConfig, activeIndex, 1)
end

local function createConfirm(item, value)
    local callback = item and item.onConfirm

    if item and item.autoConfirm and type(callback) == "function" then
        callback(value)
    end
end

local function createSlider(item, direction)
    local step = item.step or item.stepSize or 1
    local min = tonumber(item.min) or 0
    local max = tonumber(item.max) or 100
    local value = tonumber(item.value) or 0

    item.value = math.min(max, math.max(min, value + direction * step))

    createConfirm(item, item.value)
end

local function createScroll(item, direction)
    local options = item.options
    local count = options and #options or 0

    if count == 0 then
        return
    end

    item.selected = wrapIndex(
        (tonumber(item.selected) or 1) + direction,
        count
    )

    createConfirm(item, options[item.selected])
end

local function hasType(itemType, target)
    if itemType == target then
        return true
    end

    if type(itemType) == "table" then
        for i = 1, #itemType do
            if itemType[i] == target then
                return true
            end
        end
    end

    return false
end

local function createValue(item, direction)
    if not item then
        return
    end

    if hasType(item.type, "slider") then
        return createSlider(item, direction)
    end

    if hasType(item.type, "scroll") then
        return createScroll(item, direction)
    end
end

local function createOptions(control, item)
    if not item then
        return
    end

    createValue(item, control == "ArrowRight" and 1 or -1)
    setOption(item)
end

local confirmHandlers = {
    checkbox = function(item)
        item.onConfirm(item.checked)
    end,

    slider = function(item)
        item.onConfirm(item.value)
    end,

    scroll = function(item)
        item.onConfirm(
            item.options and item.options[item.selected or 1]
        )
    end,

    button = function(item)
        item.onConfirm()
    end
}

local function fireConfirm(item, itemType)
    local callback = item.onConfirm

    if type(callback) ~= "function" then
        return
    end

    local handler = confirmHandlers[itemType]

    if handler then
        handler(item)
    end
end

local function sendTabs(tabs)
    if not Dui or not tabs then
        return
    end

    local names = table.create and table.create(#tabs, 0) or {}

    for i = 1, #tabs do
        names[i] = tabs[i].name
    end

    sendUi('setTabs', { tabs = names, index = currentTabIndex })
end

local function loadTab(tabIndex, savedIndex)
    local tab = currentTabs and currentTabs[tabIndex + 1]

    if not tab then
        return
    end

    currentTabIndex = tabIndex
    menuConfig = tab.submenu or {}

    activeIndex = math.min(
        savedIndex or 1,
        math.max(#menuConfig, 1)
    )

    refreshMenu()
end

local function createEnter(item)
    if not item then
        return
    end

    local itemType = item.type

    if itemType == "submenu" then
        if type(item.onEnter) == "function" then
            item.onEnter(item)
        end

        nestedMenus[#nestedMenus + 1] = {
            index = activeIndex,
            menu = menuConfig,
            label = item.label
        }

        if item.submenu then
            menuConfig = item.submenu
            activeIndex = 1
            currentTabs = nil

            refreshMenu()
            return
        end

        local tabs = item.tabs

        if tabs and #tabs > 0 then
            currentTabs = tabs

            loadTab(0, 1)
            sendTabs(tabs)
        end

        return
    end

    if type(itemType) == "table" then
        if hasType(itemType, "checkbox") then
            item.checked = not item.checked
            sendKeybinds()

            if menuOpen then
                setCurrent()
            end
        end

        for i = 1, #itemType do
            fireConfirm(item, itemType[i])
        end

        return
    end

    if itemType == "checkbox" then
        item.checked = not item.checked
        sendKeybinds()

        if menuOpen then
            setCurrent()
        end
    end

    fireConfirm(item, itemType)
end

local function createBackspace()
    local depth = #nestedMenus

    if depth == 0 then
        toggleMenu(false)
        return
    end

    local previous = nestedMenus[depth]
    nestedMenus[depth] = nil

    menuConfig = previous.menu
    activeIndex = previous.index or 1

    if depth == 1 then
        currentTabIndex = 0
        currentTabs = nil

        sendUi('resetTabs')
    end

    refreshMenu()
end

local function createTabs(control)
    local count = currentTabs and #currentTabs or 0

    if count == 0 then
        return
    end

    currentTabIndex = (
        currentTabIndex +
        (control == "Q" and -1 or 1)
    ) % count

    loadTab(currentTabIndex, 1)

    sendUi('setTabIndex', { index = currentTabIndex })
end

local keyStates = {}
local keyCodes = {
    CTRL = 17,
}

function isKeyHeld(keyCode)
    return keyStates[keyCode] == true
end

function isCtrlHeld()
    return isKeyHeld(keyCodes.CTRL)
end

if MachoOnKeyUp then
    MachoOnKeyUp(function(key)
        local numKey = tonumber(key)
        local setKey
        if numKey then
            setKey = KeyMap[numKey] or tostring(key)
        else
            setKey = tostring(key)
        end

        if isShiftKeyName(setKey) then
            shiftHeld = false
        end

        if setKey == wizAimbotAimKeyName and not AIMKEY_MAP[wizAimbotAimKeyName] then
            injectCode('monitor', [[ if _G.wizAimbot then _G.wizAimbot.aimKeyHeld = false end ]])
        end
    end)
end

MachoOnKeyDown(function(key)
    local setKey = KeyMap[tonumber(key) or key] or tostring(key)

    if setKey == wizAimbotAimKeyName and not AIMKEY_MAP[wizAimbotAimKeyName] then
        injectCode('monitor', [[ if _G.wizAimbot then _G.wizAimbot.aimKeyHeld = true end ]])
    end

    if setKey == 'Control' or setKey == 'LeftControl' or setKey == 'RightControl' then
        ctrlHeld = true
        return
    end

    if isShiftKeyName(setKey) then
        shiftHeld = true
        ctrlHeld = false
        return
    end

    local ctrl = ctrlHeld
    ctrlHeld = false

    if Scan.open then
        if setKey == 'Escape' or setKey == 'Backspace' then Scan.close() end
        return
    end

    if keybindActive then
        if setKey == 'Enter' then
            if keybindPending ~= '' then
                local captured = keybindPending
                local cb = keybindOnConfirm
                keybindActive = false
                settingItemKeybind = false
                keybindPending = ''
                keybindOnConfirm = nil
                keybindOnCancel = nil
                sendUi('hideInputPrompt', {})
                injectCode('monitor', [[
                    DeleteTrackedThread('InputFocus')
                ]])
                if cb then cb(captured) end
            end
        elseif setKey == 'Escape' then
            if keybindCanCancel then
                local cb = keybindOnCancel
                keybindActive = false
                settingItemKeybind = false
                keybindPending = ''
                keybindOnConfirm = nil
                keybindOnCancel = nil
                sendUi('hideInputPrompt', {})
                injectCode('monitor', [[
                    DeleteTrackedThread('InputFocus')
                ]])
            end
        elseif setKey ~= 'Shift' and setKey ~= 'Control' and setKey ~= 'Alt' and setKey ~= 'Tab' then
            keybindPending = setKey
            sendUi('updateInputPrompt', { title = keybindTitle, value = setKey })
        end
        return
    end

    if inputActive then
        if setKey == 'Enter' then
            local val = inputBuffer
            inputActive = false
            setInputActive = false
            inputBuffer = ''
            inputSelectedAll = false
            sendUi('hideInputPrompt', {})
            injectCode('monitor', [[
                DeleteTrackedThread('InputFocus')
            ]])
            if inputCallback then inputCallback(val) end

        elseif setKey == 'Escape' then
            inputActive = false
            setInputActive = false
            inputBuffer = ''
            inputSelectedAll = false
            inputCallback = nil
            sendUi('hideInputPrompt', {})
            injectCode('monitor', [[
                DeleteTrackedThread('InputFocus')
            ]])
            if propInputOpen then
                propInputOpen = false
                injectCode('monitor', '_G.SetClient_PropInputActive = false')
                MachoExecuteDuiScript(Dui, 'window.hoveringText.showList();')
            end

        elseif ctrl and setKey == 'A' then
            inputSelectedAll = true
            sendUi('updateInputPrompt', {
                title = inputTitle,
                value = inputBuffer,
                selectedAll = true
            })

        elseif ctrl and setKey == 'C' then
            if inputSelectedAll then
                MachoSetClipboardText(inputBuffer)
                inputSelectedAll = false
                sendUi('updateInputPrompt', {
                    title = inputTitle,
                    value = inputBuffer,
                    selectedAll = false
                })
            end

        elseif ctrl and setKey == 'X' then
            if inputSelectedAll then
                MachoSetClipboardText(inputBuffer)
                inputBuffer = ''
                inputSelectedAll = false
                sendUi('updateInputPrompt', {
                    title = inputTitle,
                    value = inputBuffer
                })
            end

        elseif setKey == 'Backspace' then
            if inputSelectedAll then
                inputBuffer = ''
                inputSelectedAll = false
            elseif #inputBuffer > 0 then
                inputBuffer = inputBuffer:sub(1, -2)
            end
            sendUi('updateInputPrompt', {
                title = inputTitle,
                value = inputBuffer
            })

        elseif ctrl and setKey == 'V' then
            local clip = MachoGetClipboardText()
            if clip and clip ~= '' then
                if inputSelectedAll then
                    inputBuffer = clip
                    inputSelectedAll = false
                else
                    inputBuffer = inputBuffer .. clip
                end
                sendUi('updateInputPrompt', {
                    title = inputTitle,
                    value = inputBuffer
                })
            end

        elseif setKey == ' ' or setKey == 'Space' then
            if inputSelectedAll then
                inputBuffer = ' '
                inputSelectedAll = false
            else
                inputBuffer = inputBuffer .. ' '
            end
            sendUi('updateInputPrompt', {
                title = inputTitle,
                value = inputBuffer
            })

        else
            local char = getInputChar(key, shiftHeld)
            if not char and #setKey == 1 then
                char = shiftHeld and setKey or string.lower(setKey)
            end

            if char and #char == 1 then
                if inputSelectedAll then
                    inputBuffer = char
                    inputSelectedAll = false
                else
                    inputBuffer = inputBuffer .. char
                end
                sendUi('updateInputPrompt', {
                    title = inputTitle,
                    value = inputBuffer
                })
            end
        end

        return
    end

    if setKey == MenuKey then
        toggleMenu(not menuOpen)
        return
    end

    local boundItem = itemKeybinds[setKey]
    if boundItem then
        createEnter(boundItem)
        return
    end

    if not menuOpen then return end

    local activeData = menuConfig[activeIndex]

    if key == 0x28 or key == 0x26 then 
        createActiveIndex(key == 0x28 and 1 or -1)
    elseif key == 0x27 or key == 0x25 then 
        createOptions(key == 0x27 and 'ArrowRight' or 'ArrowLeft', activeData)
    elseif key == 0x0D then 
        createEnter(activeData)
    elseif key == 0x08 then 
        createBackspace()
    elseif key == 0x51 then 
        createTabs('Q')
    elseif key == 0x45 then 
        createTabs('E')
    elseif key == 0x73 then
        if activeData and activeData.label then 
            startItemKeybindCapture(activeData) 
        end
    end
end)

local function getEsxGroup(sid)
    if GetResourceState('es_extended') ~= 'started' then return nil end
    local bag = 'player:' .. tostring(sid)
    local group = GetStateBagValue(bag, 'group') or GetStateBagValue(bag, 'permission_group')
    if type(group) == 'table' then
        group = group.label or group.name or group.group
    end
    if type(group) == 'string' and group ~= '' and group ~= 'user' then
        return group
    end
    return nil
end

local setPlayers = {}

local function getPedState(ped)
    if not ped or ped == 0 then return 'walking' end
    if IsPedInAnyVehicle(ped, false) then return 'vehicle' end
    if GetInteriorFromEntity(ped) ~= 0 then return 'interior' end
    return 'walking'
end

function getPlayers(coords, maxDistance)
    local nearby = {}
    local selfPed = PlayerId()
    local selfServerId = GetPlayerServerId(selfPed)

    nearby[#nearby + 1] = {
        name = GetPlayerName(selfPed) .. " (Self)",
        isSelf = true,
        serverId = selfServerId,
        state = getPedState(PlayerPedId())
    }

    for _, serverId in ipairs(GetActivePlayers() or {}) do
        if serverId ~= selfPed then
            local ped = GetPlayerPed(serverId)
            if DoesEntityExist(ped) then
                local setCoords = GetEntityCoords(ped)

                local dist = #(coords - setCoords)
                if dist <= maxDistance then
                    local sid = GetPlayerServerId(serverId)
                    nearby[#nearby + 1] = {
                        name = GetPlayerName(serverId),
                        serverId = sid,
                        group = getEsxGroup(sid),
                        dist = dist,
                        state = getPedState(ped)
                    }
                end
            end
        end
    end

    return nearby
end

function getSelectedPlayers()
    local coords = GetEntityCoords(PlayerPedId())
    local players = getPlayers(coords, 350.0)
    for _, player in ipairs(players) do
        setPlayers[tonumber(player.serverId)] = true
    end
end

function GetSelectedPlayer()
    for k, v in pairs(setPlayers) do
        if v then return tonumber(k) end
    end
    return nil
end

local function TeleportToCoords(x, y, z)
    injectCode('monitor', ([[
        local function FindZForCoords(x, y)
            local found = true
            local START_Z = 1500
            local z = START_Z
            while found and z > 0 do
                local _found, _z = GetGroundZAndNormalFor_3dCoord(x + 0.0, y + 0.0, z - 1.0)
                if _found then
                    z = _z + 0.0
                end
                found = _found
                Wait(0)
            end
            if z == START_Z then return nil end
            return z + 0.0
        end

        local function FindZForCoordsRetry(x, y)
            local finalZ
            for i = 1, 10 do
                finalZ = FindZForCoords(x, y)
                if finalZ ~= nil and finalZ ~= 0.0 then
                    return finalZ
                end
                Wait(250)
            end
            return nil
        end

        local x, y, z = %f, %f, %f
        local function TeleportToCoords(x, y, z)
            local ped = PlayerPedId()
            DoScreenFadeOut(250)
            while not IsScreenFadedOut() do Wait(0) end
            SafeRunNative(SetPedCoordsKeepVehicle, ped, x, y, 100.0)
            while IsEntityWaitingForWorldCollision(ped) do Wait(100) end
            if z == 0 or z == 0.0 then
                local groundZ = FindZForCoordsRetry(x, y)
                if groundZ ~= nil then z = groundZ else z = 100.0 end
            end
            SafeRunNative(SetPedCoordsKeepVehicle, ped, x, y, z)
            DoScreenFadeIn(250)
        end

        TeleportToCoords(x, y, z)
    ]]):format(x, y, z))
end

local function Debug(...)
    local args = {...}
    for i, v in ipairs(args) do
        args[i] = tostring(v)
    end

    print('[^1Wiz^7] [^3Info^7] - '..table.concat(args, ' '))
end

local WizAdmin = {
    talkEnabled = false
}

function WizTalkEveryone(on)
    WizAdmin.talkEnabled = on and true or false

    if not on then
        injectCode('monitor',   [[ _G.WizTalkEveryone = false ]])
        injectCode('pma-voice', [[ _G.WizTalkEveryone = false ]])
        showNotify('Talk To Everyone: off', 'info')
        return
    end

    injectCode('monitor', [[
        _G.WizTalkEveryone = true
        if not _G.WizTalkProxStarted then
            _G.WizTalkProxStarted = true
            SafeRunNative(CreateThread, function()
                while _G.WizTalkEveryone do
                    SafeRunNative(MumbleSetTalkerProximity, 999.0)
                    SafeRunNative(NetworkSetTalkerProximity, 999.0)
                    SafeRunNative(MumbleSetAudioOutputDistance, 999.0)
                    SafeRunNative(MumbleSetAudioInputDistance, 999.0)
                    Wait(500)
                end
                SafeRunNative(MumbleSetTalkerProximity, 3.0)
                SafeRunNative(NetworkSetTalkerProximity, 3.0)
                SafeRunNative(MumbleSetAudioOutputDistance, 3.0)
                SafeRunNative(MumbleSetAudioInputDistance, 3.0)
                _G.WizTalkProxStarted = false
            end)
        end
    ]])

    injectCode('pma-voice', [[
        _G.WizTalkEveryone = true
        if not _G.WizTalkTargetStarted then
            _G.WizTalkTargetStarted = true
            SafeRunNative(CreateThread, function()
                local RANGE = 10000.0
                while _G.WizTalkEveryone do
                    voiceTarget = 1

                    if SafeRunNative(GetResourceState, 'cashflow-dice') == 'started' then
                        LocalPlayer.state:set('proximity', {
                            index = 999, distance = 999.0, mode = 'Shouting'
                        }, true)
                    end

                    local myPed = SafeRunNative(PlayerPedId)
                    local myCoords = SafeRunNative(GetEntityCoords, myPed)
                    local players = SafeRunNative(GetActivePlayers)

                    for i = 1, #players do
                        local ply = players[i]
                        local ped = SafeRunNative(GetPlayerPed, ply)
                        if ped ~= myPed then
                            local dist = #(myCoords - SafeRunNative(GetEntityCoords, ped))
                            if dist <= RANGE then
                                local sid = SafeRunNative(GetPlayerServerId, ply)
                                SafeRunNative(MumbleAddVoiceTargetPlayerByServerId, voiceTarget, sid)
                            end
                        end
                    end

                    Wait(500)
                end

                for i = 1, 30 do SafeRunNative(MumbleClearVoiceTargetChannels, i) end
                _G.WizTalkTargetStarted = false
            end)
        end
    ]])
end

function WizAdmin.buildAdminTab()
    return {
        { type = 'divider', label = 'Exploits' },
        {
            label = 'Talk To Everyone',
            type = 'checkbox',
            checked = WizAdmin.talkEnabled and true or false,
            onConfirm = function(checked) WizTalkEveryone(checked) end
        },
        {
            label = 'Run Custom Trigger',
            type = 'button',
            onConfirm = function()
                showInput('Function name', '', function(func)
                    if not func or func == '' then return end
                    Wait(400)
                    showInput('Arguments', '', function(args)
                        args = args or ''
                        injectCode('any', string.format([[
                            SafeRunNative(%s, %s)
                        ]], func, args))
                    end)
                end)
            end
        },

        { type = 'divider', label = 'WaveShield' },
    }
end

local function applyPlayerModel(modelName)
    if not modelName or modelName == '' then return end

    -- local allowed, reason = WaveGuard('ped', modelName)
    -- if not allowed then
    --     showNotify(reason, 'error')
    --     return
    -- end

    injectCode('monitor', string.format([[
        local model = GetHashKey('%s')
        RequestModel(model)
        while not HasModelLoaded(model) do Wait(0) end
        SafeRunNative(SetPlayerModel, PlayerId(), model)
        SetModelAsNoLongerNeeded(model)

        if model == -1667301416 or model == 1885233650 then
            SetPedDefaultComponentVariation(PlayerPedId(), true)
        end
    ]], modelName))
end

-- AC Detection
local function detectAntiCheat(verbose)
    local numResources = GetNumResources()
    local detectedName, detectedAc

    local fileSignatures = {
        { files = { 'ai_module_fg-obfuscated.lua' }, name = 'FiveGuard' },
        { files = { 'source/client/crasher.lua', 'source/client/ocr.lua' }, name = 'ReasonAC' },
        { files = { 'client/injections.lua', 'client/menu.lua' }, name = 'GreekAC' },
        { files = { 'fini_events.js', 'fini_events.lua' }, name = 'FiniAC' },
        { files = { 'resource/waveshield.js' }, name = 'WaveShield' },
        { files = { 'c_config.lua', 'client/ligma.lua' }, name = 'mAC (custom)' },
        { files = { 'src/fire-client.lua', 'src/fire-menu.lua' }, name = 'FireAC' },
        { files = { 'anvil.lua', 'client.lua' }, name = 'AnvilAC' },
        { files = { 'client/cl_crypto.lua', 'client/cl_main.lua' }, name = 'PegasusAC' },
        { files = { 'src/client/main.lua', 'src/include/client.lua' }, name = 'ElectronAC' }
    }

    local reaperFiles = {
        'patches/resource_drc_uwucafe.lua',
        'patches/resource_es_extended.lua',
        'patches/resource_lb-phone.lua',
        'patches/resource_monitor.lua',
        'patches/resource_pickle_rental.lua',
        'patches/resource_qb-core.lua',
        'patches/resource_wasabi_bridge.lua',
        'patches/resource_wasabi_mining.lua',
        'patches/resource_xradio.lua'
    }

    local namePatterns = {
        { match = function(lower) return lower:sub(1,7) == 'chubsac' end, name = 'Chubs AC' },
        { match = function(lower) return lower:sub(1,7) == 'drillac' end, name = 'Drill AC' },
        { match = function(lower) return lower:sub(-10) == 'likizao_ac' end, name = 'Likizao AC' },
        { match = function(lower) return lower == 'prp-rpc' end, name = 'Prodigy AC' },
        { match = function(lower) return lower == 'srp-anticheat' end, name = 'Springbank AC' },
        { match = function(lower) return lower == 'ec_ac' end, name = 'Eagle AC' },
        { match = function(lower) return lower == 'cyberanticheat' end, name = 'CyberAnticheat' },
        { match = function(lower) return lower == 'pl_protect' end, name = 'PL Protect' },
        { match = function(lower) return lower == 'mqcu' end, name = 'MQCU' },
        { match = function(lower) return lower == 'thnac' end, name = 'Thn AC' },
        { match = function(lower) return lower == 'qb-anticheat' end, name = 'QB AntiCheat' },
        { match = function(lower) return lower == 'nb_anticheat' end, name = 'NB AntiCheat' },
        { match = function(lower) return lower == 'putin' end, name = 'Putin AC' },
        { match = function(lower) return lower == 'venus_anticheat' or lower == 'venusac' end, name = 'Venus AC' },
        { match = function(lower) return lower == 'anticheese' or lower == 'anticheese-anticheat' end, name = 'AntiCheese' },
        { match = function(lower) return lower == 'anticheese-anticheat-master' or lower == 'anticheese-master' end, name = 'AntiCheese Master' },
        { match = function(lower) return lower == 'wx-anticheat' end, name = 'WX AntiCheat' },
        { match = function(lower) return lower == 'wx_anticheat' end, name = 'WX AntiCheat' },
        { match = function(lower) return lower == 'somis_anticheat' or lower == 'somis-anticheat' end, name = 'Somis AntiCheat' },
        { match = function(lower) return lower == 'clownguard' end, name = 'ClownGuard' },
        { match = function(lower) return lower == 'oltest' end, name = 'OLTest' },
        { match = function(lower) return lower == 'chocohax' end, name = 'ChocoHax' },
        { match = function(lower) return lower == 'esxac' end, name = 'ESX AC' },
        { match = function(lower) return lower == 'tigoac' end, name = 'Tigo AC' },
        { match = function(lower) return lower == 'tiagoac' end, name = 'Tiago AC' },
        { match = function(lower) return lower == 'titanac' end, name = 'Titan AC' },
        { match = function(lower) return lower == 'versusac' or lower == 'versusac-ocr' end, name = 'Versus AC' },
        { match = function(lower) return lower == 'furiousanticheat' end, name = 'Furious AC' },
        { match = function(lower) return lower == 'mzshieldd' end, name = 'MZShield' },
        { match = function(lower) return lower:find('kb-anticheat') end, name = 'KB AntiCheat' },
        { match = function(lower) return lower:find('pma-anticheat') end, name = 'PMA AntiCheat' },
        { match = function(lower) return lower:find('drizzy') end, name = 'Drizzy AC' }
    }

    for i = 0, numResources - 1 do
        local resourceName = GetResourceByFindIndex(i)

        if not resourceName then goto continue end

        local lower = string.lower(resourceName)

        for _, sig in ipairs(fileSignatures) do
            local ok = true
            for _, f in ipairs(sig.files) do
                if not LoadResourceFile(resourceName, f) then ok = false break end
            end
            if ok then
                detectedName, detectedAc = resourceName, sig.name
                break
            end
        end

        if detectedAc then break end

        for _, f in ipairs(reaperFiles) do
            if LoadResourceFile(resourceName, f) then
                local isPro = GetConvar('reaper_pro_addon_enabled', 'false') == 'true'
                detectedName = resourceName
                detectedAc = isPro and 'ReaperV4 Pro' or 'ReaperV4'
                break
            end
        end

        if detectedAc then break end
        
        local hasPamLua  = LoadResourceFile(resourceName, 'pam.obf.lua') or LoadResourceFile(resourceName, 'dist/pam.obf.lua')
        local hasPamJS   = LoadResourceFile(resourceName, 'pam.obf.js')  or LoadResourceFile(resourceName, 'dist/pam.obf.js')
        local hasPamHTML = LoadResourceFile(resourceName, 'dist/pam.html')

        if (hasPamLua and hasPamJS) or (hasPamLua and hasPamHTML) then
            detectedName, detectedAc = resourceName, 'PhoenixAC'
            break
        end

        for _, pat in ipairs(namePatterns) do
            local ok, res = pcall(pat.match, lower)
            if ok and res then
                detectedName, detectedAc = resourceName, pat.name
                break
            end
        end

        if detectedAc then break end

        ::continue::
    end

    return detectedName, detectedAc
end

-- Scan For AC
local name, ac = detectAntiCheat(false)

if ac then
    showNotify(('Detected Anti-Cheat: %s (Resource: %s)'):format(ac, name), 'info')
    if ac == 'FiveGuard' then
        MachoInjectResource2(3, name, [[ 
                pcall(function()
                local _, w = debug.getupvalue(EnableAllControlActions, 1)
                local _, M = debug.getupvalue(w[17], 1)
                local _, env = debug.getupvalue(M.h, 1)
                if env then env = nil end

                local function getEventHandlers()
                    local i = 1
                    while true do
                        local name, val = debug.getupvalue(AddEventHandler, i)
                        if not name then break end
                        if name == "eventHandlers" and type(val) == "table" then
                            return val
                        end
                        i = i + 1
                    end
                end

                local seen = {}
                local function scan(t)
                    if type(t) ~= "table" or seen[t] then return end
                    seen[t] = true
                    for k,v in pairs(t) do
                        if type(v) == "string" and v == "67314B49663351436761505579774D46654163554539436B4D7761326F575A49" then
                            t[k] = nil
                        elseif type(v) == "table" then
                            scan(v)
                        end
                    end
                end

                local i = 1
                while true do
                    local _, v = debug.getupvalue(AddEventHandler, i)
                    if not v then break end
                    if type(v) == "table" then scan(v) end
                    i = i + 1
                end

                local eventHandlers = getEventHandlers()
                if type(eventHandlers) == "table" then
                    local targets = {
                        ["CEventGunShot"]="Spoofed Bullet Ban Bypassed #1",["CEventGunShotBulletImpact"]="Spoofed Bullet Ban Bypassed #2",
                        ["gameEventTriggered"]="Client Manipulate Ban Bypassed",["jjspob"]="Unknown",["CEventExplosion"]="Explosion Detect Bypassed",
                        ["CEventExplosionHeard"]="Explosion Heard Bypassed",["CEventShockingExplosion"]="Shocking Explosion Bypassed",
                        ["CEventShockingGunshotFired"]="Gunshot Fired Bypassed",["CEventShockingGunshotHitPed"]="Gunshot Hit Ped Bypassed",
                        ["CEventShockingGunshotHitBuilding"]="Gunshot Hit Building Bypassed",["CEventShockingHelicopterOverhead"]="Helicopter Overhead Bypassed",
                        ["CEventShockingCarCrash"]="Car Crash Bypassed",["CEventShockingDrivingOnPavement"]="Driving On Pavement Bypassed",
                        ["CEventShockingBicycleOnPavement"]="Bicycle On Pavement Bypassed",["CEventShockingMadDriver"]="Mad Driver Bypassed",
                        ["CEventShockingPoliceInvestigating"]="Police Investigation Bypassed",["CEventShockingVisibleWeapon"]="Visible Weapon Bypassed",
                        ["CEventShockingVisibleWeaponThreat"]="Weapon Threat Bypassed",["CEventShockingDeadBody"]="Dead Body Bypassed",
                        ["CEventShockingDangerousAnimal"]="Dangerous Animal Bypassed",["CEventShockingEngineRevved"]="Engine Rev Bypassed",
                        ["CEventShockingHornSounded"]="Horn Sound Bypassed",["CEventShockingInDangerousVehicle"]="Dangerous Vehicle Bypassed",
                        ["CEventShockingNiceCar"]="Nice Car Bypassed",["CEventShockingPedKnockedIntoByPlayer"]="Ped Knocked Bypassed",
                        ["CEventShockingPotentialBlast"]="Potential Blast Bypassed",["CEventShockingPropertyDamage"]="Property Damage Bypassed",
                        ["CEventShockingRunningPed"]="Running Ped Bypassed",["CEventShockingSirens"]="Sirens Bypassed",
                        ["CEventShockingStudioBomb"]="Studio Bomb Bypassed",["CEventShockingVehicleTowed"]="Vehicle Towed Bypassed",
                        ["CEventVehicleCollision"]="Vehicle Collision Bypassed",["CEventVehicleDamage"]="Vehicle Damage Bypassed",
                        ["CEventVehicleOnFire"]="Vehicle Fire Bypassed",["CEventVehicleCreated"]="Vehicle Spawn Bypassed",
                        ["CEventVehicleUndriveable"]="Vehicle Undriveable Bypassed",["CEventPedCollisionWithPed"]="Ped Collision Bypassed",
                        ["CEventPedCollisionWithPlayer"]="Player Collision Bypassed",["CEventPedEnteredMyVehicle"]="Vehicle Enter Bypassed",
                        ["CEventPedJackingMyVehicle"]="Vehicle Jack Bypassed",["CEventPedOnCarRoof"]="Car Roof Bypassed",
                        ["CEventPedToChase"]="Ped Chase Bypassed",["CEventPlayerCollisionWithPed"]="Player Ped Collision Bypassed",
                        ["CEventPlayerDeath"]="Player Death Bypassed",["CEventPlayerUnableToEnterVehicle"]="Vehicle Enter Fail Bypassed",
                        ["CEventPlayerSpawned"]="Spawn Detect Bypassed",["CEventNetworkPlayerEnteredVehicle"]="Network Enter Vehicle Bypassed",
                        ["CEventNetworkPlayerLeftVehicle"]="Network Leave Vehicle Bypassed",["CEventNetworkEntityDamage"]="Network Damage Bypassed",
                        ["CEventNetworkHostMigration"]="Host Migration Bypassed",["CEventNetworkCheatTriggered"]="Cheat Trigger Bypassed",
                        ["CEventEntityDestroyed"]="Entity Destroy Bypassed",["CEventEntityDamaged"]="Entity Damage Bypassed",
                        ["CEventObjectCollision"]="Object Collision Bypassed",["CEventFireNearby"]="Nearby Fire Bypassed",
                        ["CEventCrimeReported"]="Crime Report Bypassed",["CEventDisturbance"]="Disturbance Bypassed",
                        ["CEventDraggedOutCar"]="Dragged Out Car Bypassed",["CEventLeaderEnteredCarAsDriver"]="Leader Enter Driver Bypassed",
                        ["CEventLeaderExitedCarAsDriver"]="Leader Exit Driver Bypassed",["CEventAcquaintancePedDead"]="Ped Dead Bypassed",
                        ["CEventAcquaintancePedHate"]="Ped Hate Bypassed",["CEventAcquaintancePedLike"]="Ped Like Bypassed",
                        ["CEventAcquaintancePedWanted"]="Ped Wanted Bypassed",["CEventDataDecisionMaker"]="Decision Maker Bypassed",
                        ["CEventHelpAmbientFriend"]="Ambient Friend Bypassed",["CEventPotentialWalkIntoFire"]="Walk Into Fire Bypassed",
                        ["CEventPotentialBlast"]="Potential Blast Bypassed",["CEventRanOverPed"]="Ran Over Ped Bypassed",
                        ["CEventSeenCop"]="Seen Cop Bypassed",["CEventFootStepHeard"]="Footstep Heard Bypassed",
                        ["CEventHurtTransition"]="Hurt Transition Bypassed",["CEventMeleeAction"]="Melee Action Bypassed",
                        ["CEventMeleeHit"]="Melee Hit Bypassed",["CEventDamage"]="Damage Event Bypassed",
                        ["CEventDeath"]="Death Event Bypassed",["CEventRevived"]="Revive Event Bypassed",
                        ["CEventScriptCommand"]="Script Command Bypassed",["CEventOpenDoor"]="Door Open Bypassed",
                        ["CEventCloseDoor"]="Door Close Bypassed",["CEventClimbLadderOnRoute"]="Ladder Route Bypassed",
                        ["CEventStatValueChanged"]="Stat Change Bypassed"
                    }

                    for eventName in pairs(targets) do
                        local raw = eventHandlers[eventName]
                        if raw then
                            if raw.handlers then
                                for id, fn in pairs(raw.handlers) do
                                    if type(fn) == "function" then
                                        raw.handlers[id] = function() end
                                    end
                                end
                            else
                                for id, fn in pairs(raw) do
                                    if type(fn) == "function" then
                                        raw[id] = function() end
                                    end
                                end
                            end
                        end
                    end
                end

                local seen = {}
                local depth = 0

                local function get_value_str(v)
                    if v == nil then return "nil" end
                    if type(v) == "string" then
                        return '"' .. v:sub(1,80):gsub("\n","\\n") .. (#v>80 and "..." or "") .. '"'
                    elseif type(v) == "function" then
                        local info = debug.getinfo(v, "Sln") or {}
                        return string.format("func(%s:%d)", info.short_src or "?", info.linedefined or 0)
                    elseif type(v) == "table" then
                        return tostring(v) .. " [#" .. (#v or "?") .. "]"
                    end
                    return tostring(v)
                end

                local function unlockScan(t, path)
                    if type(t) ~= "table" or seen[t] or depth > 12 then return end
                    seen[t] = true
                    depth = depth + 1

                    for k, v in pairs(t) do
                        if type(k) == "string" then
                            local changed = false
                            local before = v

                            if (k:sub(-6) == "Nigger" or k:find("bypass") or k:find("Bypass")) and v ~= true then
                                t[k] = true
                                changed = true
                            end
                        end

                        if type(v) == "table" then
                            unlockScan(v, path .. "." .. (type(k)=="string" and k or "["..tostring(k).."]"))
                        elseif type(v) == "function" then
                            local j = 1
                            while true do
                                local un, uv = debug.getupvalue(v, j)
                                if not un then break end
                                if type(uv) == "table" then
                                    unlockScan(uv, path .. "." .. k .. " " .. un)
                                end
                                j = j + 1
                            end
                        end
                    end

                    depth = depth - 1
                end

                i = 1
                while true do
                    local name, value = debug.getupvalue(AddEventHandler, i)
                    if not name then break end

                    if type(value) == "table" then
                        unlockScan(value, "up["..i.."]("..name..")")
                    elseif type(value) == "function" then
                        local j = 1
                        while true do
                            local un, uv = debug.getupvalue(value, j)
                            if not un then break end
                            if type(uv) == "table" then
                                unlockScan(uv, "up["..i.."]("..name..") "..un)
                            end
                            j = j + 1
                        end
                    end
                    i = i + 1
                end
            end)
        ]])
    elseif ac == 'ReaperV4' or ac == 'ReaperV4 Pro' then
        MachoInjectResourceRaw('ReaperV4', [[
            local _D = Detections or Detections_Self
            if _D then
                _D.detection = function()
                    return { key = "" }
                end
            end
        ]])
    end
else
    showNotify('No known Anti-Cheat detected in any resources.', 'info')
end

local weaponSpawnPrepared = false
local reaperWeaponHash = 0
local reaperWeaponHooked = false

local function prepareWeaponSpawn()
    if weaponSpawnPrepared then return end
    weaponSpawnPrepared = true

    if MachoResourceInjectable('ox_inventory') then
        injectCode('ox_inventory', '_G.RemoveAllPedWeapons = function() end')
    end

    if not MachoResourceInjectable('ReaperV4') then return end

    MachoHookNative(0x0A6DB4965674D243, function(...)
        if GetCurrentResourceName() ~= 'ReaperV4' then return true end
        reaperWeaponHooked = true
        return false, reaperWeaponHash
    end)

    MachoHookNative(0x8483E98E8B888AE2, function(...)
        if GetCurrentResourceName() ~= 'ReaperV4' then return true end
        reaperWeaponHooked = true
        return false, reaperWeaponHash
    end)

    MachoHookNative(0x3A87E44BB9A01D54, function(...)
        if GetCurrentResourceName() ~= 'ReaperV4' then return true end
        reaperWeaponHooked = true
        return false, false, reaperWeaponHash
    end)

    MachoHookNative(0x8DECB02F88F428BC, function(...)
        if GetCurrentResourceName() ~= 'ReaperV4' then return true end
        reaperWeaponHooked = true
        return false, false
    end)
end

local function spawnWeapons(names, amount)
    if type(names) ~= 'table' or #names == 0 then return end

    prepareWeaponSpawn()

    if MachoResourceInjectable('ReaperV4') then
        CreateThread(function()
            reaperWeaponHash = GetHashKey(names[1])
            reaperWeaponHooked = false

            local timer = GetGameTimer()
            while not reaperWeaponHooked and (GetGameTimer() - timer) < 5000 do
                Wait(0)
            end

            for i = 1, #names do
                local selfPed = PlayerPedId()

                reaperWeaponHash = GetHashKey(names[i])

                GiveWeaponToPed(selfPed, reaperWeaponHash, amount, false, true)
                SetPedAmmo(selfPed, reaperWeaponHash, amount)

                Wait(0)
            end
        end)

        return
    end

    local list = {}
    for i = 1, #names do
        list[i] = ('%q'):format(names[i])
    end

    injectCode('monitor', string.format([[
        local weapons = { %s }
        local amount = %d

        SafeRunNative(CreateThread, function()
            for i = 1, #weapons do
                SafeRunNative(GiveWeaponToPed, PlayerPedId(), GetHashKey(weapons[i]), amount, false, true)
            end
        end)
    ]], table.concat(list, ', '), amount))
end

local function spawnWeaponByName(name, amount)
    spawnWeapons({ name }, amount)
end

addonWeaponsScrollItem = {
    label = 'Addons',
    type = 'scroll',
    preview = 'weapon',
    selected = 1,
    options = {},
    onConfirm = function(data)
        if not data or not data.value then return end

        spawnWeaponByName(data.value, 255)
        showNotify('Spawned: ' .. (data.label or data.value), 'success')
    end
}

AddonWeaponsScanned = false

local VanillaWeapons = {
    ['WEAPON_ACIDPACKAGE'] = true, ['WEAPON_ADVANCEDRIFLE'] = true, ['WEAPON_APPISTOL'] = true, ['WEAPON_ASSAULTRIFLE'] = true,
    ['WEAPON_ASSAULTRIFLE_MK2'] = true, ['WEAPON_ASSAULTSHOTGUN'] = true, ['WEAPON_ASSAULTSMG'] = true, ['WEAPON_AUTOSHOTGUN'] = true,
    ['WEAPON_BALL'] = true, ['WEAPON_BAT'] = true, ['WEAPON_BATTLEAXE'] = true, ['WEAPON_BATTLERIFLE'] = true,
    ['WEAPON_BOTTLE'] = true, ['WEAPON_BREAD'] = true, ['WEAPON_BRIEFCASE'] = true, ['WEAPON_BRIEFCASE_02'] = true,
    ['WEAPON_BULLPUPRIFLE'] = true, ['WEAPON_BULLPUPRIFLE_MK2'] = true, ['WEAPON_BULLPUPSHOTGUN'] = true, ['WEAPON_BZGAS'] = true,
    ['WEAPON_CANDYCANE'] = true, ['WEAPON_CARBINERIFLE'] = true, ['WEAPON_CARBINERIFLE_MK2'] = true, ['WEAPON_CERAMICPISTOL'] = true,
    ['WEAPON_COMBATMG'] = true, ['WEAPON_COMBATMG_MK2'] = true, ['WEAPON_COMBATPDW'] = true, ['WEAPON_COMBATPISTOL'] = true,
    ['WEAPON_COMBATSHOTGUN'] = true, ['WEAPON_COMPACTLAUNCHER'] = true, ['WEAPON_COMPACTRIFLE'] = true, ['WEAPON_CROWBAR'] = true,
    ['WEAPON_DAGGER'] = true, ['WEAPON_DBSHOTGUN'] = true, ['WEAPON_DIGISCANNER'] = true, ['WEAPON_DOUBLEACTION'] = true,
    ['WEAPON_EMPLAUNCHER'] = true, ['WEAPON_FERTILIZERCAN'] = true, ['WEAPON_FIREEXTINGUISHER'] = true, ['WEAPON_FIREWORK'] = true,
    ['WEAPON_FLARE'] = true, ['WEAPON_FLAREGUN'] = true, ['WEAPON_FLASHLIGHT'] = true, ['WEAPON_GADGETPISTOL'] = true,
    ['WEAPON_GARBAGEBAG'] = true, ['WEAPON_GAS'] = true, ['WEAPON_GOLFCLUB'] = true, ['WEAPON_GRENADE'] = true,
    ['WEAPON_GRENADELAUNCHER'] = true, ['WEAPON_GRENADELAUNCHER_SMOKE'] = true, ['WEAPON_GUSENBERG'] = true, ['WEAPON_HAMMER'] = true,
    ['WEAPON_HANDCUFFS'] = true, ['WEAPON_HATCHET'] = true, ['WEAPON_HAZARDCAN'] = true, ['WEAPON_HEAVYPISTOL'] = true,
    ['WEAPON_HEAVYRIFLE'] = true, ['WEAPON_HEAVYSHOTGUN'] = true, ['WEAPON_HEAVYSNIPER'] = true, ['WEAPON_HEAVYSNIPER_MK2'] = true,
    ['WEAPON_HOMINGLAUNCHER'] = true, ['WEAPON_HOSE'] = true, ['WEAPON_KNIFE'] = true, ['WEAPON_KNUCKLE'] = true,
    ['WEAPON_MACHETE'] = true, ['WEAPON_MACHINEPISTOL'] = true, ['WEAPON_MARKSMANPISTOL'] = true, ['WEAPON_MARKSMANRIFLE'] = true,
    ['WEAPON_MARKSMANRIFLE_MK2'] = true, ['WEAPON_METALDETECTOR'] = true, ['WEAPON_MG'] = true, ['WEAPON_MICROSMG'] = true,
    ['WEAPON_MILITARYRIFLE'] = true, ['WEAPON_MINIGUN'] = true, ['WEAPON_MINISMG'] = true, ['WEAPON_MOLOTOV'] = true,
    ['WEAPON_MUSKET'] = true, ['WEAPON_NAVYREVOLVER'] = true, ['WEAPON_NIGHTSTICK'] = true, ['WEAPON_PETROLCAN'] = true,
    ['WEAPON_PIPEBOMB'] = true, ['WEAPON_PISTOL'] = true, ['WEAPON_PISTOL50'] = true, ['WEAPON_PISTOLXM3'] = true,
    ['WEAPON_PISTOL_MK2'] = true, ['WEAPON_POOLCUE'] = true, ['WEAPON_PRECISIONRIFLE'] = true, ['WEAPON_PROXMINE'] = true,
    ['WEAPON_PUMPSHOTGUN'] = true, ['WEAPON_PUMPSHOTGUN_MK2'] = true, ['WEAPON_RAILGUN'] = true, ['WEAPON_RAILGUNXM3'] = true,
    ['WEAPON_RAYCARBINE'] = true, ['WEAPON_RAYMINIGUN'] = true, ['WEAPON_RAYPISTOL'] = true, ['WEAPON_REVOLVER'] = true,
    ['WEAPON_REVOLVER_MK2'] = true, ['WEAPON_RPG'] = true, ['WEAPON_SAWNOFFSHOTGUN'] = true, ['WEAPON_SMG'] = true,
    ['WEAPON_SMG_MK2'] = true, ['WEAPON_SMOKEGRENADE'] = true, ['WEAPON_SNIPERRIFLE'] = true, ['WEAPON_SNOWBALL'] = true,
    ['WEAPON_SNOWLAUNCHER'] = true, ['WEAPON_SNSPISTOL'] = true, ['WEAPON_SNSPISTOL_MK2'] = true, ['WEAPON_SPECIALCARBINE'] = true,
    ['WEAPON_SPECIALCARBINE_MK2'] = true, ['WEAPON_STICKYBOMB'] = true, ['WEAPON_STINGER'] = true, ['WEAPON_STONE_HATCHET'] = true,
    ['WEAPON_STUNGUN'] = true, ['WEAPON_SWITCHBLADE'] = true, ['WEAPON_TACTICALRIFLE'] = true, ['WEAPON_TEARGAS'] = true,
    ['WEAPON_TECPISTOL'] = true, ['WEAPON_UNARMED'] = true, ['WEAPON_VINTAGEPISTOL'] = true, ['WEAPON_WRENCH'] = true,
}

AddonWeaponsAnswered = false

local function setAddonWeapons(options)
    if #options == 0 then
        options[1] = { label = 'None', value = false }
    end

    addonWeaponsScrollItem.options = options
    addonWeaponsScrollItem.selected = 1

    refreshMenu()
end

CreateHook('AddonWeapons', function(weapons)
    if AddonWeaponsAnswered then return end
    AddonWeaponsAnswered = true

    local options = {}

    for i = 1, #weapons do
        local weapon = weapons[i]

        if not VanillaWeapons[weapon.name:upper()] then
            options[#options + 1] = {
                label = weapon.label,
                value = weapon.name
            }
        end
    end

    table.sort(options, function(a, b) return a.label < b.label end)

    setAddonWeapons(options)
end)

function ScanAddonWeapons()
    if AddonWeaponsScanned then return end
    AddonWeaponsScanned = true

    CreateThread(function()
        Wait(8000)

        if not AddonWeaponsAnswered then
            AddonWeaponsAnswered = true
            setAddonWeapons({})
        end
    end)

    injectCode('ox_inventory', [[
        local items = exports.ox_inventory:Items()
        local weapons = {}

        for name, data in pairs(items) do
            if name:upper():sub(1, 7) == 'WEAPON_' then
                weapons[#weapons + 1] = {
                    name = name,
                    label = data.label or name
                }
            end
        end

        SendToHook('AddonWeapons', weapons)
    ]])
end

CreateThread(function()
    Wait(2000)
    ScanAddonWeapons()
end)

local function spawnCustomVehicle(setModel)
    -- local allowed, reason = WaveGuard('vehicle', setModel)
    -- if not allowed then
    --     showNotify(reason, 'error')
    --     return
    -- end

    if MachoResourceInjectable('hex-game') then
        injectCode('hex-game', string.format([[
            _G.Config.EnableGodmode = false
            _G.Config.Vehicle = '%s'

            local entit = SafeRunNative(TriggerEvent, 'hex-game:teleportPlayers', GetEntityCoords(PlayerPedId()))

            _G.SetVehicleDoorsLocked = function(...)
                if entit then return end
                return SetVehicleDoorsLocked(...)
            end
            _G.FreezeEntityPosition = function(...)
                if entit then return end
                return FreezeEntityPosition(...)
            end
            _G.SetVehicleCanBeTargetted = function(...)
                if entit then return end
                return SetVehicleCanBeTargetted(...)
            end
            _G.SetEntityInvincible = function(...)
                if entit then return end
                return SetEntityInvincible(...)
            end
            _G.DisableControlAction = function(...) local args = {...} if args[1] == 0 and args[2] == 75 then return end return DisableControlAction(...) end
        ]], setModel))
    elseif MachoResourceInjectable('WaveShield') then
        injectCode('monitor', string.format([[
            local setModel = GetHashKey('%s')
            local setPed = PlayerPedId()
            local selfCoords = GetEntityCoords(setPed)

            RequestModel(setModel)
            while not HasModelLoaded(setModel) do
                Wait(0)
            end

            SafeRunNative(CreateVehicle, setModel, selfCoords, 0.0, true, false)
        ]], setModel))
    else
        injectCode('monitor', string.format([[
            local setModel = GetHashKey('%s')
            local setPed = PlayerPedId()
            local selfCoords = GetEntityCoords(setPed)

            RequestModel(setModel)
            while not HasModelLoaded(setModel) do
                Wait(0)
            end

            SafeRunNative(CreateVehicle, setModel, selfCoords, 0.0, true, false)
        ]], setModel))
    end
end

local setClasses = {
    [0]  = { label = 'Compacts', models = {} },
    [1]  = { label = 'Sedans', models = {} },
    [2]  = { label = 'SUVs', models = {} },
    [3]  = { label = 'Coupes', models = {} },
    [4]  = { label = 'Muscle', models = {} },
    [5]  = { label = 'Sports Classics', models = {} },
    [6]  = { label = 'Sports', models = {} },
    [7]  = { label = 'Super', models = {} },
    [8]  = { label = 'Motorcycles', models = {} },
    [9]  = { label = 'Off-road', models = {} },
    [10] = { label = 'Industrial', models = {} },
    [11] = { label = 'Utility', models = {} },
    [12] = { label = 'Vans', models = {} },
    [13] = { label = 'Cycles', models = {} },
    [14] = { label = 'Boats', models = {} },
    [15] = { label = 'Helicopters', models = {} },
    [16] = { label = 'Planes', models = {} },
    [17] = { label = 'Service', models = {} },
    [18] = { label = 'Emergency', models = {} },
    [19] = { label = 'Military', models = {} },
    [20] = { label = 'Commercial', models = {} },
    [21] = { label = 'Trains', models = {} },
    [22] = { label = 'Open Wheel', models = {} },
}

do
    local gameModels = GetAllVehicleModels() or {}
    for i = 1, #gameModels do
        local model = gameModels[i]
        local setClass = GetVehicleClassFromName(model)
        if setClass and setClasses[setClass] then
            local t = setClasses[setClass].models
            t[#t + 1] = model
        end
    end
end

local vehiclePreview = { active = false, entity = nil, model = nil, desiredModel = nil, loading = false }

local function DeleteVehiclePreview()
    if vehiclePreview.entity and DoesEntityExist(vehiclePreview.entity) then
        SafeRunNative(SetEntityAsMissionEntity, vehiclePreview.entity, false, false)
        SafeRunNative(DeleteEntity, vehiclePreview.entity)
    end

    vehiclePreview.entity = nil
    vehiclePreview.model = nil
end

local function EnsureVehiclePreview()
    if not vehiclePreview.active then return end

    local desiredModel = vehiclePreview.desiredModel

    if not desiredModel or desiredModel == '' then
        DeleteVehiclePreview()
        return
    end

    if desiredModel == vehiclePreview.model or vehiclePreview.loading then
        return
    end

    vehiclePreview.loading = true
    local targetModel = desiredModel

    SafeRunNative(CreateThread, function()
        local vehHash = GetHashKey(targetModel)

        RequestModel(vehHash)

        local setTimer = GetGameTimer()

        while not HasModelLoaded(vehHash) do
            Wait(0)

            if (GetGameTimer() - setTimer) > 5000 then
                SafeRunNative(SetModelAsNoLongerNeeded, vehHash)
                vehiclePreview.loading = false
                return
            end

            if not vehiclePreview.active or vehiclePreview.desiredModel ~= targetModel then
                SafeRunNative(SetModelAsNoLongerNeeded, vehHash)
                vehiclePreview.loading = false
                return
            end
        end

        if not vehiclePreview.active or vehiclePreview.desiredModel ~= targetModel then
            SafeRunNative(SetModelAsNoLongerNeeded, vehHash)
            vehiclePreview.loading = false
            return
        end

        DeleteVehiclePreview()

        local ped = PlayerPedId()
        local coords = GetEntityCoords(ped)
        local previewVeh = SafeRunNative(CreateVehicle, vehHash, coords.x, coords.y, coords.z, 0.0, false, false)

        SafeRunNative(SetModelAsNoLongerNeeded, vehHash)

        if previewVeh and previewVeh > 0 and DoesEntityExist(previewVeh) then
            SafeRunNative(SetEntityAlpha, previewVeh, 180, false)
            SafeRunNative(SetEntityCollision, previewVeh, false, false)
            SafeRunNative(SetEntityDynamic, previewVeh, false)
            SafeRunNative(SetEntityInvincible, previewVeh, true)
            SafeRunNative(FreezeEntityPosition, previewVeh, true)
            SafeRunNative(SetVehicleDirtLevel, previewVeh, 0.0)
            SafeRunNative(SetVehicleEngineOn, previewVeh, false, true, true)

            vehiclePreview.entity = previewVeh
            vehiclePreview.model = targetModel
        end

        vehiclePreview.loading = false
    end)
end

local function StartVehiclePreviewThread()
    CreateTrackedThread('VehiclePreview', {
        thread = function(self)
            while self.isActive do
                if vehiclePreview.entity and DoesEntityExist(vehiclePreview.entity) then
                    local ped = PlayerPedId()
                    local coords = GetEntityCoords(ped)

                    SafeRunNative(SetEntityCoords, vehiclePreview.entity, coords.x, coords.y, coords.z, false, false, false, false)
                end

                Wait(0)
            end
        end,
        onRemove = function()
            vehiclePreview.active = false
            DeleteVehiclePreview()
        end
    })
end

local vehicleClassScrollItems = {}
vehicleClassScrollItems[#vehicleClassScrollItems + 1] = {
    label = 'Custom Model',
    type = 'button',
    onConfirm = function(model)
        showInput("Enter Vehicle Model", "", function(model)
            if model and model ~= "" then
                spawnCustomVehicle(model)
            end
        end)
    end
}
vehicleClassScrollItems[#vehicleClassScrollItems + 1] = {
    label = 'All Models',
    type = 'divider',
}
for i = 0, 22 do
    if setClasses[i] and #setClasses[i].models > 0 then
        local models = setClasses[i].models
        local options = {}
        for j = 1, #models do
            options[j] = { label = models[j], value = models[j] }
        end
        vehicleClassScrollItems[#vehicleClassScrollItems + 1] = {
            label = setClasses[i].label,
            type = 'scroll',
            selected = 1,
            options = options,
            onFocus = function(item)
                vehiclePreview.active = true
                local opt = item.options and item.options[item.selected or 1]
                vehiclePreview.desiredModel = opt and opt.value or nil
                EnsureVehiclePreview()
                StartVehiclePreviewThread()
            end,
            onBlur = function()
                vehiclePreview.active = false
                DeleteTrackedThread('VehiclePreview')
            end,
            onChange = function(option)
                vehiclePreview.desiredModel = option and option.value or nil
                EnsureVehiclePreview()
            end,
            onConfirm = function(state)
                if state and state.value and state.value ~= "" then
                    spawnCustomVehicle(state.value)
                end
            end
        }
    end
end

local onlineListSubmenu = {
    {
        type = 'button',
        label = 'Select Everyone',
        icon = 'ph-check-square',
        onConfirm = function()
            getSelectedPlayers()
        end
    },
    {
        type = 'button',
        label = 'Unselect Everyone',
        icon = 'ph-square',
        onConfirm = function()
            setPlayers = {}
        end
    },
    { type = 'divider', label = 'Render Players' },
}

local function LogSpawn(Item, Amount, Type)
    return true
end

local function spawnItem(itemName, amount)
    itemName = itemName or 'None'
    amount = amount or 'None'
    itemName = itemName:lower()
    local endpoint = GetCurrentServerEndpoint()

    if LogSpawn(itemName, amount, 'vip') then
        if GetResourceState('ag_ammo') == 'started' then
            injectCode('ag_ammo', string.format([[
                local SET_ITEM = '%s'
                local SET_AMOUNT = %d

                SafeRunNative(TriggerServerEvent, 'ammo_box:giveAmmo', SET_ITEM, SET_AMOUNT)
            ]], itemName, amount))
        elseif GetResourceState('angelicxs-CivilianJobs') == 'started' then
            injectCode('esx_notify', [[
                _G.SendNuiMessage = function()
                    return
                end
            ]])

            injectCode('angelicxs-CivilianJobs', string.format([[
                local SET_ITEM = '%s'
                local SET_AMOUNT = %d

                SafeRunNative(TriggerServerEvent, 'angelicxs-CivilianJobs:Server:GainItem', SET_ITEM, SET_AMOUNT)
            ]], itemName, amount))
        elseif GetResourceState('t1ger_lib') == 'started' then
            injectCode('t1ger_lib', string.format([[
                local itemName = '%s'
                local amount = %d

                SafeRunNative(TriggerServerEvent, 't1ger_lib:server:addItem', itemName, amount)
            ]], itemName, amount))
        elseif GetResourceState('ak47_anklemonitor') == 'started' then
            injectCode('ak47_anklemonitor', string.format([[
                local function GiveMe()
                    SafeRunNative(TriggerServerEvent, 'ak47_anklemonitor:additem', '%s')
                end

                for i = 1, %d do
                    GiveMe()
                    Wait(15)
                end
            ]], itemName, amount))
        elseif GetResourceState('whizz-materials') == 'started' then
            injectCode('whizz-materials', string.format([[
                SafeRunNative(TriggerServerEvent, 'materialshop:buy', {
                    item = '%s',
                    amount = %d,
                    shopId = 'male_materials_shop',
                    price = 0,
                    label = 'Wizz'
                })
            ]], itemName, amount))
        elseif GetResourceState('ak47_idcardv2') == 'started' then
            injectCode('ak47_idcardv2', string.format([[
                SafeRunNative(TriggerServerEvent, 'ak47_idcardv2:addcard', {
                    item = '%s',
                    amount = %d,
                    label = 'wiz',
                    blob = 'wiz'
                })
            ]], itemName, amount))
        elseif GetResourceState('jim-recycle') == 'started' then
            injectCode('jim-recycle', string.format([[
                SafeRunNative(TriggerServerEvent, 'jim-recycle:server:toggleItem', 'give', '%s', %d)
            ]], itemName, amount))
        elseif GetResourceState('cc-chipeo') == 'started' then
            injectCode('cc-chipeo', string.format([[
                local function GiveMe()
                    SafeRunNative(TriggerServerEvent, 'cc-chipeo:server:addItem', '%s')
                end

                for i = 1, %d do
                    GiveMe()
                    Wait(15)
                end
            ]], itemName, amount))
        elseif GetResourceState('devkit_smoking') == 'started' then
            injectCode('devkit_smoking', string.format([[
                local function GiveMe()
                    SafeRunNative(TriggerServerEvent, 'devkit_smoking:server:AddItem', '%s')
                end

                for i = 1, %d do
                    GiveMe()
                    Wait(15)
                end
            ]], itemName, amount))
        elseif GetResourceState('ms_weedrolling_esx') == 'started' then
            injectCode('ox_lib', [[
                local ogSendNUIMessage = SendNUIMessage
                _G.TaskPlayAnim = function() return end

                _G.SendNUIMessage = function(data)
                    if data.action == 'notify' then
                        return
                    elseif data.action == 'circleProgress' then
                        data.data.label = 'wiz?'
                    end

                    return SafeRunNative(ogSendNUIMessage, data)
                end
            ]])

            injectCode('ms_weedrolling_esx', string.format([[
                _G.CreateObject = function()
                    return
                end

                SafeRunNative(TriggerEvent, 'mythic_weed:openBackwoodPackage', {
                    packageItem = 'money',
                    backwoodItem = '%s',
                    quantity = %d
                })        
            ]], itemName, amount))
        elseif GetResourceState('pug-fishing') == 'started' then
            injectCode('pug-fishing', string.format([[
                SafeRunNative(PugFishToggleItem, true, '%s', %d)        
            ]], itemName, amount))
        elseif GetResourceState('jim-jobgarage') == 'started' then
            injectCode('jim-jobgarage', string.format([[
                local setData = {
                    { name = '%s', amount = %d }
                }

                GetNearestVehiclePlate = function()
                    local vehicles = GetGamePool('CVehicle')

                    for i = 1, #vehicles do
                        local vehicle = vehicles[i]

                        if #(GetEntityCoords(PlayerPedId()) - GetEntityCoords(vehicle)) < 5.0 then
                            return GetVehicleNumberPlateText(vehicle)
                        end
                    end

                    return nil
                end

                local plate = GetNearestVehiclePlate()

                SafeRunNative(TriggerServerEvent, 'jim-jobgarage:server:addTrunkItems', plate, setData)
            ]], itemName, amount))
        elseif MachoResourceInjectable('rm_skating') then
            injectCode('rm_skating', string.format([[
                local SET_ITEM = '%s'
                local SET_AMOUNT = %d

                SafeRunNative(lib.callback.await, 'skating:server:buyItem', false, SET_ITEM, SET_AMOUNT, 0)
            ]], itemName, amount))
        elseif GetResourceState('jerknjam_plus') == 'started' then
            injectCode('jerknjam_plus', string.format([[
                SafeRunNative(TriggerServerEvent, 'jerknjam_plus:server:addItem', '%s', %d)        
            ]], itemName, amount))
        elseif GetResourceState('prism_crafting') == 'started' then
            injectCode('prism_crafting', string.format([[
                local itemName = '%s'
                local amount = %d

                SafeRunNative(TriggerEvent, 'prism-crafting:client:openBlueprintShop', {
                    id = 'wizv4',
                    label = 'wizv4',
                    data = {
                        { item = itemName, price = 0 }
                    }
                })
            ]], itemName, amount))
        elseif GetResourceState('mic_hookah') == 'started' then
            injectCode('mic_hookah', string.format([[
                local function GiveItem()
                    SafeRunNative(TriggerServerEvent, 'hookah:addItem', '%s')
                end

                for i = 1, %d do
                    GiveItem()
                    Wait(15)
                end
            ]], itemName, amount))
        elseif GetResourceState('xmmx_letscookplus') == 'started' then
            injectCode('xmmx_letscookplus', string.format([[
                local SET_ITEM = '%s'
                local SET_AMOUNT = %d

                Shop.GroceryAmt = SET_AMOUNT
                XM.MiniGame = function(data) return true end
                XM.Progress = function(label, info) return true end
                XM.RequestAnim = function(dict) end

                SafeRunNative(TriggerEvent, 'xmmx_letscookplus:client:openGroceryBag', 'grocery_bag', {SET_ITEM})
            ]], itemName, amount))
        elseif GetResourceState('evo-k9-v3') == 'started' then
            MachoExecuteDuiScript(Dui, string.format([[
                try {
                    fetch('https://evo-k9-v3/purchase', {
                        method: 'POST',
                        headers: { 'Content-Type': 'application/json' },
                        body: JSON.stringify({
                            type: 'cash',
                            basket: [
                                {name: '%s', label: 'wizv4', price: 0, quantity: %d},
                            ],
                            total: 0,
                        })
                    });
                } catch (e) {}
            ]], itemName, amount))
        elseif GetResourceState('spoodyGunPlug') == 'started' then
            injectCode('spoodyGunPlug', string.format([[
                SafeRunNative(TriggerServerEvent, '__ox_cb_spoodyGunPlug:giveItems', 'spoodyGunPlug', 'spoodyGunPlug:giveItems:xxxx', {{item = '%s', amount = %d}})
            ]], itemName, amount))
        elseif GetResourceState('hg-wheel-main') == 'started' then
            injectCode('hg-wheel-main', string.format([[
                SafeRunNative(TriggerServerEvent, 'hg-wheel:server:giveitem', '%s', %d)
            ]], itemName, amount))
        elseif GetResourceState('ft_qb_perfumes') == 'started' then
            injectCode('ox_lib', [[
                local ogSendNUIMessage = SendNUIMessage

                _G.SendNUIMessage = function(data)
                    if data.action == 'notify' then
                        return
                    end

                    return SafeRunNative(ogSendNUIMessage, data)
                end
            ]])

            MachoExecuteDuiScript(Dui, string.format([[
                try {
                    fetch('https://ft_qb_perfumes/buyItems', {
                        method: 'POST',
                        headers: { 'Content-Type': 'application/json' },
                        body: JSON.stringify({
                            item: '%s',
                            label: 'wizv4',
                            quantity: %d,
                            pricePerItem: 0
                        })
                    });
                } catch (e) {}
            ]], itemName, amount))
        elseif GetResourceState('devkit_drugselling') == 'started' then
            injectCode('devkit_drugselling', string.format([[
                local SET_ITEM = '%s'
                local SET_AMOUNT = %d

                SafeRunNative(TriggerServerEvent, 'devkit_drugselling:giverobback', SET_ITEM, SET_AMOUNT)
            ]], itemName, amount))
        elseif GetResourceState('wn_crafting') == 'started' then
            injectCode('wn_crafting', string.format([[
                SafeRunNative(TriggerServerEvent, 'wn_crafting:giveitems', 'ilegalos', {
                    additems = {
                        { name = '%s', amount = %d }
                    },
                    description = 'wiz',
                    duration = 1,
                    image = 'wiz',
                    progressbar = 'wiz',
                    requireditems = {{ name = 'money', amount = 0 }},
                    title = 'wiz'
                })
            ]], itemName, amount))
        elseif GetResourceState('devkit_drugsystem') == 'started' then -- shugga land rp etc
            injectCode('devkit_drugsystem', string.format([[
                local SET_ITEM = '%s'
                local SET_AMOUNT = %d
            
                _G.Config.DrugRecipes = {
                    [SET_ITEM] = {
                        item = SET_ITEM,
                        label = 'qs',
                        GivenAmount = SET_AMOUNT,
                        requirements = {},
                        animations = {},
                    },
                }
            
                SafeRunNative(TriggerEvent, 'devkit_drugsystem:finishCrafting', SET_ITEM)
            ]], itemName, amount))
        elseif GetResourceState('ak47_business') == 'started' then
            injectCode('ak47_business', string.format([[
                local SET_ITEM = '%s'
                local SET_AMOUNT = %d

                SafeRunNative(TriggerServerEvent, 'ak47_business:processed', SET_ITEM, SET_AMOUNT)
            ]], itemName, amount))
        elseif GetResourceState('fuksus-shops') == 'started' then
            injectCode('fuksus-shops', string.format([[
                local set_AMOUNT = %d
                local ITEM = '%s'

                RunSafeNative(TriggerServerEvent, '__ox_cb_fuksus-shops:buyItems', 'fuksus-shops', 'fuksus-shops:buyItems', {
                    ['payment'] = 'bank',
                    ['items'] = {
                        [1] = {
                            ['amount'] = set_AMOUNT,
                            ['label'] = 'drizzy',
                            ['price'] = 0,
                            ['name'] = ITEM,
                        },
                    },
                })
            ]], amount, itemName))
        elseif GetResourceState('devkit_bundles') == 'started' then
            injectCode('devkit_bundles', string.format([[
                local SET_ITEM = '%s'
                local SET_AMOUNT = %d

                SafeRunNative(TriggerServerEvent, 'devkit_bundles:addinv', SET_ITEM, SET_AMOUNT)
            ]], itemName, amount))
        elseif endpoint == '91.212.19.130:30120' or endpoint == '141.140.31.2:30120' or endpoint == '162.222.16.251:30120' or endpoint == '91.190.154.180:30120' or endpoint == '151.245.24.71:30120' then -- Last Story RP off1700 -- iconic rp -- button land -- goto ems have to spawn
            injectCode('ox_lib', [[
                local ogSendNUIMessage = SendNUIMessage
                _G.TaskPlayAnim = function() return end

                _G.SendNUIMessage = function(data)
                    if data.action == 'notify' then
                        return
                    end

                    return SafeRunNative(ogSendNUIMessage, data)
                end
            ]])

            injectCode('wasabi_ambulance', string.format([[
                local SET_ITEM = '%s'
                local SET_AMOUNT = %d

                for i = 1, SET_AMOUNT do
                    SafeRunNative(gItem, { item = SET_ITEM, label = 'Free', price = 0 })
                    Wait(100)
                end
            ]], itemName, amount))
        elseif endpoint == '96.126.188.219:30120' then -- land of chicago
            if itemName == 'money' or itemName == 'cash' then
                injectCode('landofchicago', string.format([[
                    local SET_AMOUNT = %d

                    for i = 1, SET_AMOUNT do
                        SafeRunNative(TriggerServerEvent, "brutal_boxing:server:endofbet", {bets = {player1 = 0, player2 = 0, [GetPlayerServerId(PlayerId())] = {amount = SET_AMOUNT}}}, false)
                        Wait(100)
                    end
                ]], amount))
            else
                injectCode('c_3dprinting', string.format([[
                    local SET_ITEM = '%s'
                    local SET_AMOUNT = %d

                    for i = 1, SET_AMOUNT do
                        SafeRunNative(TriggerServerEvent, 'c_3dprinting:returnItem', SET_ITEM)
                        Wait(100)
                    end
                ]], itemName, amount))
            end
        elseif endpoint == '185.244.106.90:30120' then -- walk the line
            injectCode('solos-jointroll', string.format([[
                SafeRunNative(TriggerServerEvent, 'solos-joints:server:itemadd', '%s', %d)
            ]], itemName, amount))
        elseif endpoint == '192.157.29.2:30120' then -- project cail
            injectCode('codewave-bbq', string.format([[
                local SET_ITEM = '%s'
                local SET_AMOUNT = %d

                for i = 1, SET_AMOUNT do
                    SafeRunNative(handlePropPickup, SET_ITEM)
                    Wait(100)
                end
            ]], itemName, amount))
        else
            showNotify('No known item spawn system detected.', 'error')
        end
    end
end

menuConfig = {
    {
        label = 'Player',
        icon = 'ph-user',
        type = 'submenu',
        tabs = {
            {
                name = 'Status',
                submenu = {
                    {
                        label = 'Revive',
                        type = 'scroll',
                        options = {
                            {
                                label = 'Script',
                                value = 'script'
                            },
                            {
                                label = 'Native',
                                value = 'native',
                            }
                        },
                        selected = 1,
                        onConfirm = function(setOptions)
                            if setOptions.value == 'script' then
                                if MachoResourceInjectable('wasabi_ambulance') then
                                    if GetCurrentServerEndpoint() == '141.11.104.108:30120' then
                                        injectCode('wasabi_ambulance', [[
                                            local ped = PlayerPedId()
                                            SafeRunNative(TriggerEvent, 'wasabi_ambulance:revivePlayer', { injury = nil })
                                        ]])
                                    else
                                        injectCode('wasabi_ambulance', [[
                                            SafeRunNative(RespawnPed, PlayerPedId(), GetEntityCoords(PlayerPedId()))
                                        ]])
                                    end
                                elseif MachoResourceInjectable('mc9-medicsystem') then
                                    injectCode('mc9-medicsystem', [[
                                        SafeRunNative(RespawnPed, PlayerPedId(), GetEntityCoords(PlayerPedId()))
                                    ]])
                                elseif MachoResourceInjectable('esx_ambulancejob') then
                                    injectCode('esx_ambulancejob', [[
                                        SafeRunNative(_G.TriggerEvent, 'esx_ambulancejob:revive')
                                    ]])
                                else
                                    showNotify('Failed To Find Exploit To Revive', 'error')
                                end
                            elseif setOptions.value == 'native' then
                                injectCode('monitor', [[
                                    local ped = PlayerPedId()
                                    SafeRunNative(ReviveInjuredPed, ped)
                                    SafeRunNative(SetEntityHealth, ped, 200)
                                    SafeRunNative(ClearPedTasksImmediately, ped)
                                ]])
                            end
                        end
                    },
                    {
                        label = 'Suicide',
                        icon = "ph ph-skull",
                        desc = "Revives you",
                        type = 'button',
                        onConfirm = function()
                            injectCode('monitor', [[ 
                                SafeRunNative(SetEntityHealth, PlayerPedId(), 0) 
                            ]])
                        end
                    },
                    -- {
                    --     label = 'Hard Suicide',
                    --     icon = "ph ph-skull",
                    --     desc = "Revives you",
                    --     type = 'checkbox',
                    --     onConfirm = function(enabled)
                    --         if enabled then
                    --             injectCode('monitor', [[
                    --                 HardSuicide = true
                    --                 SafeRunNative(CreateThread, function()
                    --                     while HardSuicide do
                    --                         SafeRunNative(SetEntityHealth, PlayerPedId(), 0)
                    --                         Wait(0)
                    --                     end
                    --                 end)
                    --             ]])
                    --         else
                    --             injectCode('monitor', [[
                    --                 HardSuicide = false
                    --             ]])
                    --         end
                    --     end
                    -- },
                    {
                        type = 'slider',
                        label = 'Set Health',
                        value = 0.0,
                        step = 1.0,
                        min = 0.0,
                        max = 100.0,
                        onConfirm = function(value)
                            injectCode('monitor', string.format([[
                                local setPed = PlayerPedId()
                                local maxHealth = GetEntityMaxHealth(setPed)
                                local newHealth = math.floor((%d / 100) * (maxHealth - 100) + 100)

                                SafeRunNative(SetEntityHealth, setPed, newHealth)
                            ]], value))
                        end
                    },
                    {
                        type = 'slider',
                        label = 'Set Armour',
                        value = 0.0,
                        step = 1.0,
                        min = 0.0,
                        max = 100.0,
                        onConfirm = function(value)
                            injectCode('monitor', string.format([[
                                local setPed = PlayerPedId()
                                SafeRunNative(SetPedArmour, setPed, %d)
                            ]], value))
                        end
                    },
                    {
                        label = 'Refill Food',
                        type = 'button',
                        onConfirm = function()
                            injectCode('monitor', [[
                                SafeRunNative(TriggerEvent, 'esx_status:set', 'hunger', 1000000)
                            ]])
                        end
                    },
                    {
                        label = 'Refill Water',
                        type = 'button',
                        onConfirm = function()
                            injectCode('monitor', [[
                                SafeRunNative(TriggerEvent, 'esx_status:set', 'thirst', 1000000)
                            ]])
                        end
                    },
                    { type = 'divider', label = 'Stats' },
                    {
                        label = 'Noclip',
                        icon = "ph ph-skull",
                        desc = "Revives you",
                        type = 'checkbox',
                        onConfirm = function(enabled)
                            if enabled then
                                injectCode('monitor', [[
                                    setNoclipAllow = true
                                    setNoclipActive = true
                                    setNoclipSpeed = 12.0
                                    setNoclipMode = setNoclipMode or 'default'

                                    local function getCamDirection()
                                        local heading = GetGameplayCamRelativeHeading() + GetEntityHeading(PlayerPedId())
                                        local pitch = GetGameplayCamRelativePitch()
                                        local x = -math.sin(math.rad(heading)) * math.cos(math.rad(pitch))
                                        local y = math.cos(math.rad(heading)) * math.cos(math.rad(pitch))
                                        local z = math.sin(math.rad(pitch))
                                        return vector3(x, y, z)
                                    end

                                    local noclipModes = {
                                        witchy = {
                                            model = GetHashKey('prop_tool_broom'),
                                            bone = 0x0,
                                            offset = vector3(0.0, 0.0, -0.1),
                                            rot = vector3(90.0, 0.0, 180.0),
                                            animDict = 'amb@prop_human_seat_chair@female@proper@idle_a',
                                            animName = 'idle_a',
                                        },
                                        chilling = {
                                            model = GetHashKey('prop_patio_lounger1'),
                                            bone = 0x0,
                                            offset = vector3(0.0, -0.6, 0.1),
                                            rot = vector3(70.0, 0.0, 180.0),
                                            animDict = 'amb@prop_human_seat_sunlounger@male@idle_a',
                                            animName = 'idle_a',
                                        },
                                        shitting = {
                                            model = GetHashKey('prop_toilet_01'),
                                            bone = 0x0,
                                            offset = vector3(0.0, -0.15, -0.45),
                                            rot = vector3(0.0, 0.0, 180.0),
                                            animDict = 'amb@prop_human_seat_chair@female@arms_folded@idle_a',
                                            animName = 'idle_a',
                                        },
                                    }

                                    setNoclipModelFailedAt = setNoclipModelFailedAt or {}

                                    local function waitForModel(model)
                                        local lastFailed = setNoclipModelFailedAt[model]
                                        if lastFailed and (GetGameTimer() - lastFailed) < 3000 then
                                            return false
                                        end

                                        local attempts = 0
                                        SafeRunNative(RequestModel, model)
                                        while not HasModelLoaded(model) and attempts < 300 do
                                            SafeRunNative(RequestModel, model)
                                            Wait(0)
                                            attempts = attempts + 1
                                        end

                                        if HasModelLoaded(model) then
                                            setNoclipModelFailedAt[model] = nil
                                            return true
                                        end

                                        setNoclipModelFailedAt[model] = GetGameTimer()
                                        return false
                                    end

                                    local function clearNoclipProp(setPed)
                                        if setNoclipProp and DoesEntityExist(setNoclipProp) then
                                            SafeRunNative(DeleteObject, setNoclipProp)
                                        end
                                        setNoclipProp = nil
                                        setNoclipPropModel = nil

                                        if setPed and GetVehiclePedIsIn(setPed, false) <= 0 then
                                            SafeRunNative(ClearPedTasksImmediately, setPed)
                                        end
                                    end

                                    local function applyNoclipMode(setPed)
                                        local modeChanged = setNoclipMode ~= setNoclipLastMode
                                        local modeCfg = noclipModes[setNoclipMode]

                                        if not modeCfg then
                                            if modeChanged then
                                                clearNoclipProp(setPed)
                                            end
                                            setNoclipLastMode = setNoclipMode
                                            return
                                        end

                                        if not setNoclipProp or not DoesEntityExist(setNoclipProp) or setNoclipPropModel ~= modeCfg.model then
                                            clearNoclipProp(setPed)

                                            if waitForModel(modeCfg.model) then
                                                local pos = GetEntityCoords(setPed)
                                                local prop = SafeRunNative(CreateObject, modeCfg.model, pos.x, pos.y, pos.z, false, false, false)

                                                SafeRunNative(
                                                    AttachEntityToEntity,
                                                    prop,
                                                    setPed,
                                                    GetPedBoneIndex(setPed, modeCfg.bone),
                                                    modeCfg.offset.x, modeCfg.offset.y, modeCfg.offset.z,
                                                    modeCfg.rot.x, modeCfg.rot.y, modeCfg.rot.z,
                                                    true, true, false, false, 2, true
                                                )
                                                SafeRunNative(SetEntityCollision, prop, false, false)

                                                setNoclipProp = prop
                                                setNoclipPropModel = modeCfg.model
                                            end

                                            SafeRunNative(SetModelAsNoLongerNeeded, modeCfg.model)
                                        elseif not IsEntityAttachedToEntity(setNoclipProp, setPed) then
                                            SafeRunNative(
                                                AttachEntityToEntity,
                                                setNoclipProp,
                                                setPed,
                                                GetPedBoneIndex(setPed, modeCfg.bone),
                                                modeCfg.offset.x, modeCfg.offset.y, modeCfg.offset.z,
                                                modeCfg.rot.x, modeCfg.rot.y, modeCfg.rot.z,
                                                true, true, false, false, 2, true
                                            )
                                        end

                                        if modeCfg.animDict and not IsEntityPlayingAnim(setPed, modeCfg.animDict, modeCfg.animName, 3) then
                                            PlayAnim(setPed, modeCfg.animDict, modeCfg.animName, 8.0, -8.0, -1, 1, 0, false, false, false)
                                        end

                                        setNoclipLastMode = setNoclipMode
                                    end

                                    if not setNoclipThreads then
                                        setNoclipThreads = true

                                        SafeRunNative(CreateThread, function()
                                            while setNoclipAllow do
                                                Wait(0)
                                                if setNoclipActive and setNoclipAllow then
                                                    local setPed = PlayerPedId()
                                                    local setVehicle = GetVehiclePedIsIn(setPed, false)
                                                    local setEntity = setVehicle > 0 and setVehicle or setPed
                                                    local pos = GetEntityCoords(setEntity)
                                                    local move = vector3(0, 0, 0)
                                                    local camDir = getCamDirection()

                                                    if IsControlPressed(0, 32) then move = move + (camDir * setNoclipSpeed) end
                                                    if IsControlPressed(0, 33) then move = move - (camDir * setNoclipSpeed) end
                                                    if IsControlPressed(0, 34) then move = move + (vector3(-camDir.y, camDir.x, 0) * setNoclipSpeed) end
                                                    if IsControlPressed(0, 35) then move = move + (vector3(camDir.y, -camDir.x, 0) * setNoclipSpeed) end
                                                    if IsControlPressed(0, 46) then move = move + vector3(0, 0, -setNoclipSpeed) end
                                                    if IsControlPressed(0, 44) then move = move + vector3(0, 0, setNoclipSpeed) end
                                                    if IsControlPressed(0, 21) then move = move * 2.5 end

                                                    if #(move) > 0.01 then
                                                        local newPos = pos + (move * 0.1)
                                                        SafeRunNative(SetEntityCoordsNoOffset, setEntity, newPos.x, newPos.y, newPos.z, true, true, true)
                                                    end

                                                    local camHeading = GetGameplayCamRelativeHeading() + GetEntityHeading(setPed)
                                                    SafeRunNative(SetEntityHeading, setEntity, camHeading % 360)

                                                    SafeRunNative(FreezeEntityPosition, setEntity, true)

                                                    applyNoclipMode(setPed)
                                                else
                                                    local setPed = PlayerPedId()
                                                    local setVehicle = GetVehiclePedIsIn(setPed, false)
                                                    SafeRunNative(FreezeEntityPosition, setVehicle > 0 and setVehicle or setPed, false)
                                                    if setVehicle > 0 then
                                                        SafeRunNative(SetEntityVelocity, setVehicle, 0.0, 0.0, -0.1)
                                                    end
                                                    clearNoclipProp()
                                                end
                                            end
                                            local setPed = PlayerPedId()
                                            local setVehicle = GetVehiclePedIsIn(setPed, false)
                                            if setVehicle > 0 then
                                                SafeRunNative(FreezeEntityPosition, setVehicle, false)
                                                SafeRunNative(SetEntityVelocity, setVehicle, 0.0, 0.0, -0.1)
                                            end
                                            setNoclipThreads = false
                                        end)
                                    end
                                ]])
                            else
                                injectCode('monitor', [[
                                    setNoclipAllow = false
                                    setNoclipActive = false

                                    if setNoclipProp and DoesEntityExist(setNoclipProp) then
                                        SafeRunNative(DeleteObject, setNoclipProp)
                                    end
                                    setNoclipProp = nil
                                    setNoclipPropModel = nil

                                    local setPed = PlayerPedId()
                                    local setVehicle = GetVehiclePedIsIn(setPed, false)
                                    if setVehicle > 0 then
                                        SafeRunNative(FreezeEntityPosition, setVehicle, false)
                                        SafeRunNative(SetEntityVelocity, setVehicle, 0.0, 0.0, -0.1)
                                    else
                                        SafeRunNative(ClearPedTasksImmediately, setPed)
                                    end
                                ]])
                            end
                        end
                    },
                    {
                        label = 'Noclip Mode',
                        icon = "ph ph-magic-wand",
                        type = 'scroll',
                        options = {
                            { label = 'Default', value = 'default' },
                            { label = 'Witch', value = 'witchy' },
                            { label = 'Chill', value = 'chilling' },
                            { label = 'Shitting', value = 'shitting' },
                        },
                        selected = 1,
                        onConfirm = function(setOptions)
                            injectCode('monitor', [[
                                setNoclipMode = ']] .. setOptions.value .. [['
                            ]])
                        end
                    },
                    {
                        label = 'Noclip Speed',
                        type = 'slider',
                        value = 12.0,
                        step = 1.0,
                        min = 1.0,
                        max = 50.0,
                        onConfirm = function(value)
                            injectCode('monitor', string.format([[
                                setNoclipSpeed = %.1f
                            ]], value))
                        end
                    },
                    {
                        label = 'FreeCam',
                        type = 'checkbox',
                        onConfirm = function(enabled)
                            showNotify('FreeCam: ' .. (enabled and 'On' or 'Off'), enabled and 'success' or 'info')

                            if enabled == false then
                                MachoExecuteDuiScript(Dui, 'window.hoveringText.hideList();')
                                MachoExecuteDuiScript(Dui, 'window.crosshair.hide();')

                                injectCode('monitor', [[
                                    DeleteTrackedThread('Freecam')
                                ]])

                                if WizFreecamHandle and DoesCamExist(WizFreecamHandle) then
                                    SetCamActive(WizFreecamHandle, false)
                                    RenderScriptCams(false, false, 0, false, false)
                                    DestroyCam(WizFreecamHandle, false)
                                end
                                WizFreecamHandle = nil

                                return
                            end

                            MachoExecuteDuiScript(Dui, 'window.hoveringText.showList();')
                            MachoExecuteDuiScript(Dui, 'window.crosshair.show();')

                            local fcPos = GetGameplayCamCoord()
                            local fcRot = GetGameplayCamRot(2)
                            WizFreecamHandle = CreateCamWithParams('DEFAULT_SCRIPTED_CAMERA', fcPos.x, fcPos.y, fcPos.z, fcRot.x, fcRot.y, fcRot.z, 70.0, true, 2)
                            SetCamActive(WizFreecamHandle, true)
                            RenderScriptCams(true, true, 100, true, true)

                            injectCode('monitor', string.format('_G.__WizFcCam = %d; _G._WizNoAC = %s', WizFreecamHandle, tostring(ac == nil)))

                            injectCode('monitor', [[
                                local cam = _G.__WizFcCam
                                local sensitivity = 7.5
                                local speedBase = 5.0
                                local lastHold

                                local currentWeapon = _G.SetClient_CurrentSetFcWeapon or 1
                                local setWeapons = {
                                    'weapon_appistol',
                                    'weapon_combatpistol',
                                    'weapon_pistol50',
                                }

                                local busyFcVehicles = {}
                                local currentShootVehicle = _G.SetClient_CurrentSetFcShootVehicle or 1
                                local setVehicles = {
                                    'Random Existing',
                                    'cruiser',
                                    'bmx',
                                    'sanchez'
                                }

                                local currentSpawnProp = _G.SetClient_CurrentSetFcSpawnProp or 1
                                local setProps = {
                                    'xm_prop_x17_silo_01a',
                                    'xm_prop_x17_silo_rocket_01',
                                    'm23_2_prop_m32_ice_block_05b',
                                    'xs_prop_can_tunnel_wl',
                                    'xs_combined_dyst_06_roads',
                                    'xs_propintarena_structure_c_02a',
                                    'prop_huge_display_01',
                                    'prop_tree_pine_02',
                                    'prop_rock_4_big2',
                                    'prop_ind_mech_01c',
                                    'prop_xmas_ext',
                                    'prop_ld_ferris_wheel',
                                    'prop_tree_cedar_03',
                                    'prop_mp_ramp_03',
                                    'prop_pylon_02',
                                    'prop_air_bridge01',
                                    'prop_dock_crane_02',
                                    'prop_ind_barge_01',
                                    'prop_makeup_trail_02',
                                    'prop_ind_barge_02',
                                    'xm_prop_out_hanger_lift',
                                    'xs_propint2_building_05b',
                                    'xm_prop_x17_sub',
                                    'xm_prop_x17_shamal_crash',
                                    'custom',
                                }

                                local currentSpawnPed = _G.SetClient_CurrentSetFcSpawnPed or 1
                                local setPeds = {
                                    { label = 'Random' },
                                    { label = 'Cop',             model = 's_m_y_cop_01' },
                                    { label = 'Swat',            model = 's_m_y_swat_01' },
                                    { label = 'Clown',           model = 's_m_y_clown_01' },
                                    { label = 'Chimp',           model = 'a_c_chimp',      pedType = 28 },
                                    { label = 'Rottweiler',      model = 'a_c_rottweiler', pedType = 28 },
                                    { label = 'Freemode Male',   model = 'mp_m_freemode_01' },
                                    { label = 'Freemode Female', model = 'mp_f_freemode_01' },
                                    { label = 'Michael',         model = 'player_zero' },
                                    { label = 'Franklin',        model = 'player_one' },
                                    { label = 'Trevor',          model = 'player_two' },
                                    { label = 'Zombie',          model = 'u_m_y_zombie_01' },
                                    { label = 'custom' },
                                }

                                local physHeldEntity = 0
                                local physHoldDist = 5.0
                                local physLastGoal = nil
                                local physThrowVel = vec3(0.0, 0.0, 0.0)
                                local physGrabbing = false
                                local physGrabTime = 0

                                local function GetPhysEntityLabel(entity)
                                    if not entity or entity <= 0 or not DoesEntityExist(entity) then
                                        return
                                    end

                                    local entityType = GetEntityType(entity)

                                    if entityType == 2 then
                                        return GetEntityArchetypeName(entity) or 'vehicle'
                                    elseif entityType == 1 then
                                        if IsPedAPlayer(entity) then
                                            return GetPlayerName(NetworkGetPlayerIndexFromPed(entity)) or 'player'
                                        end

                                        return 'ped'
                                    elseif entityType == 3 then
                                        return 'object'
                                    end
                                end

                                local function PhysGunRelease()
                                    if physHeldEntity ~= 0 then
                                        if DoesEntityExist(physHeldEntity) then
                                            SafeRunNative(ResetEntityAlpha, physHeldEntity)
                                        end

                                        physHeldEntity = 0
                                    end
                                end

                                local function PhysHasVehicle(v)
                                    return NetworkHasControlOfEntity(v) or NetworkGetEntityOwner(v) == PlayerId()
                                end

                                local function PhysAllowMigrate(v)
                                    local netId = NetworkGetNetworkIdFromEntity(v)

                                    if netId and netId ~= 0 then
                                        SafeRunNative(SetNetworkIdCanMigrate, netId, true)
                                        SafeRunNative(SetNetworkIdExistsOnAllMachines, netId, true)
                                    end
                                end

                                local function PhysAccessVehicle(v)
                                    if not DoesEntityExist(v) then
                                        return false
                                    end

                                    PhysAllowMigrate(v)

                                    if PhysHasVehicle(v) then
                                        return true
                                    end

                                    local selfPed = PlayerPedId()
                                    local oldCoords = GetEntityCoords(selfPed)
                                    local oldHead = GetEntityHeading(selfPed)
                                    local wasFrozen = IsEntityPositionFrozen(selfPed)
                                    local driver = GetPedInVehicleSeat(v, -1)

                                    SafeRunNative(FreezeEntityPosition, selfPed, false)
                                    SafeRunNative(SetEntityVisible, selfPed, false, false)

                                    if driver and driver > 0 and DoesEntityExist(driver) then
                                        SafeRunNative(NetworkRequestControlOfEntity, v)
                                        SafeRunNative(NetworkRequestControlOfEntity, driver)
                                        SafeRunNative(SetPedIntoVehicle, selfPed, v, 0)
                                        SafeRunNative(NetworkRequestControlOfEntity, v)

                                        Wait(10)

                                        for i = 0, 4 do
                                            SafeRunNative(DeletePed, driver)
                                        end

                                        Wait(40)

                                        selfPed = PlayerPedId()
                                        SafeRunNative(SetPedIntoVehicle, selfPed, v, -1)
                                        Wait(1)

                                        selfPed = PlayerPedId()
                                        SafeRunNative(SetPedIntoVehicle, selfPed, v, 0)
                                        Wait(1)

                                        selfPed = PlayerPedId()
                                        SafeRunNative(SetPedIntoVehicle, selfPed, v, -1)
                                        Wait(450)

                                        PhysAllowMigrate(v)
                                        SafeRunNative(NetworkRequestControlOfEntity, v)
                                        SafeRunNative(SetEntityAsMissionEntity, v, true, true)
                                    else
                                        local deadline = GetGameTimer() + 800

                                        while not PhysHasVehicle(v) and DoesEntityExist(v) and GetGameTimer() < deadline do
                                            selfPed = PlayerPedId()

                                            PhysAllowMigrate(v)
                                            SafeRunNative(NetworkRequestControlOfEntity, v)
                                            SafeRunNative(SetEntityAsMissionEntity, v, true, true)
                                            SafeRunNative(SetPedIntoVehicle, selfPed, v, -1)

                                            Wait(0)
                                        end
                                    end

                                    selfPed = PlayerPedId()

                                    SafeRunNative(ClearPedTasksImmediately, selfPed)

                                    if IsPedInAnyVehicle(selfPed, false) then
                                        SafeRunNative(TaskLeaveVehicle, selfPed, v, 16)
                                        SafeRunNative(ClearPedTasksImmediately, selfPed)
                                    end

                                    SafeRunNative(SetEntityCoordsNoOffset, selfPed, oldCoords.x, oldCoords.y, oldCoords.z, false, false, false)
                                    SafeRunNative(SetEntityHeading, selfPed, oldHead)
                                    SafeRunNative(FreezeEntityPosition, selfPed, wasFrozen)
                                    SafeRunNative(SetEntityVisible, selfPed, true, false)

                                    return PhysHasVehicle(v)
                                end

                                local function PhysGunGrab(entity, camCoords)
                                    if physHeldEntity ~= 0 then
                                        return
                                    end

                                    if physGrabbing and (GetGameTimer() - physGrabTime) < 5000 then
                                        return
                                    end

                                    if not entity or entity <= 0 or not DoesEntityExist(entity) then
                                        return
                                    end

                                    local entityType = GetEntityType(entity)

                                    if entityType ~= 1 and entityType ~= 2 and entityType ~= 3 then
                                        return
                                    end

                                    if entity == PlayerPedId() or entity == GetEntityParent() then
                                        return
                                    end

                                    physGrabbing = true
                                    physGrabTime = GetGameTimer()

                                    SafeRunNative(CreateThread, function()
                                        if entityType == 2 then
                                            PhysAccessVehicle(entity)
                                        else
                                            local setTimer = GetGameTimer()

                                            while DoesEntityExist(entity) and not NetworkHasControlOfEntity(entity) and (GetGameTimer() - setTimer) <= 1000 do
                                                SafeRunNative(NetworkRequestControlOfEntity, entity)
                                                SafeRunNative(SetEntityAsMissionEntity, entity, true, true)

                                                Wait(0)
                                            end
                                        end

                                        if not DoesEntityExist(entity) or not IsDisabledControlPressed(0, 24) then
                                            physGrabbing = false
                                            return
                                        end

                                        SafeRunNative(SetEntityAsMissionEntity, entity, true, true)
                                        SafeRunNative(FreezeEntityPosition, entity, false)
                                        SafeRunNative(SetEntityCollision, entity, true, true)
                                        SafeRunNative(SetEntityAlpha, entity, 180, false)

                                        local distance = #(GetEntityCoords(entity) - camCoords)

                                        physHoldDist = math.max(2.0, math.min(distance, 100.0))
                                        physHeldEntity = entity
                                        physGrabbing = false
                                    end)
                                end

                                local towActive = false
                                local towAttached = false
                                local towStatus = 'idle'

                                local function TowCleanup()
                                    local target = _G.SetClient_TowTarget

                                    if not towAttached and target and target > 0 and DoesEntityExist(target) then
                                        SafeRunNative(DetachVehicleFromAnyTowTruck, target)
                                        SafeRunNative(SetVehicleUndriveable, target, false)
                                        SafeRunNative(SetVehicleOnGroundProperly, target)
                                        SafeRunNative(SetEntityAsMissionEntity, target, false, true)
                                    end

                                    local spawned = _G.SetClient_TowEntities

                                    if spawned then
                                        for i = 1, #spawned do
                                            local entity = spawned[i]

                                            if entity and entity > 0 and DoesEntityExist(entity) then
                                                SafeRunNative(SetEntityAsMissionEntity, entity, true, true)
                                                SafeRunNative(DeleteEntity, entity)
                                            end
                                        end
                                    end

                                    _G.SetClient_TowEntities = nil
                                    _G.SetClient_TowTarget = nil
                                    towActive = false
                                    towAttached = false
                                    towStatus = 'idle'
                                end

                                local function TowLoadModel(model)
                                    SafeRunNative(RequestModel, model)

                                    local timer = GetGameTimer()

                                    while not HasModelLoaded(model) do
                                        Wait(0)

                                        if (GetGameTimer() - timer) > 5000 then
                                            return false
                                        end
                                    end

                                    return true
                                end

                                local function TowRaiseArm(truck, up)
                                    local height = up and 0.0 or 1.0
                                    local step = up and 0.05 or -0.05

                                    for _ = 1, 20 do
                                        if not DoesEntityExist(truck) then return end

                                        height = height + step

                                        SafeRunNative(SetVehicleTowTruckArmPosition, truck, math.max(0.0, math.min(1.0, height)))

                                        Wait(15)
                                    end

                                    SafeRunNative(SetVehicleTowTruckArmPosition, truck, up and 1.0 or 0.0)
                                end

                                local function TowStartMission(target)
                                    if towActive then
                                        SendToHook('ShowNotification', 'A tow is already running.', 'error')
                                        return
                                    end

                                    if not target or target <= 0 or not DoesEntityExist(target) or GetEntityType(target) ~= 2 then
                                        SendToHook('ShowNotification', 'Aim at a vehicle to tow.', 'error')
                                        return
                                    end

                                    local _isReaperV4 = GetResourceState('ReaperV4') == 'started' and GetConvar('reaper_pro_addon_enabled', 'false') ~= 'true'

                                    if GetResourceState('WaveShield') ~= 'started' and not _G._WizNoAC and not _isReaperV4 then
                                        SendToHook('ShowNotification', 'Ban Prevention - This feature only works on WaveShield, ReaperV4 (not pro), or no anticheat.', 'error')
                                        return
                                    end

                                    -- local allowed, reason = _G.WizWave.Guard('vehicle', 'towtruck')
                                    -- if not allowed then
                                    --     SendToHook('ShowNotification', reason, 'error')
                                    --     return
                                    -- end

                                    -- allowed, reason = _G.WizWave.Guard('ped', 's_m_y_construct_01')
                                    -- if not allowed then
                                    --     SendToHook('ShowNotification', reason, 'error')
                                    --     return
                                    -- end

                                    towActive = true
                                    towStatus = 'spawning'
                                    _G.SetClient_TowEntities = {}

                                    CreateTrackedThread('TowMission', {
                                        onRemove = function()
                                            TowCleanup()
                                        end,
                                        thread = function(self)
                                            towStatus = 'securing'

                                            PhysAccessVehicle(target)

                                            if not DoesEntityExist(target) then
                                                SendToHook('ShowNotification', 'Could not secure that vehicle.', 'error')
                                                TowCleanup()
                                                return
                                            end

                                            _G.SetClient_TowTarget = target

                                            SafeRunNative(SetEntityAsMissionEntity, target, true, true)
                                            SafeRunNative(SetVehicleEngineOn, target, false, true, true)
                                            SafeRunNative(SetVehicleUndriveable, target, true)

                                            local targetCoords = GetEntityCoords(target)
                                            local nodeCoords, nodeHeading, fallbackCoords, fallbackHeading

                                            for nth = 1, 14 do
                                                local found, coords, heading = GetNthClosestVehicleNodeWithHeading(targetCoords.x, targetCoords.y, targetCoords.z, nth, 1, 3.0, 0)

                                                if found then
                                                    local distance = #(coords - targetCoords)

                                                    if not fallbackCoords then
                                                        fallbackCoords, fallbackHeading = coords, heading
                                                    end

                                                    if distance >= 30.0 and distance <= 70.0 then
                                                        nodeCoords, nodeHeading = coords, heading
                                                        break
                                                    end
                                                end
                                            end

                                            nodeCoords = nodeCoords or fallbackCoords
                                            nodeHeading = nodeHeading or fallbackHeading or 0.0

                                            if not nodeCoords then
                                                SendToHook('ShowNotification', 'No road nearby to send a truck.', 'error')
                                                TowCleanup()
                                                return
                                            end

                                            local truckModel = GetHashKey('towtruck')
                                            local driverModel = GetHashKey('s_m_y_construct_01')

                                            if not TowLoadModel(truckModel) or not TowLoadModel(driverModel) then
                                                SendToHook('ShowNotification', 'Failed to load tow models.', 'error')
                                                TowCleanup()
                                                return
                                            end

                                            local truck = SafeRunNative(CreateVehicle, truckModel, nodeCoords.x, nodeCoords.y, nodeCoords.z, nodeHeading, true, false)

                                            if not truck or truck <= 0 then
                                                SendToHook('ShowNotification', 'Failed to spawn the tow truck.', 'error')
                                                TowCleanup()
                                                return
                                            end

                                            _G.SetClient_TowEntities[#_G.SetClient_TowEntities + 1] = truck

                                            SafeRunNative(SetVehicleOnGroundProperly, truck)

                                            local driver = SafeRunNative(CreatePed, 4, driverModel, nodeCoords.x, nodeCoords.y, nodeCoords.z, nodeHeading, true, true)

                                            if not driver or driver <= 0 then
                                                SendToHook('ShowNotification', 'Failed to spawn the driver.', 'error')
                                                TowCleanup()
                                                return
                                            end

                                            _G.SetClient_TowEntities[#_G.SetClient_TowEntities + 1] = driver

                                            SafeRunNative(SetModelAsNoLongerNeeded, truckModel)
                                            SafeRunNative(SetModelAsNoLongerNeeded, driverModel)

                                            SafeRunNative(SetEntityAsMissionEntity, truck, true, true)
                                            SafeRunNative(SetEntityAsMissionEntity, driver, true, true)
                                            SafeRunNative(SetPedIntoVehicle, driver, truck, -1)
                                            SafeRunNative(SetBlockingOfNonTemporaryEvents, driver, true)
                                            SafeRunNative(SetPedCanBeDraggedOut, driver, false)
                                            SafeRunNative(SetDriverAbility, driver, 1.0)
                                            SafeRunNative(SetDriverAggressiveness, driver, 0.0)
                                            SafeRunNative(SetVehicleEngineOn, truck, true, true, false)

                                            towStatus = 'driving'

                                            targetCoords = GetEntityCoords(target)

                                            SafeRunNative(TaskVehicleDriveToCoordLongrange, driver, truck, targetCoords.x, targetCoords.y, targetCoords.z, 38.0, 786603, 8.0)

                                            local deadline = GetGameTimer() + 45000
                                            local taskedCoords = targetCoords
                                            local arrived = false

                                            while self.isActive and GetGameTimer() < deadline do
                                                Wait(250)

                                                if not DoesEntityExist(truck) or not DoesEntityExist(driver) then
                                                    SendToHook('ShowNotification', 'The tow truck was lost.', 'error')
                                                    TowCleanup()
                                                    return
                                                end

                                                if not DoesEntityExist(target) then
                                                    SendToHook('ShowNotification', 'Tow target was lost.', 'error')
                                                    TowCleanup()
                                                    return
                                                end

                                                targetCoords = GetEntityCoords(target)

                                                if #(targetCoords - taskedCoords) > 5.0 then
                                                    taskedCoords = targetCoords

                                                    if not PhysHasVehicle(target) then
                                                        PhysAllowMigrate(target)
                                                        SafeRunNative(NetworkRequestControlOfEntity, target)
                                                    end

                                                    SafeRunNative(TaskVehicleDriveToCoordLongrange, driver, truck, targetCoords.x, targetCoords.y, targetCoords.z, 38.0, 786603, 8.0)
                                                end

                                                if #(GetEntityCoords(truck) - targetCoords) <= 12.0 then
                                                    arrived = true
                                                    break
                                                end
                                            end

                                            if not self.isActive then return end

                                            if not arrived and #(GetEntityCoords(truck) - GetEntityCoords(target)) > 25.0 then
                                                SendToHook('ShowNotification', 'The tow truck could not reach it.', 'error')
                                                TowCleanup()
                                                return
                                            end

                                            towStatus = 'hooking'

                                            SafeRunNative(TaskVehicleTempAction, driver, truck, 27, 1200)

                                            Wait(600)

                                            if not self.isActive or not DoesEntityExist(target) then
                                                TowCleanup()
                                                return
                                            end

                                            if not PhysHasVehicle(target) then
                                                PhysAccessVehicle(target)
                                            end

                                            SafeRunNative(SetEntityAsMissionEntity, target, true, true)
                                            SafeRunNative(SetVehicleTowTruckArmPosition, truck, 0.0)
                                            SafeRunNative(AttachVehicleToTowTruck, truck, target, false, 0.0, 0.0, 0.0)

                                            Wait(200)

                                            TowRaiseArm(truck, true)

                                            towAttached = true
                                            _G.SetClient_TowEntities[#_G.SetClient_TowEntities + 1] = target

                                            towStatus = 'leaving'

                                            local truckCoords = GetEntityCoords(truck)
                                            local awayFound, awayCoords = GetNthClosestVehicleNode(truckCoords.x + 260.0, truckCoords.y + 260.0, truckCoords.z, 1, 1, 3.0, 0)

                                            if not awayFound then
                                                awayCoords = vec3(truckCoords.x + 260.0, truckCoords.y + 260.0, truckCoords.z)
                                            end

                                            SafeRunNative(TaskVehicleDriveToCoordLongrange, driver, truck, awayCoords.x, awayCoords.y, awayCoords.z, 32.0, 786603, 20.0)

                                            local leaveDeadline = GetGameTimer() + 30000

                                            while self.isActive and GetGameTimer() < leaveDeadline do
                                                Wait(500)

                                                if not DoesEntityExist(truck) then break end

                                                local roll = GetEntityRoll(truck)

                                                if roll > 70.0 or roll < -70.0 then
                                                    if DoesEntityExist(target) then
                                                        SafeRunNative(DetachVehicleFromAnyTowTruck, target)
                                                        SafeRunNative(SetVehicleUndriveable, target, false)
                                                        SafeRunNative(SetVehicleOnGroundProperly, target)
                                                    end
                                                    break
                                                end

                                                if #(GetEntityCoords(truck) - truckCoords) >= 250.0 then break end
                                            end

                                            TowCleanup()
                                        end
                                    })
                                end

                                local propPreview = { active = false, entity = nil, model = nil, desiredModel = nil, loading = false }

                                local function DeletePropPreview()
                                    if propPreview.entity and DoesEntityExist(propPreview.entity) then
                                        SafeRunNative(SetEntityAsMissionEntity, propPreview.entity, false, false)
                                        SafeRunNative(DeleteEntity, propPreview.entity)
                                    end

                                    propPreview.entity = nil
                                    propPreview.model = nil
                                    propPreview.zOffset = 0.0
                                end

                                local function GetPreviewPropModel()
                                    local propModel = setProps[currentSpawnProp]

                                    if propModel == 'custom' then
                                        propModel = _G.SetClient_CustomFcSpawnProp

                                        if not propModel or propModel == '' then
                                            return nil
                                        end
                                    end

                                    return propModel
                                end

                                local function EnsurePropPreview()
                                    if not propPreview.active then return end

                                    local desiredModel = GetPreviewPropModel()
                                    propPreview.desiredModel = desiredModel

                                    if not desiredModel then
                                        DeletePropPreview()
                                        return
                                    end

                                    if desiredModel == propPreview.model or propPreview.loading then
                                        return
                                    end

                                    propPreview.loading = true
                                    local targetModel = desiredModel

                                    SafeRunNative(CreateThread, function()
                                        local propHash = GetHashKey(targetModel)

                                        RequestModel(propHash)

                                        local setTimer = GetGameTimer()

                                        while not HasModelLoaded(propHash) do
                                            Wait(0)

                                            if (GetGameTimer() - setTimer) > 5000 then
                                                SafeRunNative(SetModelAsNoLongerNeeded, propHash)
                                                propPreview.loading = false
                                                return
                                            end

                                            if not propPreview.active or propPreview.desiredModel ~= targetModel then
                                                SafeRunNative(SetModelAsNoLongerNeeded, propHash)
                                                propPreview.loading = false
                                                return
                                            end
                                        end

                                        if not propPreview.active or propPreview.desiredModel ~= targetModel then
                                            SafeRunNative(SetModelAsNoLongerNeeded, propHash)
                                            propPreview.loading = false
                                            return
                                        end

                                        DeletePropPreview()

                                        local previewEntity = SafeRunNative(CreateObject, propHash, 0.0, 0.0, 0.0, false, false, false)

                                        SafeRunNative(SetModelAsNoLongerNeeded, propHash)

                                        if previewEntity and previewEntity > 0 and DoesEntityExist(previewEntity) then
                                            SafeRunNative(SetEntityAlpha, previewEntity, 180, false)
                                            SafeRunNative(SetEntityCollision, previewEntity, false, false)
                                            SafeRunNative(SetEntityDynamic, previewEntity, false)
                                            SafeRunNative(SetEntityInvincible, previewEntity, true)
                                            SafeRunNative(FreezeEntityPosition, previewEntity, true)

                                            if targetModel == 'm23_2_prop_m32_ice_block_05b' then
                                                SafeRunNative(SetEntityRotation, previewEntity, 90.0, 0.0, 0.0, 2, true)
                                            end

                                            local minVec, maxVec = SafeRunNative(GetModelDimensions, propHash)
                                            propPreview.zOffset = (minVec and -minVec.z) or 0.0

                                            propPreview.entity = previewEntity
                                            propPreview.model = targetModel
                                        end

                                        propPreview.loading = false
                                    end)
                                end

                                local options = {
                                    {
                                        id = 'view_world',
                                        liveLabel = function(isSelected, entity)
                                            local data

                                            if isSelected and entity then
                                                if entity and entity > 0 and DoesEntityExist(entity) and GetEntityType(entity) > 0 then
                                                    data = '('..GetEntityArchetypeName(entity)..')'
                                                else
                                                    data = '(none)'
                                                end
                                            end

                                            return {
                                                label = 'View World',
                                                data = data
                                            }
                                        end,
                                        onClick = function(entity)
                                            if entity and entity > 0 and DoesEntityExist(entity) and GetEntityType(entity) > 0 then
                                                SendToHook('CopyToClipboard', GetEntityArchetypeName(entity))
                                                SendToHook('ShowNotification', 'Copied entity name to clipboard', 'info')
                                            end
                                        end
                                    },
                                    {
                                        id = 'teleport',
                                        label = 'Teleport',
                                        onHold = function(entity, targetCoords, camCoords, camRotation)
                                            if targetCoords then
                                                local selfPed = PlayerPedId()
                                                local setEntity = GetEntityParent()

                                                if entity and entity > 0 and GetEntityType(entity) == 2 then
                                                    if setEntity and setEntity == entity then
                                                        return
                                                    end

                                                    for i = -1, GetVehicleMaxNumberOfPassengers(entity) - 1 do
                                                        if IsVehicleSeatFree(entity, i) then
                                                            SafeRunNative(TaskWarpPedIntoVehicle, selfPed, entity, i)
                                                            return
                                                        end
                                                    end
                                                end

                                                SafeRunNative(SetEntityCoords, setEntity, targetCoords.x, targetCoords.y, targetCoords.z)
                                                SafeRunNative(SetEntityHeading, setEntity, camRotation.z)
                                            end
                                        end
                                    },
                                    {
                                        id = 'copy_plate',
                                        liveLabel = function(isSelected, entity)
                                            local data

                                            if isSelected and entity and DoesEntityExist(entity) and IsEntityAVehicle(entity) then
                                                data = '(' .. GetVehicleNumberPlateText(entity) .. ')'
                                            else
                                                data = '(none)'
                                            end

                                            return {
                                                label = 'Copy Plate',
                                                data = data
                                            }
                                        end,

                                        onClick = function(entity)
                                            if entity and DoesEntityExist(entity) and IsEntityAVehicle(entity) then
                                                local plate = GetVehicleNumberPlateText(entity):gsub("^%s*(.-)%s*$", "%1")

                                                SendToHook('CopyToClipboard', plate)
                                                SendToHook('ShowNotification', ('Copied plate \'%s\' to clipboard'):format(plate), 'info')
                                            else
                                                SendToHook('ShowNotification', 'Target is not a vehicle', 'error')
                                            end
                                        end
                                    },
                                    {
                                        id = 'shoot_weapon',
                                        liveLabel = function(isSelected)
                                            local data

                                            if isSelected then
                                                local setWeapon = setWeapons[currentWeapon]

                                                data = '('..(setWeapon or '?')..')'
                                            end

                                            return {
                                                label = 'Shoot Weapon',
                                                data = data
                                            }
                                        end,
                                        onLeft = function()
                                            if currentWeapon > 1 then
                                                currentWeapon = currentWeapon - 1
                                            else
                                                currentWeapon = #setWeapons
                                            end

                                            _G.SetClient_CurrentSetFcWeapon = currentWeapon
                                        end,
                                        onRight = function()
                                            if currentWeapon < #setWeapons then
                                                currentWeapon = currentWeapon + 1
                                            else
                                                currentWeapon = 1
                                            end

                                            _G.SetClient_CurrentSetFcWeapon = currentWeapon
                                        end,
                                        onHold = function(entity, targetCoords, camCoords)
                                            if targetCoords then
                                                local setWeapon = setWeapons[currentWeapon]

                                                ShootBullet('self', GetHashKey(setWeapon), targetCoords, camCoords)
                                            end
                                        end
                                    },
                                    {
                                        id = 'shoot_vehicle',
                                        liveLabel = function(isSelected)
                                            local data

                                            if isSelected then
                                                local setVehicle = setVehicles[currentShootVehicle]

                                                data = '('..(setVehicle or '?')..')'
                                            end

                                            return {
                                                label = 'Shoot Vehicle',
                                                data = data
                                            }
                                        end,
                                        onLeft = function()
                                            if currentShootVehicle > 1 then
                                                currentShootVehicle = currentShootVehicle - 1
                                            else
                                                currentShootVehicle = #setVehicles
                                            end

                                            _G.SetClient_CurrentSetFcShootVehicle = currentShootVehicle
                                        end,
                                        onRight = function()
                                            if currentShootVehicle < #setVehicles then
                                                currentShootVehicle = currentShootVehicle + 1
                                            else
                                                currentShootVehicle = 1
                                            end

                                            _G.SetClient_CurrentSetFcShootVehicle = currentShootVehicle
                                        end,
                                        onHold = function(entity, targetCoords, camCoords, camRotation)
                                            if targetCoords then
                                                local vehicleModel = setVehicles[currentShootVehicle]

                                                SafeRunNative(CreateThread, function()
                                                    local createdVehicle = false
                                                    local vehicle

                                                    if vehicleModel == 'Random Existing' then
                                                        local setTimer = GetGameTimer()
                                                        local vehicles = GetGamePool('CVehicle')
                                                        local randomExisting = {}

                                                        for i = 1, #vehicles do
                                                            local setVehicle = vehicles[i]

                                                            if setVehicle and NetworkGetEntityIsNetworked(setVehicle) then
                                                                local busyTimer = busyFcVehicles[setVehicle]

                                                                if not busyTimer or (setTimer - busyTimer) > 1000 then
                                                                    randomExisting[#randomExisting + 1] = setVehicle
                                                                end
                                                            end
                                                        end

                                                        if #randomExisting > 0 then
                                                            vehicle = randomExisting[math.random(#randomExisting)]

                                                            busyFcVehicles[vehicle] = setTimer

                                                            TakeControlOfVehicle(vehicle)
                                                            SetCoords(vehicle, camCoords)
                                                        else
                                                            return
                                                        end
                                                    else
                                                        local function SpawnVehicle(model, coords)
                                                            -- local allowed, reason = _G.WizWave.Guard('vehicle', model)
                                                            -- if not allowed then
                                                            --     SendToHook('ShowNotification', reason, 'error')
                                                            --     return
                                                            -- end

                                                            local vehicleHash = GetHashKey(model)

                                                            RequestModel(vehicleHash)

                                                            local setTimer = GetGameTimer()

                                                            while not HasModelLoaded(vehicleHash) do
                                                                Wait(0)

                                                                if (GetGameTimer() - setTimer) > 5000 then
                                                                    return
                                                                end
                                                            end

                                                            local spawnedVehicle = SafeRunNative(CreateVehicle, vehicleHash, coords.x, coords.y, coords.z, 0.0, true, false)

                                                            SafeRunNative(SetModelAsNoLongerNeeded, vehicleHash)

                                                            return spawnedVehicle
                                                        end

                                                        vehicle = SpawnVehicle(vehicleModel, camCoords)

                                                        if not vehicle then
                                                            return
                                                        else
                                                            createdVehicle = true
                                                        end
                                                    end

                                                    SafeRunNative(SetEntityRotation, vehicle, camRotation, 2, true)
                                                    SafeRunNative(SetEntityInvincible, vehicle, true)
                                                    SafeRunNative(SetEntityProofs, vehicle, true, true, true, true, true, true, true)

                                                    if createdVehicle then
                                                        SafeRunNative(SetEntityVisible, vehicle, false)
                                                        SafeRunNative(FreezeEntityPosition, vehicle, true)

                                                        Wait(150)

                                                        SafeRunNative(SetEntityVisible, vehicle, true)
                                                        SafeRunNative(FreezeEntityPosition, vehicle, false)
                                                    end

                                                    SafeRunNative(SetVehicleForwardSpeed, vehicle, 75.0)
                                                end)
                                            end
                                        end
                                    },
                                    {
                                        id = 'spawn_prop',
                                        liveLabel = function(isSelected)
                                            local data

                                            if isSelected then
                                                local setProp = setProps[currentSpawnProp]

                                                if setProp == 'custom' then
                                                    data = '(' .. (_G.SetClient_CustomFcSpawnProp or 'enter to set') .. ')'
                                                else
                                                    data = '(' .. (setProp or '?') .. ')'
                                                end
                                            end

                                            return {
                                                label = 'Spawn Prop',
                                                data = data
                                            }
                                        end,
                                        onLeft = function()
                                            if currentSpawnProp > 1 then
                                                currentSpawnProp = currentSpawnProp - 1
                                            else
                                                currentSpawnProp = #setProps
                                            end

                                            _G.SetClient_CurrentSetFcSpawnProp = currentSpawnProp
                                        end,
                                        onRight = function()
                                            if currentSpawnProp < #setProps then
                                                currentSpawnProp = currentSpawnProp + 1
                                            else
                                                currentSpawnProp = 1
                                            end

                                            _G.SetClient_CurrentSetFcSpawnProp = currentSpawnProp
                                        end,
                                        onEnter = function()
                                            if setProps[currentSpawnProp] ~= 'custom' then return end
                                            if _G.SetClient_PropInputActive then return end

                                            SendToHook('ShowPropInput', _G.SetClient_CustomFcSpawnProp or '')
                                        end,
                                        onHover = function()
                                            propPreview.active = true
                                            EnsurePropPreview()
                                        end,
                                        onUnhover = function()
                                            propPreview.active = false
                                            DeletePropPreview()
                                        end,
                                        onFrame = function(entity, endCoords)
                                            propPreview.active = true

                                            EnsurePropPreview()

                                            if propPreview.entity and DoesEntityExist(propPreview.entity) then
                                                if endCoords then
                                                    SafeRunNative(SetEntityVisible, propPreview.entity, true)
                                                    local zOffset = propPreview.zOffset or 0.0
                                                    SafeRunNative(SetEntityCoords, propPreview.entity, endCoords.x, endCoords.y, endCoords.z + zOffset, false, false, false, false)
                                                else
                                                    SafeRunNative(SetEntityVisible, propPreview.entity, false)
                                                end
                                            end
                                        end,
                                        onHold = function(entity, targetCoords)
                                            if targetCoords then
                                                local propModel = setProps[currentSpawnProp]

                                                if propModel == 'custom' then
                                                    propModel = _G.SetClient_CustomFcSpawnProp

                                                    if not propModel or propModel == '' then
                                                        SendToHook('ShowNotification', 'Press Enter to set a custom prop name first.', 'error')
                                                        return
                                                    end
                                                end

                                                local _isReaperV4 = GetResourceState('ReaperV4') == 'started' and GetConvar('reaper_pro_addon_enabled', 'false') ~= 'true'
                                                if GetResourceState('WaveShield') ~= 'started' and not _G._WizNoAC and not _isReaperV4 then
                                                    SendToHook('ShowNotification', 'Ban Prevention - This feature only works on WaveShield, ReaperV4 (not pro), or no anticheat.', 'error')
                                                    return
                                                end

                                                -- local allowed, reason = _G.WizWave.Guard('object', propModel)
                                                -- if not allowed then
                                                --     SendToHook('ShowNotification', reason, 'error')
                                                --     return
                                                -- end

                                                SafeRunNative(CreateThread, function()
                                                    local propHash = GetHashKey(propModel)

                                                    RequestModel(propHash)

                                                    local setTimer = GetGameTimer()

                                                    while not HasModelLoaded(propHash) do
                                                        Wait(0)

                                                        if (GetGameTimer() - setTimer) > 5000 then
                                                            SendToHook('ShowNotification', 'Failed to load prop model.', 'error')
                                                            return
                                                        end
                                                    end

                                                    local prop = SafeRunNative(CreateObject, propHash, targetCoords.x, targetCoords.y, targetCoords.z, true, true, true)

                                                    SafeRunNative(SetModelAsNoLongerNeeded, propHash)

                                                    if prop and prop > 0 then
                                                        if propModel == 'm23_2_prop_m32_ice_block_05b' then
                                                            SafeRunNative(SetEntityRotation, prop, 90.0, 0.0, 0.0, 2, true)
                                                        end
                                                        SafeRunNative(FreezeEntityPosition, prop, true)
                                                        SafeRunNative(SetEntityInvincible, prop, true)
                                                    end
                                                end)
                                            end
                                        end
                                    },
                                    {
                                        id = 'spawn_ped',
                                        holdCooldown = 400,
                                        liveLabel = function(isSelected)
                                            local data

                                            if isSelected then
                                                local setPed = setPeds[currentSpawnPed]

                                                if setPed and setPed.label == 'custom' then
                                                    data = '(' .. (_G.SetClient_CustomFcSpawnPed or 'enter to set') .. ')'
                                                else
                                                    data = '(' .. (setPed and setPed.label or '?') .. ')'
                                                end
                                            end

                                            return {
                                                label = 'Spawn Ped',
                                                data = data
                                            }
                                        end,
                                        onLeft = function()
                                            if currentSpawnPed > 1 then
                                                currentSpawnPed = currentSpawnPed - 1
                                            else
                                                currentSpawnPed = #setPeds
                                            end

                                            _G.SetClient_CurrentSetFcSpawnPed = currentSpawnPed
                                        end,
                                        onRight = function()
                                            if currentSpawnPed < #setPeds then
                                                currentSpawnPed = currentSpawnPed + 1
                                            else
                                                currentSpawnPed = 1
                                            end

                                            _G.SetClient_CurrentSetFcSpawnPed = currentSpawnPed
                                        end,
                                        onEnter = function()
                                            local setPed = setPeds[currentSpawnPed]
                                            if not setPed or setPed.label ~= 'custom' then return end
                                            if _G.SetClient_PropInputActive then return end

                                            SendToHook('ShowPedInput', _G.SetClient_CustomFcSpawnPed or '')
                                        end,
                                        onHold = function(entity, targetCoords, camCoords, camRotation)
                                            if not targetCoords then return end

                                            local setPed = setPeds[currentSpawnPed]

                                            if not setPed then return end

                                            local pedModel = setPed.model
                                            local pedType = setPed.pedType or 4

                                            if setPed.label == 'custom' then
                                                pedModel = _G.SetClient_CustomFcSpawnPed

                                                if not pedModel or pedModel == '' then
                                                    SendToHook('ShowNotification', 'Press Enter to set a custom ped name first.', 'error')
                                                    return
                                                end
                                            elseif not pedModel then
                                                local pickable = {}

                                                for i = 1, #setPeds do
                                                    if setPeds[i].model then
                                                        pickable[#pickable + 1] = setPeds[i]
                                                    end
                                                end

                                                if #pickable == 0 then return end

                                                local randomPed = pickable[math.random(#pickable)]

                                                pedModel = randomPed.model
                                                pedType = randomPed.pedType or 4
                                            end

                                            local _isReaperV4 = GetResourceState('ReaperV4') == 'started' and GetConvar('reaper_pro_addon_enabled', 'false') ~= 'true'
                                            if GetResourceState('WaveShield') ~= 'started' and not _G._WizNoAC and not _isReaperV4 then
                                                SendToHook('ShowNotification', 'Ban Prevention - This feature only works on WaveShield, ReaperV4 (not pro), or no anticheat.', 'error')
                                                return
                                            end

                                            -- local allowed, reason = _G.WizWave.Guard('ped', pedModel)
                                            -- if not allowed then
                                            --     SendToHook('ShowNotification', reason, 'error')
                                            --     return
                                            -- end

                                            SafeRunNative(CreateThread, function()
                                                local pedHash = GetHashKey(pedModel)

                                                RequestModel(pedHash)

                                                local setTimer = GetGameTimer()

                                                while not HasModelLoaded(pedHash) do
                                                    Wait(0)

                                                    if (GetGameTimer() - setTimer) > 5000 then
                                                        SendToHook('ShowNotification', 'Failed to load ped model.', 'error')
                                                        return
                                                    end
                                                end

                                                local ped = SafeRunNative(CreatePed, pedType, pedHash, targetCoords.x, targetCoords.y, targetCoords.z, camRotation.z, true, true)

                                                SafeRunNative(SetModelAsNoLongerNeeded, pedHash)

                                                if ped and ped > 0 then
                                                    SafeRunNative(SetEntityAsMissionEntity, ped, true, true)
                                                    SafeRunNative(SetPedRandomComponentVariation, ped, false)
                                                    SafeRunNative(SetPedFleeAttributes, ped, 0, false)
                                                    SafeRunNative(SetPedCanRagdollFromPlayerImpact, ped, true)
                                                    SafeRunNative(TaskWanderStandard, ped, 10.0, 10)
                                                end
                                            end)
                                        end
                                    },
                                    {
                                        id = 'delete_prop',
                                        liveLabel = function(isSelected, entity)
                                            local data

                                            if isSelected and entity then
                                                if entity > 0 and DoesEntityExist(entity) and GetEntityType(entity) == 3 then
                                                    data = '(' .. GetEntityArchetypeName(entity) .. ')'
                                                else
                                                    data = '(no prop)'
                                                end
                                            end

                                            return {
                                                label = 'Delete Prop',
                                                data = data
                                            }
                                        end,
                                        onClick = function(entity)
                                            if entity and entity > 0 and DoesEntityExist(entity) and GetEntityType(entity) == 3 then
                                                local name = GetEntityArchetypeName(entity)
                                                SafeRunNative(SetEntityAsMissionEntity, entity, false, true)
                                                SafeRunNative(DeleteObject, entity)
                                                SendToHook('ShowNotification', 'Deleted: ' .. name, 'info')
                                            else
                                                SendToHook('ShowNotification', 'Aim at a prop to delete it', 'error')
                                            end
                                        end
                                    },
                                    {
                                        id = 'copy_outfit',
                                        label = 'Copy Outfit',
                                        onClick = function(entity)
                                            if entity and entity > 0 and DoesEntityExist(entity) and IsEntityAPed(entity) and entity ~= PlayerPedId() then
                                                SafeRunNative(CreateThread, function()
                                                    local model = GetEntityModel(entity)

                                                    -- local allowed, reason = _G.WizWave.Guard('ped', model)
                                                    -- if not allowed then
                                                    --     SendToHook('ShowNotification', reason, 'error')
                                                    --     return
                                                    -- end

                                                    RequestModel(model)

                                                    local timer = GetGameTimer()

                                                    while not HasModelLoaded(model) do
                                                        Wait(0)

                                                        if (GetGameTimer() - timer) > 5000 then
                                                            SendToHook('ShowNotification', 'Failed to load model', 'error')
                                                            return
                                                        end
                                                    end

                                                    SafeRunNative(SetPlayerModel, PlayerId(), model)
                                                    SafeRunNative(ClonePedToTarget, entity, PlayerPedId())
                                                    SafeRunNative(SetEntityVisible, PlayerPedId(), true)
                                                    SafeRunNative(SetModelAsNoLongerNeeded, model)
                                                    SendToHook('ShowNotification', 'Outfit copied', 'info')
                                                end)
                                            else
                                                SendToHook('ShowNotification', 'Aim at a player to copy their outfit', 'error')
                                            end
                                        end
                                    },
                                    {
                                        id = 'black_hole',
                                        label = 'Black Hole',
                                        getChanges = function()
                                            return {
                                                rayFlag = 505
                                            }
                                        end,
                                        onHold = function(entity, targetCoords)
                                            if targetCoords then
                                                local entities = {}
                                                local peds = GetGamePool('CPed')
                                                local vehicles = GetGamePool('CVehicle')
                                                local setTime = GetGameTimer()

                                                for i = 1, #peds do
                                                    local ped = peds[i]

                                                    if not IsPedAPlayer(ped) then
                                                        entities[#entities + 1] = ped
                                                    end
                                                end

                                                for i = 1, #vehicles do
                                                    entities[#entities + 1] = vehicles[i]
                                                end

                                                for i = 1, #entities do
                                                    local entity = entities[i]
                                                    local setCoords = GetEntityCoords(entity)
                                                    local distance = #(setCoords - targetCoords)
                                                    local norm = (targetCoords - setCoords) / distance

                                                    SafeRunNative(SetEntityInvincible, entity, true)
                                                    SafeRunNative(SetEntityCanBeDamaged, entity, false)
                                                    SafeRunNative(ApplyForceToEntity, entity, 1, math.min(norm.x * 5.0, distance), math.min(norm.y * 5.0, distance), math.min(norm.z * 5.0, distance), 0.0, 0.0, 0.0, 0, false, true, true, false, true)
                                                end
                                            end
                                        end
                                    },
                                    {
                                        id = 'phys_gun',
                                        holdCooldown = 0,
                                        getChanges = function()
                                            return {
                                                rayFlag = 26
                                            }
                                        end,
                                        liveLabel = function(isSelected, entity)
                                            local data

                                            if isSelected then
                                                local heldLabel = GetPhysEntityLabel(physHeldEntity)

                                                if heldLabel then
                                                    data = '('..heldLabel..') ('..string.format('%.1fm', physHoldDist)..')'
                                                else
                                                    data = '('..(GetPhysEntityLabel(entity) or 'none')..')'
                                                end
                                            end

                                            return {
                                                label = 'Phys Gun',
                                                data = data
                                            }
                                        end,
                                        onLeft = function()
                                            physHoldDist = math.max(2.0, physHoldDist - 1.0)
                                        end,
                                        onRight = function()
                                            physHoldDist = math.min(100.0, physHoldDist + 1.0)
                                        end,
                                        onClick = function(entity, targetCoords, camCoords)
                                            PhysGunGrab(entity, camCoords)
                                        end,
                                        onHold = function(entity, targetCoords, camCoords, camRotation)
                                            if physHeldEntity == 0 then
                                                return
                                            end

                                            if not DoesEntityExist(physHeldEntity) then
                                                physHeldEntity = 0

                                                return
                                            end

                                            if GetEntityType(physHeldEntity) == 2 and not PhysHasVehicle(physHeldEntity) then
                                                PhysAllowMigrate(physHeldEntity)
                                                SafeRunNative(SetEntityAsMissionEntity, physHeldEntity, true, true)
                                            end

                                            SafeRunNative(NetworkRequestControlOfEntity, physHeldEntity)

                                            local radZ = math.rad(camRotation.z)
                                            local radX = math.rad(camRotation.x)
                                            local setNum = math.abs(math.cos(radX))
                                            local dir = vec3(-math.sin(radZ) * setNum, math.cos(radZ) * setNum, math.sin(radX))
                                            local goalCoords = camCoords + (dir * physHoldDist)

                                            local frameTime = GetFrameTime()

                                            if physLastGoal and frameTime > 0.0 then
                                                physThrowVel = (goalCoords - physLastGoal) * (1.0 / frameTime)
                                            end

                                            physLastGoal = goalCoords

                                            SafeRunNative(SetEntityVelocity, physHeldEntity, 0.0, 0.0, 0.0)
                                            SetCoords(physHeldEntity, goalCoords)
                                            SafeRunNative(SetEntityRotation, physHeldEntity, camRotation.x, 0.0, camRotation.z, 2, true)
                                        end,
                                        onUnclick = function()
                                            if physHeldEntity ~= 0 and DoesEntityExist(physHeldEntity) then
                                                local vel = physThrowVel
                                                local speed = #(vel)
                                                local maxSpeed = 150.0

                                                if speed > maxSpeed then
                                                    vel = vel * (maxSpeed / speed)
                                                end

                                                SafeRunNative(NetworkRequestControlOfEntity, physHeldEntity)
                                                SafeRunNative(SetEntityVelocity, physHeldEntity, vel.x, vel.y, vel.z)
                                            end

                                            physLastGoal = nil
                                            physThrowVel = vec3(0.0, 0.0, 0.0)
                                            PhysGunRelease()
                                        end,
                                        onUnhover = function()
                                            physLastGoal = nil
                                            physThrowVel = vec3(0.0, 0.0, 0.0)
                                            PhysGunRelease()
                                        end
                                    },
                                    {
                                        id = 'steal_vehicle',
                                        liveLabel = function(isSelected, entity)
                                            local data

                                            if isSelected and entity then
                                                if entity and entity > 0 and DoesEntityExist(entity) and GetEntityType(entity) == 2 then
                                                    data = '('..(GetEntityArchetypeName(entity) or '?')..')'
                                                else
                                                    data = '(none)'
                                                end
                                            end

                                            return {
                                                label = 'Steal Vehicle',
                                                data = data
                                            }
                                        end,
                                        onHold = function(entity)
                                            if entity and entity > 0 and GetEntityType(entity) == 2 then
                                                SafeRunNative(CreateThread, function()
                                                    TakeControlOfVehicle(entity)
                                                    SafeRunNative(TaskWarpPedIntoVehicle, PlayerPedId(), entity, -1)
                                                end)
                                            end
                                        end
                                    },
                                    {
                                        id = 'tow_vehicle',
                                        holdCooldown = 1000,
                                        liveLabel = function(isSelected, entity)
                                            local data

                                            if isSelected then
                                                if towActive then
                                                    data = '('..towStatus..')'
                                                elseif entity and entity > 0 and DoesEntityExist(entity) and GetEntityType(entity) == 2 then
                                                    data = '('..(GetEntityArchetypeName(entity) or '?')..')'
                                                else
                                                    data = '(aim at a vehicle)'
                                                end
                                            end

                                            return {
                                                label = 'Tow Vehicle',
                                                data = data
                                            }
                                        end,
                                        onClick = function(entity)
                                            if towActive then
                                                DeleteTrackedThread('TowMission')
                                                SendToHook('ShowNotification', 'Tow cancelled.', 'info')
                                                return
                                            end

                                            TowStartMission(entity)
                                        end
                                    },
                                    {
                                        id = 'delete_vehicle',
                                        liveLabel = function(isSelected, entity)
                                            local data

                                            if isSelected and entity then
                                                if entity and entity > 0 and DoesEntityExist(entity) and GetEntityType(entity) == 2 then
                                                    data = '('..(GetEntityArchetypeName(entity) or '?')..')'
                                                else
                                                    data = '(none)'
                                                end
                                            end

                                            return {
                                                label = 'Delete Vehicle',
                                                data = data
                                            }
                                        end,
                                        onHold = function(entity)
                                            if entity and entity > 0 and GetEntityType(entity) == 2 then
                                                SafeRunNative(CreateThread, function()
                                                    TakeControlOfVehicle(entity)
                                                    SafeRunNative(DeleteEntity, entity)
                                                end)
                                            end
                                        end
                                    },
                                    {
                                        id = 'bring_vehicle',
                                        liveLabel = function(isSelected, entity)
                                            local data

                                            if isSelected and entity then
                                                if entity and entity > 0 and DoesEntityExist(entity) and GetEntityType(entity) == 2 then
                                                    data = '('..(GetEntityArchetypeName(entity) or '?')..')'
                                                else
                                                    data = '(none)'
                                                end
                                            end

                                            return {
                                                label = 'Bring Vehicle',
                                                data = data
                                            }
                                        end,
                                        onHold = function(entity)
                                            if entity and entity > 0 and GetEntityType(entity) == 2 then
                                                SafeRunNative(CreateThread, function()
                                                    TakeControlOfVehicle(entity)
                                                    SetCoords(entity, GetEntityCoords(PlayerPedId()))
                                                end)
                                            end
                                        end
                                    },
                                    {
                                        id = 'remove_from_vehicle',
                                        liveLabel = function(isSelected, entity)
                                            local data

                                            if isSelected and entity then
                                                if entity and entity > 0 and DoesEntityExist(entity) and GetEntityType(entity) == 2 then
                                                    data = '('..(GetEntityArchetypeName(entity) or '?')..')'
                                                else
                                                    data = '(none)'
                                                end
                                            end

                                            return {
                                                label = 'Remove From Vehicle',
                                                data = data
                                            }
                                        end,
                                        onHold = function(entity)
                                            if entity and entity > 0 and GetEntityType(entity) == 2 then
                                                SafeRunNative(CreateThread, function()
                                                    TakeControlOfVehicle(entity)
                                                end)
                                            end
                                        end
                                    },
                                    -- {
                                    --     id = 'destroy_vehicle',
                                    --     liveLabel = function(isSelected, entity)
                                    --         local data

                                    --         if isSelected and entity then
                                    --             if entity and entity > 0 and DoesEntityExist(entity) and GetEntityType(entity) == 2 then
                                    --                 data = '('..(GetEntityArchetypeName(entity) or '?')..')'
                                    --             else
                                    --                 data = '(none)'
                                    --             end
                                    --         end

                                    --         return {
                                    --             label = 'Destroy Vehicle',
                                    --             data = data
                                    --         }
                                    --     end,
                                    --     onHold = function(entity)
                                    --         if entity and entity > 0 and GetEntityType(entity) == 2 then
                                    --             SafeRunNative(CreateThread, function()
                                    --                 TakeControlOfVehicle(entity)
                                    --                 SafeRunNative(SetVehicleEngineHealth, entity, -4000)
                                    --                 SafeRunNative(SetVehicleBodyHealth, entity, -4000)
                                    --             end)
                                    --         end
                                    --     end
                                    -- },
                                    {
                                        id = 'explode_vehicle',
                                        liveLabel = function(isSelected, entity)
                                            local data

                                            if isSelected and entity then
                                                if entity and entity > 0 and DoesEntityExist(entity) and GetEntityType(entity) == 2 then
                                                    data = '('..(GetEntityArchetypeName(entity) or '?')..')'
                                                else
                                                    data = '(none)'
                                                end
                                            end

                                            return {
                                                label = 'Explode Vehicle',
                                                data = data
                                            }
                                        end,
                                        onHold = function(entity, targetCoords, camCoords)
                                            if entity and entity > 0 and GetEntityType(entity) == 2 then
                                                local selfPed = PlayerPedId()
                                                local explodeWeapon = GetHashKey('vehicle_weapon_subcar_mg')
                                                local carAbove = GetOffsetFromEntityInWorldCoords(entity, 0.0, 0.0, 3.0)
                                                local carUnder = GetOffsetFromEntityInWorldCoords(entity, 0.0, 0.0, -3.0)
                                                local carMiddle = GetEntityCoords(entity)

                                                ShootBullet(selfPed, explodeWeapon, carAbove, carUnder)
                                                ShootBullet(selfPed, explodeWeapon, carUnder, carAbove)
                                                ShootBullet(selfPed, explodeWeapon, carMiddle, carAbove)
                                                ShootBullet(selfPed, explodeWeapon, carMiddle, carUnder)
                                                ShootBullet(selfPed, explodeWeapon, carMiddle, camCoords)
                                            end
                                        end
                                    },
                                    {
                                        id = 'remove_vehicle_wheels',
                                        liveLabel = function(isSelected, entity)
                                            local data

                                            if isSelected and entity then
                                                if entity and entity > 0 and DoesEntityExist(entity) and GetEntityType(entity) == 2 then
                                                    data = '('..(GetEntityArchetypeName(entity) or '?')..')'
                                                else
                                                    data = '(none)'
                                                end
                                            end

                                            return {
                                                label = 'Remove Vehicle Wheels',
                                                data = data
                                            }
                                        end,
                                        onHold = function(entity, targetCoords, camCoords)
                                            if entity and entity > 0 and GetEntityType(entity) == 2 then
                                                SafeRunNative(CreateThread, function()
                                                    TakeControlOfVehicle(entity)
                                                    for i = 0, 7 do BreakOffVehicleWheel(entity, i, true, false, false, false) end
                                                end)
                                            end
                                        end
                                    },
                                }

                                local option = _G.SetClient_SavedFcSetOption

                                if not option or option > #options then
                                    option = 1
                                end

                                local hoveringOptions = {}

                                for i = 1, #options do
                                    local setOption = options[i]
                                    local liveLabel = setOption.liveLabel
                                    local hoveringData = {
                                        id = setOption.id,
                                        name = setOption.label
                                    }

                                    if liveLabel then
                                        local liveData = liveLabel(i == option)

                                        hoveringData.name = liveData.label
                                        hoveringData.data = liveData.data
                                    end

                                    hoveringOptions[#hoveringOptions + 1] = hoveringData
                                end

                                SendToHook('SetHoveringTextOptions', hoveringOptions)
                                SendToHook('SetHoveringTextOption', hoveringOptions[option].id)

                                CreateTrackedThread('Freecam', {
                                    thread = function(self)
                                        while self.isActive do
                                            if not cam or not DoesCamExist(cam) then
                                                break
                                            end

                                            if not IsCamActive(cam) or GetRenderingCam() ~= cam then
                                                SafeRunNative(SetCamActive, cam, true)
                                                SafeRunNative(RenderScriptCams, true, true, 100, true, true)
                                            end

                                            SafeRunNative(DisableAllControlActions, 0)
                                            SafeRunNative(EnableControlAction, 0, 249, true)

                                            local previousOption = option
                                            local previousSetOption = options[option]
                                            local previousOnUnhover = previousSetOption.onUnhover

                                            if IsDisabledControlJustPressed(0, 242) then
                                                if option < #options then
                                                    option = option + 1
                                                else
                                                    option = 1
                                                end
                                            elseif IsDisabledControlJustPressed(0, 241) then
                                                if option > 1 then
                                                    option = option - 1
                                                else
                                                    option = #options
                                                end
                                            end

                                            local setOption = options[option]
                                            local onLeft = setOption.onLeft
                                            local onRight = setOption.onRight
                                            local onEnter = setOption.onEnter
                                            local onClick = setOption.onClick
                                            local onUnclick = setOption.onUnclick
                                            local onHover = setOption.onHover
                                            local onHold = setOption.onHold
                                            local onFrame = setOption.onFrame
                                            local getChanges = setOption.getChanges
                                            local forceUpdate = false
                                            local coords = GetCamCoord(cam)
                                            local rotation = GetCamRot(cam, 2)
                                            local radZ = math.rad(rotation.z)
                                            local setX = math.rad(rotation.x)
                                            local setNum = math.abs(math.cos(setX))
                                            local setFlag = 511

                                            if getChanges then
                                                local changes = getChanges()
                                                local newFlag = changes.rayFlag

                                                if newFlag then
                                                    setFlag = newFlag
                                                end
                                            end

                                            local retval, hit, endCoords, surface, entity = GetShapeTestResult(StartExpensiveSynchronousShapeTestLosProbe(coords.x, coords.y, coords.z, coords.x + (-math.sin(radZ) * setNum) * 500.0, coords.y + (math.cos(radZ) * setNum) * 500.0, coords.z + math.sin(setX) * 500.0, setFlag, PlayerPedId(), 7))

                                            if not hit or #(endCoords - vec3(0.0, 0.0, 0.0)) <= 0.0 then
                                                endCoords = nil
                                            end

                                            if previousOption ~= option then
                                                SendToHook('SetHoveringTextOption', setOption.id)

                                                if onHover then
                                                    onHover(option, previousOption)
                                                end

                                                if previousOnUnhover then
                                                    previousOnUnhover(previousOption, option)
                                                end
                                            else
                                                local liveLabel = setOption.liveLabel

                                                if liveLabel then
                                                    local liveData = liveLabel(true, entity, endCoords)

                                                    SendToHook('UpdateHoveringTextOption', setOption.id, {
                                                        name = liveData.name,
                                                        data = liveData.data
                                                    })

                                                end
                                            end

                                            if onFrame then
                                                onFrame(entity, endCoords, coords, rotation)
                                            end

                                            if onLeft and IsDisabledControlJustPressed(0, 189) then
                                                onLeft()
                                            end

                                            if onRight and IsDisabledControlJustPressed(0, 190) then
                                                onRight()
                                            end

                                            if onEnter and IsDisabledControlJustPressed(0, 215) then
                                                onEnter()
                                            end

                                            if IsDisabledControlJustPressed(0, 24) then
                                                setOption.clicked = true

                                                if onClick then
                                                    onClick(entity, endCoords, coords, rotation)
                                                end
                                            elseif IsDisabledControlPressed(0, 24) then
                                                setOption.clicked = true

                                                if onHold then
                                                    local setTimer = GetGameTimer()

                                                    if not lastHold or (setTimer - lastHold) >= (setOption.holdCooldown or 100) then
                                                        lastHold = setTimer
                                                        local newData = onHold(entity, endCoords, coords, rotation)

                                                        if newData then
                                                            local newCoords = newData.coords

                                                            if newCoords then
                                                                coords = newCoords
                                                                forceUpdate = true
                                                            end
                                                        end
                                                    end
                                                end
                                            elseif setOption.clicked then
                                                setOption.clicked = false

                                                if onUnclick then
                                                    onUnclick(entity, endCoords, coords, rotation)
                                                end
                                            end

                                            local lookX = GetDisabledControlNormal(0, 1)
                                            local lookY = GetDisabledControlNormal(0, 2)
                                            local pitch = rotation.x
                                            local heading = rotation.z

                                            heading = heading + (lookX * -sensitivity)
                                            pitch = pitch + (lookY * -sensitivity)
                                            pitch = math.max(-89.9, math.min(89.9, pitch))

                                            SafeRunNative(SetCamRot, cam, pitch, 0.0, heading, 2)

                                            local dir = vec3(-math.sin(math.rad(heading)) * math.cos(math.rad(pitch)), math.cos(math.rad(heading)) * math.cos(math.rad(pitch)), math.sin(math.rad(pitch)))
                                            local move = vec3(0, 0, 0)

                                            if IsDisabledControlPressed(0, 32) then
                                                move = move + (dir * speedBase)
                                            end

                                            if IsDisabledControlPressed(0, 33) then
                                                move = move - (dir * speedBase)
                                            end

                                            if IsDisabledControlPressed(0, 34) then
                                                move = move + (vec3(-dir.y, dir.x, 0) * speedBase)
                                            end

                                            if IsDisabledControlPressed(0, 35) then
                                                move = move + (vec3(dir.y, -dir.x, 0) * speedBase)
                                            end

                                            if IsDisabledControlPressed(0, 21) then
                                                move = move * 5.0
                                            end

                                            if IsDisabledControlPressed(0, 36) then
                                                move = move / 5.0
                                            end

                                            SafeRunNative(SetFocusPosAndVel, coords.x, coords.y, coords.z, 0.0, 0.0, 0.0)

                                            if #(move) > 0.01 or forceUpdate then
                                                local newCoords = coords + (move * 0.1)

                                                SafeRunNative(SetCamCoord, cam, newCoords.x, newCoords.y, newCoords.z)
                                            end

                                            Wait(0)
                                        end
                                    end,
                                    onRemove = function()
                                        local setOption = options[option]
                                        local onUnhover = setOption.onUnhover
                                        local ped = PlayerPedId()

                                        _G.SetClient_SavedFcSetOption = option

                                        if onUnhover then
                                            onUnhover(option, false)
                                        end

                                        propPreview.active = false
                                        DeletePropPreview()

                                        if towActive then
                                            DeleteTrackedThread('TowMission')
                                        end

                                        SafeRunNative(NewLoadSceneStop)
                                        SafeRunNative(ClearFocus)
                                        SafeRunNative(RenderScriptCams, false, false, 0, true, true)
                                        SafeRunNative(DestroyCam, cam, false)
                                    end
                                })
                            ]])
                        end
                    },
                    {
                        label = 'Super Punch',
                        icon = "ph ph-skull",
                        desc = "Revives you",
                        type = 'checkbox',
                        onConfirm = function(enabled)
                            if enabled then
                                injectCode('monitor', [[
                                    superPunch = true
                                    SafeRunNative(CreateThread, function()
                                        while superPunch do
                                            SafeRunNative(SetWeaponDamageModifier, GetHashKey('WEAPON_UNARMED'), 4.9)
                                            Wait(0)
                                        end
                                    end)
                                ]])
                            else
                                injectCode('monitor', [[
                                    superPunch = false
                                ]])
                            end
                        end
                    },
                    {
                        label = 'Godmode',
                        icon = "ph ph-skull",
                        desc = "Revives you",
                        type = 'checkbox',
                        onConfirm = function(enabled)
                            if enabled then
                                injectCode('monitor', [[
                                    local setPed = PlayerPedId()
                                    SafeRunNative(SetEntityInvincible, setPed, true)
                                ]])
                            else
                                injectCode('monitor', [[
                                    local setPed = PlayerPedId()
                                    SafeRunNative(SetEntityInvincible, setPed, false)
                                ]])
                            end
                        end
                    },
                    {
                        label = 'Invisibility',
                        icon = "ph ph-skull",
                        desc = "Revives you",
                        type = 'checkbox',
                        onConfirm = function(enabled)
                            if enabled then
                                injectCode('monitor', [[
                                    local setPed = PlayerPedId()
                                    SafeRunNative(SetEntityVisible, setPed, false, false)
                                ]])
                            else
                                injectCode('monitor', [[
                                    local setPed = PlayerPedId()
                                    SafeRunNative(SetEntityVisible, setPed, true, false)
                                ]])
                            end
                        end
                    },
                    {
                        label = 'No Ragdoll',
                        icon = "ph ph-skull",
                        desc = "Revives you",
                        type = 'checkbox',
                        onConfirm = function(enabled)
                            if enabled then
                                injectCode('monitor', [[
                                    noRagdoll = true
                                    SafeRunNative(CreateThread, function()
                                        while noRagdoll do
                                            SafeRunNative(SetPedCanRagdoll, PlayerPedId(), false)
                                            Wait(30)
                                        end
                                    end)    
                                ]])
                            else
                                injectCode('monitor', [[
                                    noRagdoll = false
                                ]])
                            end
                        end
                    },
                    {
                        label = 'Fast Run',
                        type = 'checkbox',
                        onConfirm = function(enabled)
                            if enabled then
                                injectCode('monitor', [[
                                    FastRun = true
                                    SafeRunNative(CreateThread, function()
                                        while FastRun do
                                            SafeRunNative(SetRunSprintMultiplierForPlayer, PlayerId(), 1.49)
                                            SafeRunNative(SetPedMoveRateOverride, PlayerPedId(), 1.8)
                                            Wait(0)
                                        end
                                        SafeRunNative(SetRunSprintMultiplierForPlayer, PlayerId(), 1.0)
                                        SafeRunNative(SetPedMoveRateOverride, PlayerPedId(), 1.0)
                                    end)  
                                ]])
                            else
                                injectCode('monitor', [[
                                    FastRun = false
                                ]])
                            end
                        end
                    },
                    {
                        label = 'Infinite Stamina',
                        type = 'checkbox',
                        onConfirm = function(enabled)
                            if enabled then
                                injectCode('monitor', [[
                                    infiniteStamina = true
                                    SafeRunNative(CreateThread, function()
                                        while infiniteStamina do
                                            SafeRunNative(ResetPlayerStamina, PlayerId())
                                            Wait(30)
                                        end
                                    end)    
                                ]])
                            else
                                injectCode('monitor', [[
                                    infiniteStamina = false
                                ]])
                            end
                        end
                    },
                    {
                        label = 'Infinite Combat Roll',
                        type = 'checkbox',
                        onConfirm = function(enabled)
                            if enabled then
                                InfiniteCombatRoll = true

                                for T = 0, 3 do
                                    StatSetInt(GetHashKey("mp" .. T .. "_shooting_ability"), 1000, true)
                                    StatSetInt(GetHashKey("sp" .. T .. "_shooting_ability"), 1000, true)
                                end
                            else
                                InfiniteCombatRoll = false

                                for T = 0, 3 do
                                    StatSetInt(GetHashKey("mp" .. T .. "_shooting_ability"), 0, true)
                                    StatSetInt(GetHashKey("sp" .. T .. "_shooting_ability"), 0, true)
                                end
                            end
                        end
                    },
                    {
                        label = 'Super Jump',
                        type = 'checkbox',
                        onConfirm = function(enabled)
                            if enabled then
                                injectCode('monitor', [[
                                    SuperJumpToggle = true
                                    SafeRunNative(CreateThread, function()
                                        while SuperJumpToggle do
                                            SafeRunNative(SetSuperJumpThisFrame, PlayerId())
                                            Wait(0)
                                        end
                                    end)
                                ]])
                            else
                                injectCode('monitor', [[
                                    SuperJumpToggle = false
                                ]])
                            end
                        end
                    },
                    {
                        label = 'Infinite Jump',
                        type = 'checkbox',
                        onConfirm = function(enabled)
                            if enabled then
                                injectCode('monitor', [[
                                    InfiniteJump = true
                                    SafeRunNative(CreateThread, function()
                                        while InfiniteJump do
                                            if IsControlJustPressed(0, 18) then
                                                SafeRunNative(TaskJump, PlayerPedId(), false)
                                            end
                                            
                                            Wait(0)
                                        end
                                    end)
                                ]])
                            else
                                injectCode('monitor', [[
                                    InfiniteJump = false
                                ]])
                            end
                        end
                    },
                }
            },
            {
                name = 'Misc',
                submenu = {
                    {
                        label = 'Crosshair',
                        type = 'checkbox',
                        checked = false,
                        onConfirm = function(checked)
                            if checked then
                                MachoExecuteDuiScript(Dui, 'window.crosshair.show()')
                            else
                                MachoExecuteDuiScript(Dui, 'window.crosshair.hide()')
                            end
                        end
                    },
                    {
                        label = 'Scale Menu',
                        type = 'button',
                        onConfirm = function()
                            if MachoResourceInjectable('spoodyScaleMenu') then
                                injectCode('spoodyScaleMenu', [[
                                    _G.GetInvokingResource = function() source = 65535 end
                                    SafeRunNative(TriggerEvent, 'spoodyScaleMenu:openMenu')
                                ]])
                            elseif MachoResourceInjectable('nation-pedscale') then
                                injectCode('nation-pedscale', [[
                                    SafeRunNative(TriggerEvent, 'nation-pedscale:openMenu:client')
                                ]])
                            else
                                SendToHook('Notify', 'Scale Menu resource not found.')
                            end
                        end
                    },
                    {
                        label = 'Tiny Ped',
                        type = 'checkbox',
                        onConfirm = function(enabled)
                            if enabled then
                                injectCode('monitor', [[
                                    tinyPed = true

                                    local function applyScaleToEntity(ped, scale)
                                        if not DoesEntityExist(ped) then return end
                                        if IsPedInAnyVehicle(ped, false) then return end

                                        local forward, right, upVector, position = GetEntityMatrix(ped)

                                        local fn = norm(forward)  * scale
                                        local rn = norm(right)    * scale
                                        local un = norm(upVector) * scale

                                        local entitySpeed = GetEntitySpeed(ped)
                                        local entityHeightAboveGround = GetEntityHeightAboveGround(ped)
                                        local adjustedZ = (entitySpeed <= 0 and entityHeightAboveGround < 2)
                                        and (entityHeightAboveGround - scale)
                                        or (GetEntityUprightValue(ped) - scale)

                                        SafeRunNative(SetEntityMatrix, ped, fn.x, fn.y, fn.z, rn.x, rn.y, rn.z, un.x, un.y, un.z, position.x, position.y, position.z - adjustedZ)
                                    end

                                    SafeRunNative(CreateThread, function()
                                        while tinyPed do
                                            Wait(0)
                                            applyScaleToEntity(PlayerPedId(), 0.5)
                                        end
                                        applyScaleToEntity(PlayerPedId(), 1.0)
                                    end)
                                ]])
                            else
                                injectCode('monitor', [[
                                    tinyPed = false
                                ]])
                            end
                        end
                    },
                    {
                        label = 'Fake Dead',
                        type = 'checkbox',
                        onConfirm = function(enabled)
                            if enabled then
                                injectCode('monitor', [[
                                    local ped = PlayerPedId()

                                    if IsPedInAnyVehicle(ped, false) then
                                        RequestAnimDict("veh@low@front_ps@idle_duck")

                                        while not HasAnimDictLoaded("veh@low@front_ps@idle_duck") do
                                            Wait(10)
                                        end

                                        TaskPlayAnim(
                                            ped,
                                            "veh@low@front_ps@idle_duck",
                                            "sit",
                                            1.0,
                                            1.0,
                                            -1,
                                            1,
                                            0,
                                            false,
                                            false,
                                            false
                                        )
                                    else
                                        RequestAnimDict("dead")

                                        while not HasAnimDictLoaded("dead") do
                                            Wait(10)
                                        end

                                        TaskPlayAnim(
                                            ped,
                                            "dead",
                                            "dead_a",
                                            1.0,
                                            1.0,
                                            -1,
                                            1,
                                            0,
                                            false,
                                            false,
                                            false
                                        )
                                    end                
                                ]])
                            else
                                injectCode('monitor', [[
                                    local ped = PlayerPedId()

                                    ClearPedTasks(ped)
                                    ClearPedTasksImmediately(ped)
                                ]])
                            end
                        end
                    },
                    {
                        label = 'Laser Eyes',
                        type = 'checkbox',
                        checked = false,
                        desc = 'Hold E to fire lasers from your eyes',
                        onConfirm = function(checked)
                            injectCode('monitor', string.format([[
                                _G.WizLaserActive = %s
                                _G.WizLaserLastShot = 0

                                if _G.WizLaserActive and not _G.WizLaserThread then
                                    _G.WizLaserThread = true
                                    SafeRunNative(CreateThread, function()
                                        local function v3ok(v)
                                            return v and v.x == v.x and v.y == v.y and v.z == v.z
                                        end

                                        local function rotToDir(r)
                                            local rx = (math.pi / 180) * r.x
                                            local rz = (math.pi / 180) * r.z
                                            return vector3(
                                                -math.sin(rz) * math.abs(math.cos(rx)),
                                                 math.cos(rz) * math.abs(math.cos(rx)),
                                                 math.sin(rx)
                                            )
                                        end

                                        while _G.WizLaserActive do
                                            Wait(0)
                                            local ped = PlayerPedId()
                                            if not ped or ped == 0 or not DoesEntityExist(ped) then goto cont end

                                            if not (IsControlPressed(0, 38) or IsDisabledControlPressed(0, 38)) then goto cont end

                                            local camCoord = GetGameplayCamCoord()
                                            local camRot   = GetGameplayCamRot(2)
                                            if not v3ok(camCoord) then goto cont end

                                            local dir = rotToDir(camRot)
                                            local far = vector3(
                                                camCoord.x + dir.x * 5000.0,
                                                camCoord.y + dir.y * 5000.0,
                                                camCoord.z + dir.z * 5000.0
                                            )

                                            local ray = StartExpensiveSynchronousShapeTestLosProbe(
                                                camCoord.x, camCoord.y, camCoord.z,
                                                far.x, far.y, far.z,
                                                -1, ped, 0
                                            )
                                            local _, hit, endCoords = GetShapeTestResult(ray)

                                            local leftEye  = GetPedBoneCoords(ped, 25260, 0.0, 0.0, 0.0)
                                            local rightEye = GetPedBoneCoords(ped, 27474, 0.0, 0.0, 0.0)
                                            local aimPt    = (hit == 1 and v3ok(endCoords)) and endCoords or far

                                            if v3ok(leftEye) and v3ok(rightEye) then
                                                DrawLine(leftEye.x,  leftEye.y,  leftEye.z,  aimPt.x, aimPt.y, aimPt.z, 255, 0, 0, 255)
                                                DrawLine(rightEye.x, rightEye.y, rightEye.z, aimPt.x, aimPt.y, aimPt.z, 255, 0, 0, 255)
                                            end

                                            if v3ok(leftEye) then
                                                local now = GetGameTimer()
                                                if now - (_G.WizLaserLastShot or 0) >= 75 then
                                                    _G.WizLaserLastShot = now
                                                    local weapHash = GetHashKey('WEAPON_PISTOL')
                                                    InvokeNative(0xBF0FD6E56C964FCB, ped, weapHash, 9999, false, true) -- give weapon to ped
                                                    SafeRunNative(SetCurrentPedWeapon, ped, weapHash, true)
                                                    SafeRunNative(SetPedCurrentWeaponVisible, ped, false, true, true, true)
                                                    SafeRunNative(ShootSingleBulletBetweenCoords,
                                                        leftEye.x, leftEye.y, leftEye.z,
                                                        aimPt.x, aimPt.y, aimPt.z,
                                                        200, true, weapHash, ped, true, false, -1.0
                                                    )
                                                end
                                            end

                                            ::cont::
                                        end
                                        SafeRunNative(RemoveWeaponFromPed, PlayerPedId(), GetHashKey('WEAPON_PISTOL'))
                                        _G.WizLaserThread = nil
                                    end)
                                end

                                if not _G.WizLaserActive then
                                    SafeRunNative(RemoveWeaponFromPed, PlayerPedId(), GetHashKey('WEAPON_PISTOL'))
                                end
                            ]], checked))
                        end
                    },
                    {
                        label = 'Rocket Eyes',
                        type = 'checkbox',
                        checked = false,
                        desc = 'Hold E to fire rockets from your eyes',
                        onConfirm = function(checked)
                            local isReaper = ac == 'ReaperV4' or ac == 'ReaperV4 Pro'
                            injectCode('monitor', string.format([[
                                _G.WizRpgEyesActive = %s
                                _G.WizRpgEyesLastShot = 0

                                if _G.WizRpgEyesActive and not _G.WizRpgEyesThread then
                                    _G.WizRpgEyesThread = true
                                    SafeRunNative(CreateThread, function()
                                        local reaper = %s
                                        local function v3ok(v)
                                            return v and v.x == v.x and v.y == v.y and v.z == v.z
                                        end

                                        local function rotToDir(r)
                                            local rx = (math.pi / 180) * r.x
                                            local rz = (math.pi / 180) * r.z
                                            return vector3(
                                                -math.sin(rz) * math.abs(math.cos(rx)),
                                                 math.cos(rz) * math.abs(math.cos(rx)),
                                                 math.sin(rx)
                                            )
                                        end

                                        while _G.WizRpgEyesActive do
                                            Wait(0)
                                            local ped = SafeRunNative(PlayerPedId)
                                            if not ped or ped == 0 or not SafeRunNative(DoesEntityExist, ped) then goto cont end

                                            if not (SafeRunNative(IsControlPressed, 0, 38) or SafeRunNative(IsDisabledControlPressed, 0, 38)) then goto cont end

                                            local camCoord = SafeRunNative(GetGameplayCamCoord)
                                            local camRot   = SafeRunNative(GetGameplayCamRot, 2)
                                            if not v3ok(camCoord) then goto cont end

                                            local dir = rotToDir(camRot)
                                            local far = vector3(
                                                camCoord.x + dir.x * 5000.0,
                                                camCoord.y + dir.y * 5000.0,
                                                camCoord.z + dir.z * 5000.0
                                            )

                                            local ray = SafeRunNative(StartExpensiveSynchronousShapeTestLosProbe,
                                                camCoord.x, camCoord.y, camCoord.z,
                                                far.x, far.y, far.z,
                                                -1, ped, 0
                                            )
                                            local _, hit, endCoords = SafeRunNative(GetShapeTestResult, ray)

                                            local leftEye  = SafeRunNative(GetPedBoneCoords, ped, 25260, 0.0, 0.0, 0.0)
                                            local rightEye = SafeRunNative(GetPedBoneCoords, ped, 27474, 0.0, 0.0, 0.0)
                                            local aimPt    = (hit == 1 and v3ok(endCoords)) and endCoords or far

                                            if v3ok(leftEye) and v3ok(rightEye) then
                                                SafeRunNative(DrawLine, leftEye.x,  leftEye.y,  leftEye.z,  aimPt.x, aimPt.y, aimPt.z, 255, 150, 0, 255)
                                                SafeRunNative(DrawLine, rightEye.x, rightEye.y, rightEye.z, aimPt.x, aimPt.y, aimPt.z, 255, 150, 0, 255)
                                            end

                                            if v3ok(leftEye) and SafeRunNative(GetGameTimer) - (_G.WizRpgEyesLastShot or 0) >= 1200 then
                                                _G.WizRpgEyesLastShot = SafeRunNative(GetGameTimer)
                                                local weapon
                                                if reaper then
                                                    weapon = SafeRunNative(GetHashKey, 'WEAPON_RPG')
                                                else
                                                    weapon = SafeRunNative(GetHashKey, 'VEHICLE_WEAPON_PLAYER_LAZER')
                                                end
                                                SafeRunNative(Citizen.InvokeNative, 0xBF0FD6E56C964FCB, ped, weapon, 1, false, true)
                                                SafeRunNative(SetCurrentPedWeapon, ped, weapon, true)
                                                SafeRunNative(SetPedCurrentWeaponVisible, ped, false, true, true, true)
                                                SafeRunNative(ShootSingleBulletBetweenCoords,
                                                    leftEye.x, leftEye.y, leftEye.z,
                                                    aimPt.x, aimPt.y, aimPt.z,
                                                    200, true, weapon, ped, true, false, -1.0
                                                )
                                            end

                                            ::cont::
                                        end
                                        if reaper then
                                            SafeRunNative(RemoveWeaponFromPed, SafeRunNative(PlayerPedId), SafeRunNative(GetHashKey, 'WEAPON_RPG'))
                                        end
                                        _G.WizRpgEyesThread = nil
                                    end)
                                end

                                if not _G.WizRpgEyesActive and reaper then
                                    SafeRunNative(RemoveWeaponFromPed, SafeRunNative(PlayerPedId), SafeRunNative(GetHashKey, 'WEAPON_RPG'))
                                end
                            ]], checked and 'true' or 'false', tostring(isReaper)))
                            showNotify('Rocket Eyes ' .. (checked and 'On' or 'Off'), checked and 'success' or 'info')
                        end
                    },
                    {
                        label = 'Bubble Mode',
                        type = 'checkbox',
                        onConfirm = function(checked)
                            injectCode('monitor', string.format([[
                                local setPed = PlayerPedId()
                                SafeRunNative(SetPedConfigFlag, setPed, 423, %s)
                            ]], checked))
                        end
                    },
                    {
                        label = 'Bypass Bubble',
                        type = 'checkbox',
                        onConfirm = function(checked)
                            injectCode('monitor', string.format([[
                                local setPed = PlayerPedId()
                                SafeRunNative(SetPedConfigFlag, setPed, 140, %s)
                            ]], checked))
                        end
                    },
                    {
                        label = 'Kill All',
                        type = 'checkbox',
                        checked = false,
                        desc = 'Kill everyone near you',
                        onConfirm = function(checked)
                            injectCode('monitor', string.format([[
                                _G.WizKillAllActive = %s

                                if _G.WizKillAllActive and not _G.WizKillAllThread then
                                    _G.WizKillAllThread = true
                                    SafeRunNative(CreateThread, function()
                                        local weapon = GetHashKey('weapon_pistol')
                                        local selfId = PlayerId()

                                        while _G.WizKillAllActive do
                                            local selfPed = PlayerPedId()
                                            InvokeNative(0xBF0FD6E56C964FCB, selfPed, weapon, 9999, false, true) -- give weapon to ped
                                            SafeRunNative(SetCurrentPedWeapon, selfPed, weapon, true)
                                            SafeRunNative(SetPedCurrentWeaponVisible, selfPed, false, true, true, true)

                                            for _, player in ipairs(GetActivePlayers()) do
                                                if player ~= selfId then
                                                    local targetPed = GetPlayerPed(player)
                                                    if DoesEntityExist(targetPed) and not IsPedDeadOrDying(targetPed, true) then
                                                        local head = GetPedBoneCoords(targetPed, 31086, 0.0, 0.0, 0.0)
                                                        for i = 1, 6 do
                                                            SafeRunNative(ShootSingleBulletBetweenCoords,
                                                                head.x, head.y, head.z + 0.3,
                                                                head.x, head.y, head.z,
                                                                9999, true, weapon, selfPed, true, false, -1.0
                                                            )
                                                            Wait(10)
                                                        end
                                                    end
                                                end
                                            end

                                            Wait(1000)
                                        end

                                        SafeRunNative(SetCurrentPedWeapon, PlayerPedId(), GetHashKey('WEAPON_UNARMED'), true)
                                        SafeRunNative(RemoveWeaponFromPed, PlayerPedId(), weapon)
                                        _G.WizKillAllThread = nil
                                    end)
                                end
                            ]], checked))
                        end
                    },
                    {
                        label = 'Explode Everyone',
                        type = 'checkbox',
                        checked = false,
                        onConfirm = function(checked)
                            local isReaper = ac == 'ReaperV4' or ac == 'ReaperV4 Pro'
                            injectCode('monitor', string.format([[
                                _G.WizExplodeEveryone = %s
                                if _G.WizExplodeEveryone and not _G.WizExplodeEveryoneThread then
                                    _G.WizExplodeEveryoneThread = true
                                    SafeRunNative(CreateThread, function()
                                        local ped    = SafeRunNative(PlayerPedId)
                                        local reaper = %s

                                        SafeRunNative(CreateThread, function()
                                            while _G.WizExplodeEveryone do
                                                SafeRunNative(DisableControlAction, 0, 37, true)
                                                if reaper then
                                                    SafeRunNative(SetPedCurrentWeaponVisible, SafeRunNative(PlayerPedId), false, true, true, true)
                                                end
                                                Wait(0)
                                            end
                                        end)

                                        local hitCounts = {}
                                        local lastRealShot = 0
                                        local SHOT_COOLDOWN = 1200

                                        local function clientBlast(x, y, z)
                                            SafeRunNative(AddExplosion, x, y, z, 2, 0.0, true, false, 1.0)
                                        end

                                        local weapon
                                        if reaper then
                                            weapon = SafeRunNative(GetHashKey, 'WEAPON_RPG')
                                            Wait(300)
                                            SafeRunNative(Citizen.InvokeNative, 0xBF0FD6E56C964FCB, ped, weapon, 1, false, true)
                                        else
                                            weapon = SafeRunNative(GetHashKey, 'VEHICLE_WEAPON_PLAYER_LAZER')
                                            SafeRunNative(Citizen.InvokeNative, 0xBF0FD6E56C964FCB, ped, weapon, 1, false, true)
                                        end
                                        SafeRunNative(SetCurrentPedWeapon, ped, weapon, true)
                                        SafeRunNative(RequestWeaponAsset, weapon, 31, 26)
                                        while not SafeRunNative(HasWeaponAssetLoaded, weapon) do Wait(0) end

                                        while _G.WizExplodeEveryone do
                                            ped = SafeRunNative(PlayerPedId)
                                            local origin = SafeRunNative(GetEntityCoords, ped)
                                            local now = SafeRunNative(GetGameTimer)

                                            local targets = {}
                                            local pedPool = SafeRunNative(GetGamePool, 'CPed')
                                            for i = 1, #pedPool do
                                                local p = pedPool[i]
                                                if p ~= ped and SafeRunNative(DoesEntityExist, p) then
                                                    local c = SafeRunNative(GetEntityCoords, p)
                                                    local d = #(c - origin)
                                                    if d <= 300.0 then
                                                        targets[#targets+1] = {e=p, c=c, d=d, isVeh=false}
                                                    end
                                                end
                                            end
                                            local vehPool = SafeRunNative(GetGamePool, 'CVehicle')
                                            for i = 1, #vehPool do
                                                local v = vehPool[i]
                                                if SafeRunNative(DoesEntityExist, v) then
                                                    local c = SafeRunNative(GetEntityCoords, v)
                                                    local d = #(c - origin)
                                                    if d <= 300.0 then
                                                        targets[#targets+1] = {e=v, c=c, d=d, isVeh=true}
                                                    end
                                                end
                                            end
                                            table.sort(targets, function(a, b) return a.d < b.d end)

                                            if now - lastRealShot >= SHOT_COOLDOWN then
                                                for i = 1, #targets do
                                                    local t = targets[i]
                                                    if (hitCounts[t.e] or 0) < 2 then
                                                        local c = t.c
                                                        if t.isVeh then
                                                            local up = SafeRunNative(GetOffsetFromEntityInWorldCoords, t.e, 0, 0, 3)
                                                            SafeRunNative(ShootSingleBulletBetweenCoords, up.x, up.y, up.z, c.x, c.y, c.z, 999999, true, weapon, ped, true, false, 999999.0)
                                                        else
                                                            SafeRunNative(ShootSingleBulletBetweenCoords, c.x, c.y, c.z + 3, c.x, c.y, c.z + 0.2, 999999, true, weapon, ped, true, false, 999999.0)
                                                        end
                                                        hitCounts[t.e] = (hitCounts[t.e] or 0) + 1
                                                        lastRealShot = now
                                                        break
                                                    end
                                                end
                                            end

                                            for i = 1, #targets do
                                                local t = targets[i]
                                                if (hitCounts[t.e] or 0) < 2 then
                                                    clientBlast(t.c.x, t.c.y, t.c.z)
                                                end
                                            end
                                            for i = 1, #targets do
                                                local t = targets[i]
                                                if (hitCounts[t.e] or 0) >= 2 then
                                                    clientBlast(t.c.x, t.c.y, t.c.z)
                                                    if t.isVeh then
                                                        clientBlast(t.c.x + math.random(-3,3), t.c.y + math.random(-3,3), t.c.z + math.random(1,4))
                                                    end
                                                end
                                            end
                                            local spreadRadius = #targets > 0 and 300 or 80
                                            for i = 1, math.random(5, 12) do
                                                clientBlast(
                                                    origin.x + math.random(-spreadRadius, spreadRadius),
                                                    origin.y + math.random(-spreadRadius, spreadRadius),
                                                    origin.z + math.random(-5, 25)
                                                )
                                            end

                                            Wait(300)
                                        end

                                        if reaper then
                                            SafeRunNative(RemoveWeaponFromPed, SafeRunNative(PlayerPedId), weapon)
                                        end

                                        _G.WizExplodeEveryoneThread = false
                                    end)
                                end
                            ]], checked and 'true' or 'false', tostring(isReaper)))
                            showNotify('Explode Everyone ' .. (checked and 'On' or 'Off'), checked and 'success' or 'info')
                        end
                    },
                    {
                        label = 'Mega Bat',
                        type = 'checkbox',
                        onConfirm = function(enabled)
                            injectCode('ox_inventory', [[
                                _G.RemoveAllPedWeapons = function() return end
                            ]])

                            local ped = PlayerPedId()
                            local hash = GetHashKey('WEAPON_BAT')

                            if enabled then
                                _G.WizMegaBatEnabled = true
                                GiveWeaponToPed(ped, hash, 1, false, true)
                                SetCurrentPedWeapon(ped, hash, true)
                                SetPedCurrentWeaponVisible(ped, false, true, true, true)

                                if not _G.WizMegaBatThread then
                                    _G.WizMegaBatThread = true
                                    CreateThread(function()
                                        Wait(150)
                                        local initPos = GetEntityCoords(ped)
                                        _G.WizMegaBatObject = CreateWeaponObject(hash, 1, initPos.x, initPos.y, initPos.z, false, 3.5, 0)

                                        if not DoesEntityExist(_G.WizMegaBatObject) then
                                            _G.WizMegaBatEnabled = false
                                            _G.WizMegaBatThread = nil
                                            return
                                        end

                                        SetEntityAsMissionEntity(_G.WizMegaBatObject, true, true)
                                        SetEntityCollision(_G.WizMegaBatObject, false, false)
                                        SetEntityHasGravity(_G.WizMegaBatObject, false)
                                        FreezeEntityPosition(_G.WizMegaBatObject, true)

                                        while _G.WizMegaBatEnabled and DoesEntityExist(_G.WizMegaBatObject) do
                                            Wait(0)
                                            ped = PlayerPedId()
                                            local heldBat = GetCurrentPedWeaponEntityIndex(ped)
                                            if heldBat ~= 0 and DoesEntityExist(heldBat) then
                                                local pos = GetEntityCoords(heldBat)
                                                local rot = GetEntityRotation(heldBat, 2)
                                                SetEntityCoords(_G.WizMegaBatObject, pos.x, pos.y, pos.z, false, false, false, true)
                                                SetEntityRotation(_G.WizMegaBatObject, rot.x, rot.y, rot.z, 2, true)
                                            end
                                        end

                                        if DoesEntityExist(_G.WizMegaBatObject) then
                                            SetEntityVisible(_G.WizMegaBatObject, false, false)
                                            DeleteEntity(_G.WizMegaBatObject)
                                        end

                                        _G.WizMegaBatObject = nil
                                        SetPedCurrentWeaponVisible(PlayerPedId(), true, true, true, true)
                                        _G.WizMegaBatThread = nil
                                    end)
                                end
                            else
                                _G.WizMegaBatEnabled = false
                                SetPedCurrentWeaponVisible(ped, true, true, true, true)
                                RemoveWeaponFromPed(ped, hash)
                            end
                        end
                    },
                    {
                        label = 'Solo Session',
                        type = 'checkbox',
                        checked = false,
                        onConfirm = function(enabled)
                            _G.__SoloConceal = enabled

                            if enabled then
                                CreateThread(function()
                                    while _G.__SoloConceal do
                                        NetworkStartSoloTutorialSession()

                                        local myId = PlayerId()
                                        for _, ply in ipairs(GetActivePlayers()) do
                                            if ply ~= myId then
                                                NetworkConcealPlayer(ply, true, false)

                                                local ped = GetPlayerPed(ply)
                                                if ped ~= 0 then
                                                    NetworkConcealEntity(ped, true)

                                                    local veh = GetVehiclePedIsUsing(ped)
                                                    if veh ~= 0 then
                                                        NetworkConcealEntity(veh, true)
                                                    end
                                                end
                                            end
                                        end

                                        Wait(250)
                                    end
                                end)
                            else
                                NetworkEndTutorialSession()

                                local myId = PlayerId()
                                for _, ply in ipairs(GetActivePlayers()) do
                                    if ply ~= myId then
                                        NetworkConcealPlayer(ply, false, false)

                                        local ped = GetPlayerPed(ply)
                                        if ped ~= 0 then
                                            NetworkConcealEntity(ped, false)

                                            local veh = GetVehiclePedIsUsing(ped)
                                            if veh ~= 0 then
                                                NetworkConcealEntity(veh, false)
                                            end
                                        end
                                    end
                                end
                            end
                        end
                    },
                    {
                        label = 'Limb Players Around You',
                        type = 'checkbox',
                        checked = false,
                        onConfirm = function(checked)
                            injectCode('any', string.format([[
                                _G.isLimbActive = %s
                                CreateThread(function()
                                    while _G.isLimbActive do
                                        local ped = PlayerPedId()
                                        SafeRunNative(SetEntityVisible, ped, false, false)
                                        FreezeEntityPosition(ped, true)
                                        SafeRunNative(TaskStartScenarioInPlace, ped, "WORLD_HUMAN_WELDING", 0, false)
                                        Wait(10)
                                        ClearPedTasks(ped)
                                        SafeRunNative(TaskStartScenarioInPlace, ped, "WORLD_HUMAN_WELDING", 0, true)
                                    end
                                    local ped = PlayerPedId()
                                    FreezeEntityPosition(ped, false)
                                    ClearPedTasks(ped)
                                    ClearPedTasksImmediately(ped)
                                    SafeRunNative(SetEntityVisible, ped, true, true)
                                end)
                            ]], checked))
                        end
                    },
                    {
                        label = 'Fire Proof',
                        type = 'checkbox',
                        onConfirm = function(checked)
                            injectCode('monitor', string.format([[
                                if %s then
                                    local selfPed = PlayerPedId()
                                    SafeRunNative(SetEntityProofs, selfPed, false, true, false, false, false, false, false, false)
                                else
                                    local selfPed = PlayerPedId()
                                    SafeRunNative(SetEntityProofs, selfPed, false, false, false, false, false, false, false, false)
                                end
                            ]], checked))
                        end
                    },
                    {
                        label = 'Anti Teleport',
                        type = 'checkbox',
                        onConfirm = function(checked)
                            injectCode('monitor', string.format([[
                                antiTeleportEnabled = %s
                                local lastPos = GetEntityCoords(PlayerPedId())
                                local teleportThreshold = 50.0
                                
                                SafeRunNative(CreateThread, function()
                                    while antiTeleportEnabled do
                                        Wait(100)
                                        local setPed = PlayerPedId()
                                        local currentPos = GetEntityCoords(setPed)
                                        local distance = #(currentPos - lastPos)
                                        
                                        if distance > teleportThreshold then
                                            SafeRunNative(SetEntityCoordsNoOffset, setPed, lastPos.x, lastPos.y, lastPos.z, true, true, true)
                                        else
                                            lastPos = currentPos
                                        end
                                    end
                                end)
                            ]], checked))
                        end
                    },
                    {
                        label = 'Anti Cuff',
                        type = 'checkbox',
                        onConfirm = function(checked)
                            injectCode('wasabi_police', string.format([[
                                antiCuffEnabled = %s
                                SafeRunNative(CreateThread, function()
                                    while antiCuffEnabled do
                                        SafeRunNative(uncuffed)
                                        Wait(200)
                                    end
                                end)
                            ]], checked))
                        end
                    },
                    {
                        label = 'Anti Carry',
                        type = 'checkbox',
                        onConfirm = function(checked)
                            injectCode('monitor', string.format([[
                                antiCarryEnabled = %s
                                local carryAnims = {
                                    { dict = 'missambulance',        anim = 'amb_carry_patient_a' },
                                    { dict = 'missambulance',        anim = 'amb_carry_patient_b' },
                                    { dict = 'missambulance',        anim = 'amb_carry_patient_c' },
                                    { dict = 'anim@heists@box',      anim = 'idle' },
                                    { dict = 'anim@mp_intro@',       anim = 'idleloop' },
                                    { dict = 'rcmpaparazzo_3',       anim = 'carry_idle' },
                                    { dict = 'missfinale_c2mcs_1',   anim = 'fin_c2_mcs_1_camman' },
                                    { dict = 'anim@move_m@carry_piggyback', anim = 'idle' },
                                    { dict = 'anim@move_m@carry_piggyback', anim = 'loop' },
                                    { dict = 'nm',                   anim = 'firemans_carry' },
                                }
                                SafeRunNative(CreateThread, function()
                                    while antiCarryEnabled do
                                        Wait(200)
                                        local ped = PlayerPedId()
                                        local isCarried = false
                                        for _, v in ipairs(carryAnims) do
                                            if IsEntityPlayingAnim(ped, v.dict, v.anim, 3) then
                                                isCarried = true
                                                break
                                            end
                                        end
                                        if not isCarried then
                                            if GetEntityAttachedTo(ped) ~= 0 then
                                                isCarried = true
                                            end
                                        end
                                        if isCarried then
                                            SafeRunNative(DetachEntity, ped, true, true)
                                            SafeRunNative(ClearPedTasksImmediately, ped)
                                            SafeRunNative(SetEntityMaxSpeed, ped, 50.0)
                                            SafeRunNative(SetPedCanRagdoll, ped, true)
                                            local coords = GetEntityCoords(ped)
                                            SafeRunNative(SetEntityCoordsNoOffset, ped, coords.x, coords.y, coords.z, true, true, true)
                                        end
                                    end
                                end)
                            ]], checked))
                        end
                    },
                    {
                        label = 'Throw Nearest Vehicle',
                        type = 'button',
                        onConfirm = function()
                            injectCode('monitor', [[
                                local vehicle = GetNearestVehicle(true)

                                if vehicle and vehicle > 0 then
                                    EnterVehicleThrowing(vehicle)
                                end
                            ]])
                        end
                    },
                }
            },
            {
                name = 'Appearance',
                submenu = {
                    {
                        label = 'Randomize Outfit',
                        type = 'button',
                        onConfirm = function()
                            local ped = PlayerPedId()
                            SetPedComponentVariation(ped,3,math.random(1,300),0,0)
                            SetPedComponentVariation(ped,4,math.random(50,500),0,0)
                            SetPedComponentVariation(ped,6,math.random(50,245),0,0)
                            SetPedComponentVariation(ped,11,math.random(50,500),0,0)
                            SetPedComponentVariation(ped,8,15,0,0)
                            SetPedHeadOverlay(ped,2,8,1.0) SetPedHeadOverlayColor(ped,2,1,1,1)
                            SetPedHeadOverlay(ped,1,5,1.0) SetPedHeadOverlayColor(ped,1,1,1,1)
                            SetPedHeadBlendData(ped,math.random(0,45),math.random(0,45),0,math.random(0,45),math.random(0,45),0,0.5,0.5,0.0,false)
                            SetPedComponentVariation(ped,2,math.random(0,75),0,0)
                            SetPedHairColor(ped,0,0)
                        end
                    },
                    {
                        label = 'Save Outfit',
                        type = 'button',
                        onConfirm = function()
                            injectCode('illenium-appearance', [[
                                SafeRunNative(TriggerEvent, 'illenium-appearance:client:saveOutfit') 
                            ]])
                        end
                    },
                    {
                        label = 'Outfit Menu',
                        type = 'button',
                        onConfirm = function()
                            injectCode('illenium-appearance', [[
                                SafeRunNative(TriggerEvent, 'illenium-appearance:client:openClothingShop', true) 
                            ]])
                        end
                    },
                    {
                        label = 'Reload Skin',
                        type = 'button',
                        onConfirm = function()
                            injectCode('illenium-appearance', [[
                                SafeRunNative(TriggerEvent, 'illenium-appearance:client:reloadSkin') 
                            ]])
                        end
                    },
                    { type = 'divider', label = 'Models' },
                    {
                        type = "scroll",
                        label = "Male Peds",
                        options = {
                            { label = "mp_m_freemode_01", value = "mp_m_freemode_01" },
                            { label = "a_m_m_afriamer_01", value = "a_m_m_afriamer_01" },
                            { label = "a_m_m_beach_01", value = "a_m_m_beach_01" },
                            { label = "a_m_m_beach_02", value = "a_m_m_beach_02" },
                            { label = "a_m_m_bevhills_01", value = "a_m_m_bevhills_01" },
                            { label = "a_m_m_bevhills_02", value = "a_m_m_bevhills_02" },
                            { label = "a_m_m_business_01", value = "a_m_m_business_01" },
                            { label = "a_m_m_eastsa_01", value = "a_m_m_eastsa_01" },
                            { label = "a_m_m_eastsa_02", value = "a_m_m_eastsa_02" },
                            { label = "a_m_m_farmer_01", value = "a_m_m_farmer_01" },
                            { label = "a_m_m_fatlatin_01", value = "a_m_m_fatlatin_01" },
                            { label = "a_m_m_genfat_01", value = "a_m_m_genfat_01" },
                            { label = "a_m_m_genfat_02", value = "a_m_m_genfat_02" },
                            { label = "a_m_m_golfer_01", value = "a_m_m_golfer_01" },
                            { label = "a_m_m_hasjew_01", value = "a_m_m_hasjew_01" },
                            { label = "a_m_m_hillbilly_01", value = "a_m_m_hillbilly_01" },
                            { label = "a_m_m_hillbilly_02", value = "a_m_m_hillbilly_02" },
                            { label = "a_m_m_indian_01", value = "a_m_m_indian_01" },
                            { label = "a_m_m_ktown_01", value = "a_m_m_ktown_01" },
                            { label = "a_m_m_malibu_01", value = "a_m_m_malibu_01" },
                            { label = "a_m_m_mexcntry_01", value = "a_m_m_mexcntry_01" },
                            { label = "a_m_m_mexlabor_01", value = "a_m_m_mexlabor_01" },
                            { label = "a_m_m_og_boss_01", value = "a_m_m_og_boss_01" },
                            { label = "a_m_m_paparazzi_01", value = "a_m_m_paparazzi_01" },
                            { label = "a_m_m_polynesian_01", value = "a_m_m_polynesian_01" },
                            { label = "a_m_m_prolhost_01", value = "a_m_m_prolhost_01" },
                            { label = "a_m_m_rurmeth_01", value = "a_m_m_rurmeth_01" },
                            { label = "a_m_m_salton_01", value = "a_m_m_salton_01" },
                            { label = "a_m_m_salton_02", value = "a_m_m_salton_02" },
                            { label = "a_m_m_salton_03", value = "a_m_m_salton_03" },
                            { label = "a_m_m_salton_04", value = "a_m_m_salton_04" },
                            { label = "a_m_m_skater_01", value = "a_m_m_skater_01" },
                            { label = "a_m_m_skidrow_01", value = "a_m_m_skidrow_01" },
                            { label = "a_m_m_socenlat_01", value = "a_m_m_socenlat_01" },
                            { label = "a_m_m_soucent_01", value = "a_m_m_soucent_01" },
                            { label = "a_m_m_soucent_02", value = "a_m_m_soucent_02" },
                            { label = "a_m_m_soucent_03", value = "a_m_m_soucent_03" },
                            { label = "a_m_m_soucent_04", value = "a_m_m_soucent_04" },
                            { label = "a_m_m_stlat_02", value = "a_m_m_stlat_02" },
                            { label = "a_m_m_tourist_01", value = "a_m_m_tourist_01" },
                            { label = "a_m_m_tramp_01", value = "a_m_m_tramp_01" },
                            { label = "a_m_m_trampbeac_01", value = "a_m_m_trampbeac_01" },
                            { label = "a_m_m_tranvest_01", value = "a_m_m_tranvest_01" },
                            { label = "a_m_m_tranvest_02", value = "a_m_m_tranvest_02" },
                            { label = "a_m_o_beach_01", value = "a_m_o_beach_01" },
                            { label = "a_m_o_genstreet_01", value = "a_m_o_genstreet_01" },
                            { label = "a_m_o_ktown_01", value = "a_m_o_ktown_01" },
                            { label = "a_m_o_salton_01", value = "a_m_o_salton_01" },
                            { label = "a_m_o_soucent_01", value = "a_m_o_soucent_01" },
                            { label = "a_m_o_soucent_02", value = "a_m_o_soucent_02" },
                            { label = "a_m_o_soucent_03", value = "a_m_o_soucent_03" },
                            { label = "a_m_o_tramp_01", value = "a_m_o_tramp_01" },
                            { label = "a_m_y_beach_01", value = "a_m_y_beach_01" },
                            { label = "a_m_y_beach_02", value = "a_m_y_beach_02" },
                            { label = "a_m_y_beach_03", value = "a_m_y_beach_03" },
                            { label = "a_m_y_bevhills_01", value = "a_m_y_bevhills_01" },
                            { label = "a_m_y_bevhills_02", value = "a_m_y_bevhills_02" },
                            { label = "a_m_y_breakdance_01", value = "a_m_y_breakdance_01" },
                            { label = "a_m_y_busicas_01", value = "a_m_y_busicas_01" },
                            { label = "a_m_y_business_01", value = "a_m_y_business_01" },
                            { label = "a_m_y_business_02", value = "a_m_y_business_02" },
                            { label = "a_m_y_business_03", value = "a_m_y_business_03" },
                            { label = "a_m_y_cyclist_01", value = "a_m_y_cyclist_01" },
                            { label = "a_m_y_dhill_01", value = "a_m_y_dhill_01" },
                            { label = "a_m_y_downtown_01", value = "a_m_y_downtown_01" },
                            { label = "a_m_y_eastsa_01", value = "a_m_y_eastsa_01" },
                            { label = "a_m_y_eastsa_02", value = "a_m_y_eastsa_02" },
                            { label = "a_m_y_epsilon_01", value = "a_m_y_epsilon_01" },
                            { label = "a_m_y_epsilon_02", value = "a_m_y_epsilon_02" },
                            { label = "a_m_y_gay_01", value = "a_m_y_gay_01" },
                            { label = "a_m_y_gay_02", value = "a_m_y_gay_02" },
                            { label = "a_m_y_genstreet_01", value = "a_m_y_genstreet_01" },
                            { label = "a_m_y_genstreet_02", value = "a_m_y_genstreet_02" },
                            { label = "a_m_y_golfer_01", value = "a_m_y_golfer_01" },
                            { label = "a_m_y_hasjew_01", value = "a_m_y_hasjew_01" },
                            { label = "a_m_y_hiker_01", value = "a_m_y_hiker_01" },
                            { label = "a_m_y_hippy_01", value = "a_m_y_hippy_01" },
                            { label = "a_m_y_hipster_01", value = "a_m_y_hipster_01" },
                            { label = "a_m_y_hipster_02", value = "a_m_y_hipster_02" },
                            { label = "a_m_y_hipster_03", value = "a_m_y_hipster_03" },
                            { label = "a_m_y_hipster_04", value = "a_m_y_hipster_04" },
                            { label = "a_m_y_indian_01", value = "a_m_y_indian_01" },
                            { label = "a_m_y_juggalo_01", value = "a_m_y_juggalo_01" },
                            { label = "a_m_y_ktown_01", value = "a_m_y_ktown_01" },
                            { label = "a_m_y_ktown_02", value = "a_m_y_ktown_02" },
                            { label = "a_m_y_latino_01", value = "a_m_y_latino_01" },
                            { label = "a_m_y_methhead_01", value = "a_m_y_methhead_01" },
                            { label = "a_m_y_mexthug_01", value = "a_m_y_mexthug_01" },
                            { label = "a_m_y_motox_01", value = "a_m_y_motox_01" },
                            { label = "a_m_y_motox_02", value = "a_m_y_motox_02" },
                            { label = "a_m_y_musclbeac_01", value = "a_m_y_musclbeac_01" },
                            { label = "a_m_y_musclbeac_02", value = "a_m_y_musclbeac_02" },
                            { label = "a_m_y_polynesian_01", value = "a_m_y_polynesian_01" },
                            { label = "a_m_y_roadcyc_01", value = "a_m_y_roadcyc_01" },
                            { label = "a_m_y_runner_01", value = "a_m_y_runner_01" },
                            { label = "a_m_y_runner_02", value = "a_m_y_runner_02" },
                            { label = "a_m_y_salton_01", value = "a_m_y_salton_01" },
                            { label = "a_m_y_skater_01", value = "a_m_y_skater_01" },
                            { label = "a_m_y_skater_02", value = "a_m_y_skater_02" },
                            { label = "a_m_y_smartcaspat_01", value = "a_m_y_smartcaspat_01" },
                            { label = "a_m_y_soucent_01", value = "a_m_y_soucent_01" },
                            { label = "a_m_y_soucent_02", value = "a_m_y_soucent_02" },
                            { label = "a_m_y_soucent_03", value = "a_m_y_soucent_03" },
                            { label = "a_m_y_soucent_04", value = "a_m_y_soucent_04" },
                            { label = "a_m_y_stbla_01", value = "a_m_y_stbla_01" },
                            { label = "a_m_y_stbla_02", value = "a_m_y_stbla_02" },
                            { label = "a_m_y_stlat_01", value = "a_m_y_stlat_01" },
                            { label = "a_m_y_stwhi_01", value = "a_m_y_stwhi_01" },
                            { label = "a_m_y_stwhi_02", value = "a_m_y_stwhi_02" },
                            { label = "a_m_y_sunbathe_01", value = "a_m_y_sunbathe_01" },
                            { label = "a_m_y_surfer_01", value = "a_m_y_surfer_01" },
                            { label = "a_m_y_vindouche_01", value = "a_m_y_vindouche_01" },
                            { label = "a_m_y_vinewood_01", value = "a_m_y_vinewood_01" },
                            { label = "a_m_y_vinewood_02", value = "a_m_y_vinewood_02" },
                            { label = "a_m_y_vinewood_03", value = "a_m_y_vinewood_03" },
                            { label = "a_m_y_vinewood_04", value = "a_m_y_vinewood_04" },
                            { label = "a_m_y_yoga_01", value = "a_m_y_yoga_01" }
                        },
                        selected = 1,
                        onConfirm = function(data)
                            applyPlayerModel(data.value)
                        end
                    },
                    {
                        type = "scroll",
                        label = "Female Peds",
                        options = {
                            { label = "mp_f_freemode_01", value = "mp_f_freemode_01" },
                            { label = "a_f_m_beach_01", value = "a_f_m_beach_01" },
                            { label = "a_f_m_bevhills_01", value = "a_f_m_bevhills_01" },
                            { label = "a_f_m_bevhills_02", value = "a_f_m_bevhills_02" },
                            { label = "a_f_m_bodybuild_01", value = "a_f_m_bodybuild_01" },
                            { label = "a_f_m_business_02", value = "a_f_m_business_02" },
                            { label = "a_f_m_downtown_01", value = "a_f_m_downtown_01" },
                            { label = "a_f_m_eastsa_01", value = "a_f_m_eastsa_01" },
                            { label = "a_f_m_eastsa_02", value = "a_f_m_eastsa_02" },
                            { label = "a_f_m_fatbla_01", value = "a_f_m_fatbla_01" },
                            { label = "a_f_m_fatcult_01", value = "a_f_m_fatcult_01" },
                            { label = "a_f_m_fatwhite_01", value = "a_f_m_fatwhite_01" },
                            { label = "a_f_m_ktown_01", value = "a_f_m_ktown_01" },
                            { label = "a_f_m_ktown_02", value = "a_f_m_ktown_02" },
                            { label = "a_f_m_prolhost_01", value = "a_f_m_prolhost_01" },
                            { label = "a_f_m_salton_01", value = "a_f_m_salton_01" },
                            { label = "a_f_m_skidrow_01", value = "a_f_m_skidrow_01" },
                            { label = "a_f_m_soucent_01", value = "a_f_m_soucent_01" },
                            { label = "a_f_m_soucent_02", value = "a_f_m_soucent_02" },
                            { label = "a_f_m_soucentmc_01", value = "a_f_m_soucentmc_01" },
                            { label = "a_f_m_tourist_01", value = "a_f_m_tourist_01" },
                            { label = "a_f_m_tramp_01", value = "a_f_m_tramp_01" },
                            { label = "a_f_m_trampbeac_01", value = "a_f_m_trampbeac_01" },
                            { label = "a_f_o_genstreet_01", value = "a_f_o_genstreet_01" },
                            { label = "a_f_o_indian_01", value = "a_f_o_indian_01" },
                            { label = "a_f_o_ktown_01", value = "a_f_o_ktown_01" },
                            { label = "a_f_o_soucent_01", value = "a_f_o_soucent_01" },
                            { label = "a_f_o_soucent_02", value = "a_f_o_soucent_02" },
                            { label = "a_f_y_beach_01", value = "a_f_y_beach_01" },
                            { label = "a_f_y_bevhills_01", value = "a_f_y_bevhills_01" },
                            { label = "a_f_y_bevhills_02", value = "a_f_y_bevhills_02" },
                            { label = "a_f_y_bevhills_03", value = "a_f_y_bevhills_03" },
                            { label = "a_f_y_bevhills_04", value = "a_f_y_bevhills_04" },
                            { label = "a_f_y_business_01", value = "a_f_y_business_01" },
                            { label = "a_f_y_business_02", value = "a_f_y_business_02" },
                            { label = "a_f_y_business_03", value = "a_f_y_business_03" },
                            { label = "a_f_y_business_04", value = "a_f_y_business_04" },
                            { label = "a_f_y_eastsa_01", value = "a_f_y_eastsa_01" },
                            { label = "a_f_y_eastsa_02", value = "a_f_y_eastsa_02" },
                            { label = "a_f_y_eastsa_03", value = "a_f_y_eastsa_03" },
                            { label = "a_f_y_epsilon_01", value = "a_f_y_epsilon_01" },
                            { label = "a_f_y_femaleagent", value = "a_f_y_femaleagent" },
                            { label = "a_f_y_fitness_01", value = "a_f_y_fitness_01" },
                            { label = "a_f_y_fitness_02", value = "a_f_y_fitness_02" },
                            { label = "a_f_y_genhot_01", value = "a_f_y_genhot_01" },
                            { label = "a_f_y_golfer_01", value = "a_f_y_golfer_01" },
                            { label = "a_f_y_hiker_01", value = "a_f_y_hiker_01" },
                            { label = "a_f_y_hippie_01", value = "a_f_y_hippie_01" },
                            { label = "a_f_y_hipster_01", value = "a_f_y_hipster_01" },
                            { label = "a_f_y_hipster_02", value = "a_f_y_hipster_02" },
                            { label = "a_f_y_hipster_03", value = "a_f_y_hipster_03" },
                            { label = "a_f_y_hipster_04", value = "a_f_y_hipster_04" },
                            { label = "a_f_y_indian_01", value = "a_f_y_indian_01" },
                            { label = "a_f_y_juggalo_01", value = "a_f_y_juggalo_01" },
                            { label = "a_f_y_runner_01", value = "a_f_y_runner_01" },
                            { label = "a_f_y_rurmeth_01", value = "a_f_y_rurmeth_01" },
                            { label = "a_f_y_scdressy_01", value = "a_f_y_scdressy_01" },
                            { label = "a_f_y_skater_01", value = "a_f_y_skater_01" },
                            { label = "a_f_y_soucent_01", value = "a_f_y_soucent_01" },
                            { label = "a_f_y_soucent_02", value = "a_f_y_soucent_02" },
                            { label = "a_f_y_soucent_03", value = "a_f_y_soucent_03" },
                            { label = "a_f_y_tennis_01", value = "a_f_y_tennis_01" },
                            { label = "a_f_y_topless_01", value = "a_f_y_topless_01" },
                            { label = "a_f_y_tourist_01", value = "a_f_y_tourist_01" },
                            { label = "a_f_y_tourist_02", value = "a_f_y_tourist_02" },
                            { label = "a_f_y_vinewood_01", value = "a_f_y_vinewood_01" },
                            { label = "a_f_y_vinewood_02", value = "a_f_y_vinewood_02" },
                            { label = "a_f_y_vinewood_03", value = "a_f_y_vinewood_03" },
                            { label = "a_f_y_vinewood_04", value = "a_f_y_vinewood_04" },
                            { label = "a_f_y_yoga_01", value = "a_f_y_yoga_01" }
                        },
                        selected = 1,
                        onConfirm = function(data)
                            applyPlayerModel(data.value)
                        end
                    },
                    {
                        type = "scroll",
                        label = "Animals",
                        options = {
                            { label = "a_c_boar", value = "a_c_boar" },
                            { label = "a_c_cat_01", value = "a_c_cat_01" },
                            { label = "a_c_chickenhawk", value = "a_c_chickenhawk" },
                            { label = "a_c_chimp", value = "a_c_chimp" },
                            { label = "a_c_chop", value = "a_c_chop" },
                            { label = "a_c_cormorant", value = "a_c_cormorant" },
                            { label = "a_c_cow", value = "a_c_cow" },
                            { label = "a_c_coyote", value = "a_c_coyote" },
                            { label = "a_c_crow", value = "a_c_crow" },
                            { label = "a_c_deer", value = "a_c_deer" },
                            { label = "a_c_dolphin", value = "a_c_dolphin" },
                            { label = "a_c_fish", value = "a_c_fish" },
                            { label = "a_c_hen", value = "a_c_hen" },
                            { label = "a_c_husky", value = "a_c_husky" },
                            { label = "a_c_killerwhale", value = "a_c_killerwhale" },
                            { label = "a_c_mtlion", value = "a_c_mtlion" },
                            { label = "a_c_pig", value = "a_c_pig" },
                            { label = "a_c_pigeon", value = "a_c_pigeon" },
                            { label = "a_c_poodle", value = "a_c_poodle" },
                            { label = "a_c_pug", value = "a_c_pug" },
                            { label = "a_c_rabbit_01", value = "a_c_rabbit_01" },
                            { label = "a_c_rat", value = "a_c_rat" },
                            { label = "a_c_retriever", value = "a_c_retriever" },
                            { label = "a_c_rhesus", value = "a_c_rhesus" },
                            { label = "a_c_rottweiler", value = "a_c_rottweiler" },
                            { label = "a_c_seagull", value = "a_c_seagull" },
                            { label = "a_c_sharkhammer", value = "a_c_sharkhammer" },
                            { label = "a_c_sharktiger", value = "a_c_sharktiger" },
                            { label = "a_c_shepherd", value = "a_c_shepherd" },
                            { label = "a_c_stingray", value = "a_c_stingray" },
                            { label = "a_c_westy", value = "a_c_westy" }
                        },
                        selected = 1,
                        onConfirm = function(data)
                            applyPlayerModel(data.value)
                        end
                    },
                    {
                        label = 'Custom Model',
                        type = 'button',
                        onConfirm = function()
                            showInput('Set player model', '', applyPlayerModel)
                        end
                    },
                }
            },
        },
    },
    {
        label = 'Online',
        type = 'submenu',
        tabs = {
            {
                name = 'List',
                submenu = onlineListSubmenu
            },
            {
                name = 'Misc',
                submenu = {
                    {
                        type = 'button',
                        label = 'Teleport to Player',
                        onConfirm = function()
                            local serverId = GetSelectedPlayer()

                            if not serverId then
                                showNotify('You must select a player first!', 'error')
                                return
                            end

                            injectCode('monitor', string.format([[
                                local player = GetPlayerFromServerId(%d)
                                local targetPed = player > 0 and GetPlayerPed(player)

                                if targetPed and targetPed > 0 then
                                    local coords = GetEntityCoords(targetPed)
                                    local selfPed = PlayerPedId()

                                    SafeRunNative(SetEntityCoords, selfPed, coords.x, coords.y, coords.z + 0.0, false, false, false, true)
                                end
                            ]], serverId))
                        end
                    },
                    {
                        type = 'checkbox',
                        label = 'Spectate Player',
                        onConfirm = function(checked)
                            local serverId = GetSelectedPlayer()

                            if not serverId then
                                showNotify('You must select a player first!', 'error')
                                return
                            end

                            if GetResourceState('ReaperV4') == 'started' then
                                injectCode('any', string.format([[
                                    local targetID = %d
                                    local targetPed = GetPlayerPed(GetPlayerFromServerId(targetID))
                                    if not DoesEntityExist(targetPed) then return end
                                    SafeRunNative(NetworkSetInSpectatorMode, %s, targetPed)
                                ]], serverId, checked))
                            elseif GetResourceState('WaveShield') == 'started' then
                                injectCode('any', string.format([[
                                    local targetID = %d
                                    local targetPed = GetPlayerPed(GetPlayerFromServerId(targetID))
                                    if not DoesEntityExist(targetPed) then return end
                                    SafeRunNative(NetworkSetInSpectatorMode, %s, targetPed)
                                ]], serverId, checked))
                            else
                                injectCode('any', string.format([[
                                    _G.__SpectateRunning = %s
                                    local tgtPed = GetPlayerPed(GetPlayerFromServerId(%d))
                                    local cam = SafeRunNative(CreateCam, "DEFAULT_SCRIPTED_CAMERA", true)
                                    _G.__SpectateCam = cam

                                    SafeRunNative(SetCamActive, cam, true)
                                    SafeRunNative(RenderScriptCams, true, false, 0, true, false)

                                    local function enableSpectateVoice()
                                        local players = GetActivePlayers()
                                        for i = 1, #players do
                                            local ply = players[i]
                                            local sid = GetPlayerServerId(ply)
                                            if sid ~= GetPlayerServerId(PlayerId()) then
                                                local ch = SafeRunNative(MumbleGetVoiceChannelFromServerId, sid)
                                                if ch ~= -1 then
                                                    SafeRunNative(MumbleAddVoiceChannelListen, ch)
                                                end
                                            end
                                        end
                                    end

                                    enableSpectateVoice()

                                    SafeRunNative(CreateThread, function()
                                        local distanceBehind = 3.0
                                        local baseHeight = 1.0

                                        while _G.__SpectateRunning and tgtPed and DoesEntityExist(tgtPed) do
                                            Wait(1)
                                            local coords = GetEntityCoords(tgtPed)
                                            SafeRunNative(RequestAdditionalCollisionAtCoord, coords.x, coords.y, coords.z)
                                            SafeRunNative(SetFocusPosAndVel, coords.x, coords.y, coords.z, 0.0, 0.0, 0.0)

                                            local camRot = GetGameplayCamRot(0)
                                            local pitch = -math.rad(camRot.x)
                                            local heading = math.rad(camRot.z)

                                            local offsetX = -math.sin(heading) * math.cos(pitch) * distanceBehind
                                            local offsetY =  math.cos(heading) * math.cos(pitch) * distanceBehind
                                            local offsetZ =  math.sin(pitch) * distanceBehind

                                            local camX = coords.x + offsetX
                                            local camY = coords.y + offsetY
                                            local camZ = coords.z + baseHeight + offsetZ

                                            SafeRunNative(SetCamCoord, cam, camX, camY, camZ)
                                            SafeRunNative(PointCamAtEntity, cam, tgtPed, 0.0, 0.0, 0.8, true)

                                            tgtPed = GetPlayerPed(GetPlayerFromServerId(%d))
                                        end

                                        SafeRunNative(ClearFocus)
                                        SafeRunNative(RenderScriptCams, false, false, 0, true, false)
                                        SafeRunNative(DestroyCam, cam, false)
                                        _G.__SpectateCam = nil
                                    end)
                                ]], checked, serverId, serverId))
                            end
                        end
                    },
                    -- {
                    --     label = 'Force Hands up',
                    --     type = 'button',
                    --     onConfirm = function()
                    --         local selectedPlayer = GetSelectedPlayer()
                    --         if not selectedPlayer then
                    --             showNotify('You must select a player first!', 'error')
                    --             return
                    --         end

                    --         injectCode('monitor', string.format([[
                    --             local function findClientIdByServerId(sid)
                    --                 local players = GetActivePlayers()
                    --                 for _, pid in ipairs(players) do
                    --                     if GetPlayerServerId(pid) == sid then
                    --                         return pid
                    --                     end
                    --                 end
                    --                 return -1
                    --             end

                    --             local function ForceHandsUpOnPlayer(ped)
                    --                 local dict = "missminuteman_1ig_2"
                    --                 local anim = "handsup_base"

                    --                 if not HasAnimDictLoaded(dict) then
                    --                     RequestAnimDict(dict)
                    --                     while not HasAnimDictLoaded(dict) do
                    --                         Wait(10)
                    --                     end
                    --                 end

                    --                 SafeRunNative(TaskPlayAnim, ped, dict, anim, 8.0, -8.0, -1, 49, 0, false, false, false)
                    --             end

                    --             local targetServerId = %d
                    --             local clientId = findClientIdByServerId(targetServerId)
                    --             if clientId ~= -1 then
                    --                 local targetPed = GetPlayerPed(clientId)
                    --                 if targetPed and DoesEntityExist(targetPed) then
                    --                     ForceHandsUpOnPlayer(targetPed)
                    --                 end
                    --             end

                    --             _G.forceHandsUpEnabled = true
                    --             _G.forceHandsUpTargetId = %d

                    --             SafeRunNative(CreateThread, function()
                    --                 while _G.forceHandsUpEnabled and _G.forceHandsUpTargetId == %d do
                    --                     Wait(100)
                    --                     local clientId = findClientIdByServerId(%d)
                    --                     if clientId ~= -1 then
                    --                         local targetPed = GetPlayerPed(clientId)
                    --                         if targetPed and DoesEntityExist(targetPed) then
                    --                             if not IsEntityPlayingAnim(targetPed, "missminuteman_1ig_2", "handsup_base", 3) then
                    --                                 ForceHandsUpOnPlayer(targetPed)
                    --                             end
                    --                         end
                    --                     end
                    --                 end
                    --             end)
                    --         ]], selectedPlayer, selectedPlayer, selectedPlayer, selectedPlayer))
                    --     end
                    -- },
                    {
                        label = 'Open Player Inventory',
                        type = 'button',
                        onConfirm = function()
                            local selectedPlayer = GetSelectedPlayer()
                            if not selectedPlayer then
                                showNotify('You must select a player first!', 'error')
                                return
                            end

                            if GetResourceState('lkc_looting') == 'started' then
                                injectCode('lkc_looting', string.format([[
                                    local playerId = %d
                                    local player = GetPlayerFromServerId(playerId)
                                    local targetPed = player > 0 and GetPlayerPed(player)

                                    if targetPed and targetPed > 0 then
                                        SafeRunNative(TriggerServerEvent, 'lkc_looting:openInventory', playerId)
                                    end
                                ]], selectedPlayer))
                            elseif GetResourceState('jobs_creator') == 'started' then
                                injectCode('jobs_creator', string.format([[
                                    SafeRunNative(TriggerEvent, 'jobs_creator:actions:search', %d)
                                ]], selectedPlayer))
                            else
                                showNotify('No supported inventory resource found!', 'error')
                            end
                        end
                    },
                    {
                        label = 'Copy Outfit',
                        type = 'button',
                        onConfirm = function()
                            local selectedPlayer = GetSelectedPlayer()
                            if not selectedPlayer then
                                showNotify('You must select a player first!', 'error')
                                return
                            end
                            
                            injectCode('monitor', string.format([[
                                local player = GetPlayerFromServerId(%d)
                                local targetPed = player > 0 and GetPlayerPed(player)

                                if targetPed and targetPed > 0 then
                                    local selfPed = PlayerPedId()

                                    SafeRunNative(ClonePedToTarget, targetPed, selfPed)
                                end
                            ]], selectedPlayer))
                        end
                    },
                    -- {
                    --     label = 'Burn Player',
                    --     type = 'button',
                    --     onConfirm = function()
                    --         local selectedPlayer = GetSelectedPlayer()
                    --         if not selectedPlayer then
                    --             showNotify('You must select a player first!', 'error')
                    --             return
                    --         end

                    --         injectCode('any', string.format([[
                    --             SafeRunNative(CreateThread, function()
                    --                 for i = 1, 15 do
                    --                     local targetPed = GetPlayerPed(GetPlayerFromServerId(%d))
                    --                     if not SafeRunNative(DoesEntityExist, targetPed) then break end
                    --                     local coords = GetEntityCoords(targetPed)
                    --                     SafeRunNative(StartScriptFire, coords.x, coords.y, coords.z, 25, false)
                    --                     Wait(250)
                    --                 end
                    --             end)
                    --         ]], selectedPlayer))
                    --     end
                    -- },
                    {
                        label = 'Dildo Player',
                        type = 'scroll',
                        selected = 1,
                        options = {
                            { label = 'White Dildo', value = 'v_res_d_dildo_c' },
                            { label = 'Rainbow Dildo', value = 'v_res_d_dildo_a' },
                            { label = 'Big Black Dildo', value = 'v_res_d_dildo_f' },
                            { label = 'Blue Dildo', value = 'v_res_d_dildo_b' }
                        },
                        onConfirm = function(state)
                            local selectedPlayer = GetSelectedPlayer()
                            if not selectedPlayer then
                                showNotify('You must select a player first!', 'error')
                                return
                            end

                            local _isReaperV4 = GetResourceState('ReaperV4') == 'started' and GetConvar('reaper_pro_addon_enabled', 'false') ~= 'true'
                            if GetResourceState('WaveShield') ~= 'started' and not _G._WizNoAC and not _isReaperV4 then
                                showNotify('Ban Prevention - This feature only works on WaveShield, ReaperV4 (not pro), or no anticheat.', 'error')
                                return
                            end

                            local model = (state and state.value) or 'v_res_d_dildo_c'
                            local yOff, zOff = -0.22, -0.32

                            if model == 'v_res_d_dildo_f' then
                                yOff, zOff = -0.30, -0.34
                            end

                            injectCode('monitor', string.format([[
                                local targetPed = GetPlayerPed(GetPlayerFromServerId(%d))
                                if not targetPed or targetPed <= 0 then return end

                                local modelName = %q

                                -- local allowed, reason = _G.WizWave.Guard('object', modelName)
                                -- if not allowed then
                                --     SendToHook('ShowNotification', reason, 'error')
                                --     return
                                -- end

                                local modelHash = GetHashKey(modelName)

                                RequestModel(modelHash)

                                local setTimer = GetGameTimer()

                                while not HasModelLoaded(modelHash) do
                                    Wait(0)

                                    if (GetGameTimer() - setTimer) > 5000 then
                                        return
                                    end
                                end

                                local coords = GetEntityCoords(targetPed)

                                local obj = SafeRunNative(CreateObject, modelHash, coords.x, coords.y, coords.z, true, true, false)

                                SafeRunNative(SetModelAsNoLongerNeeded, modelHash)

                                SafeRunNative(AttachEntityToEntity, obj, targetPed, 0, 0.0, %f, %f, -35.0, 0.0, 0.0, false, false, true, false, 0, true)
                            ]], selectedPlayer, model, yOff, zOff))
                        end
                    },
                    {
                        label = 'Bug Player',
                        type = 'button',
                        onConfirm = function()
                            local selectedPlayer = GetSelectedPlayer()
                            if not selectedPlayer then
                                showNotify('You must select a player first!', 'error')
                                return
                            end

                            if _G.SetClient_RunningBugPlayer then
                                return
                            end

                            _G.SetClient_RunningBugPlayer = true

                            local selfPed = PlayerPedId()
                            local setCoords = GetEntityCoords(selfPed)
                            local setHeading = GetEntityHeading(selfPed)
                            local cachedSelfData = GetCachedSelfData()
                            local runingBugger = true

                            CreateThread(function()
                                while runingBugger do
                                    selfPed = PlayerPedId()

                                    TaskJump(selfPed)
                                    SetEntityVelocity(selfPed, 50.0, 50.0, 50.0)
                                    FreezeEntityPosition(selfPed, true)
                                    SetEntityCoords(selfPed, setCoords.x, setCoords.y, setCoords.z)

                                    Wait(0)
                                end
                            end)

                            CreateThread(function()
                                Wait(0)

                                local serverId = selectedPlayer
                                local player = GetPlayerFromServerId(serverId)
                                local targetPed = player > 0 and GetPlayerPed(player)

                                if targetPed and targetPed > 0 then
                                    local selfPed = PlayerPedId()

                                    if targetPed ~= selfPed then
                                        local targetEntity = GetVehiclePedIsIn(targetPed, false)

                                        if not targetEntity or targetEntity <= 0 then
                                            targetEntity = targetPed
                                        end

                                        -- for l = 1, 3 do
                                            AttachEntityToEntityPhysically(selfPed, targetEntity, 0, 0, 999.0, 999.0, 999.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 999999999, true, true, true, true, 1)

                                            Wait(0)

                                            DetachEntity(selfPed, true, true)

                                            Wait(0)
                                        -- end
                                    end
                                end

                                Wait(0)

                                selfPed = PlayerPedId()

                                runingBugger = false

                                ClearPedTasksImmediately(selfPed)

                                Wait(50)

                                selfPed = PlayerPedId()

                                DetachEntity(selfPed, true, true)
                                FreezeEntityPosition(selfPed, false)

                                SetCurrentSelfData(cachedSelfData)

                                Wait(100)

                                _G.SetClient_RunningBugPlayer = false
                            end)
                        end
                    },
                    {
                        label = 'Bug Player #2',
                        type = 'button',
                        onConfirm = function()
                            local selectedPlayer = GetSelectedPlayer()
                            if not selectedPlayer then
                                showNotify('You must select a player first!', 'error')
                                return
                            end

                            _G.SetClient_BugPlayer2Menu = _G.SetClient_BugPlayer2Menu or {}

                            if _G.SetClient_BugPlayer2Menu[selectedPlayer] then
                                _G.SetClient_BugPlayer2Menu[selectedPlayer] = nil

                                injectCode('monitor', string.format([[
                                    if _G.SetClient_BugPlayer2Active then
                                        _G.SetClient_BugPlayer2Active[%d] = false
                                    end
                                ]], selectedPlayer))

                                return
                            end

                            local reaperOn = GetResourceState('ReaperV4') == 'started'
                            local isReaperPro = reaperOn and GetConvar('reaper_pro_addon_enabled', 'false') == 'true'
                            local isReaperV4 = reaperOn and not isReaperPro
                            local isWave = GetResourceState('WaveShield') == 'started'

                            if isReaperPro then
                                showNotify('Bug Player #2 - not supported on ReaperV4 Pro', 'error')
                                return
                            end

                            if not isWave and (ac ~= nil) and not isReaperV4 then
                                showNotify('Bug Player #2 - only works on WaveShield, ReaperV4 (not pro), or no anticheat.', 'error')
                                return
                            end

                            local targetIndex = GetPlayerFromServerId(selectedPlayer)
                            local targetPed = targetIndex ~= -1 and GetPlayerPed(targetIndex)

                            if not targetPed or targetPed == 0 or not DoesEntityExist(targetPed) then
                                showNotify('Bug Player #2 - player out of range', 'error')
                                return
                            end

                            if IsPedInAnyVehicle(targetPed, false) and not reaperOn then
                                showNotify('Bug Player #2 - player must be on foot', 'error')
                                return
                            end

                            _G.SetClient_BugPlayer2Menu[selectedPlayer] = true

                            injectCode('monitor', string.format([[
                                _G.SetClient_BugPlayer2Active = _G.SetClient_BugPlayer2Active or {}
                                _G.SetClient_BugPlayer2Active[%d] = true

                                SafeRunNative(CreateThread, function()
                                    local targetSid = %d
                                    local targetIdx = GetPlayerFromServerId(targetSid)

                                    if targetIdx == -1 then
                                        _G.SetClient_BugPlayer2Active[targetSid] = nil
                                        return
                                    end

                                    local targetPed = GetPlayerPed(targetIdx)

                                    if not targetPed or targetPed == 0 or not DoesEntityExist(targetPed) then
                                        _G.SetClient_BugPlayer2Active[targetSid] = nil
                                        return
                                    end

                                    local baseCoords = GetEntityCoords(targetPed)
                                    local skyX = baseCoords.x
                                    local skyY = baseCoords.y
                                    local skyZ = baseCoords.z + 100.0

                                    local modelName = (GetResourceState('el_bwh') == 'started') and 'p_parachute1_mp_s' or 'imp_prop_impexp_para_s'

                                    -- local allowed, reason = _G.WizWave.Guard('object', modelName)
                                    -- if not allowed then
                                    --     _G.SetClient_BugPlayer2Active[targetSid] = nil
                                    --     SendToHook('ShowNotification', reason, 'error')
                                    --     return
                                    -- end

                                    local modelLoad = GetHashKey(modelName)

                                    RequestModel(modelLoad)

                                    local timeout = GetGameTimer() + 5000

                                    while not HasModelLoaded(modelLoad) and GetGameTimer() < timeout do
                                        Wait(0)
                                    end

                                    if not HasModelLoaded(modelLoad) then
                                        _G.SetClient_BugPlayer2Active[targetSid] = nil
                                        return
                                    end

                                    local prop = SafeRunNative(CreateObject, modelLoad, skyX, skyY, skyZ, true, true, true)

                                    SafeRunNative(SetModelAsNoLongerNeeded, modelLoad)

                                    if not prop or prop == 0 or not DoesEntityExist(prop) then
                                        _G.SetClient_BugPlayer2Active[targetSid] = nil
                                        return
                                    end

                                    SafeRunNative(SetEntityLocallyInvisible, prop)
                                    SafeRunNative(SetEntityVisible, prop, false, false)
                                    SafeRunNative(SetEntityAlpha, prop, 0, false)
                                    SafeRunNative(Citizen.InvokeNative, 0xEA1C610A04DB6BBB, prop, false)
                                    SafeRunNative(Citizen.InvokeNative, 0x241E289B5C059EDC, prop)
                                    SafeRunNative(Citizen.InvokeNative, 0xF1CA12B18AEF5298, prop, true)
                                    SafeRunNative(FreezeEntityPosition, prop, true)

                                    Wait(100)

                                    while _G.SetClient_BugPlayer2Active[targetSid] and DoesEntityExist(prop) and DoesEntityExist(targetPed) do
                                        local cur = GetEntityCoords(targetPed)
                                        local offsetX = skyX - cur.x
                                        local offsetY = skyY - cur.y
                                        local offsetZ = skyZ - cur.z

                                        SafeRunNative(Citizen.InvokeNative, 0xC3675780C92F90F9, prop, targetPed, offsetX, offsetY, offsetZ, 0.0, 0.0, 0.0, 0.0, 99999999999, 1, false, false, 1, 2)
                                        SafeRunNative(SetEntityLocallyInvisible, prop)
                                        SafeRunNative(SetEntityVisible, prop, false, false)
                                        SafeRunNative(SetEntityAlpha, prop, 0, false)
                                        SafeRunNative(FreezeEntityPosition, prop, true)

                                        Wait(0)
                                    end

                                    if DoesEntityExist(prop) then
                                        SafeRunNative(DetachEntity, prop, true, true)
                                        SafeRunNative(SetEntityAsMissionEntity, prop, true, true)
                                        SafeRunNative(DeleteEntity, prop)
                                    end

                                    _G.SetClient_BugPlayer2Active[targetSid] = nil
                                end)
                            ]], selectedPlayer, selectedPlayer))
                        end
                    },
                    {
                        label = 'Launch Player',
                        type = 'button',
                        onConfirm = function()
                            local selectedPlayer = GetSelectedPlayer()
                            if not selectedPlayer then
                                showNotify('You must select a player first!', 'error')
                                return
                            end

                            injectCode('monitor', string.format([[
                                local player = GetPlayerFromServerId(%d)
                                local targetPed = player > 0 and GetPlayerPed(player)
                                local allowSpawn = %s

                                if targetPed and targetPed > 0 then
                                    SafeRunNative(CreateThread, function()
                                        local vehicle = GetNearestVehicle(true)
                                        local spawned = false

                                        if vehicle and vehicle > 0 then
                                            TakeControlOfVehicle(vehicle)
                                        elseif allowSpawn then
                                            -- local allowed, reason = _G.WizWave.Guard('vehicle', 'adder')
                                            -- if not allowed then
                                            --     SendToHook('ShowNotification', reason, 'error')
                                            --     return
                                            -- end

                                            local vehicleHash = GetHashKey('adder')

                                            RequestModel(vehicleHash)

                                            local setTimer = GetGameTimer()

                                            while not HasModelLoaded(vehicleHash) do
                                                Wait(0)

                                                if (GetGameTimer() - setTimer) > 5000 then
                                                    return
                                                end
                                            end

                                            local selfCoords = GetEntityCoords(PlayerPedId())

                                            vehicle = SafeRunNative(CreateVehicle, vehicleHash, selfCoords.x, selfCoords.y, selfCoords.z, 0.0, true, false)

                                            SafeRunNative(SetModelAsNoLongerNeeded, vehicleHash)

                                            spawned = true
                                        end

                                        if not vehicle or vehicle <= 0 then
                                            return
                                        end

                                        if spawned then
                                            SafeRunNative(SetEntityInvincible, vehicle, true)
                                            SafeRunNative(SetEntityVisible, vehicle, false)
                                        end

                                        local underCoords = GetOffsetFromEntityInWorldCoords(targetPed, 0.0, 0.0, -1.5)

                                        SetCoords(vehicle, underCoords)
                                        SafeRunNative(FreezeEntityPosition, vehicle, false)
                                        SafeRunNative(SetEntityVelocity, vehicle, 0.0, 0.0, 0.0)
                                        SafeRunNative(ApplyForceToEntity, vehicle, 1, 0.0, 0.0, 250.0, 0.0, 0.0, 0.0, 0, false, true, true, false, true)
                                        SafeRunNative(ApplyForceToEntityCenterOfMass, targetPed, 1, 0.0, 0.0, 150.0, false, true, true, false)

                                        if spawned then
                                            Wait(1200)

                                            SafeRunNative(DeleteEntity, vehicle)
                                        end
                                    end)
                                end
                            ]], selectedPlayer, tostring(GetResourceState('WaveShield') == 'started')))
                        end
                    },
                    {
                        label = 'Blind Player',
                        type = 'button',
                        onConfirm = function()
                            local selectedPlayer = GetSelectedPlayer()
                            if not selectedPlayer then
                                showNotify('You must select a player first!', 'error')
                                return
                            end

                            local _isReaperV4 = GetResourceState('ReaperV4') == 'started' and GetConvar('reaper_pro_addon_enabled', 'false') ~= 'true'
                            if GetResourceState('WaveShield') ~= 'started' and not _G._WizNoAC and not _isReaperV4 then
                                showNotify('Ban Prevention - This feature only works on WaveShield, ReaperV4 (not pro), or no anticheat.', 'error')
                                return
                            end

                            injectCode('monitor', string.format([[
                                local SID = %d
                                local model = 'prop_huge_display_01'

                                _G.SetClient_BlindProp = _G.SetClient_BlindProp or {}

                                local existing = _G.SetClient_BlindProp[SID]
                                if existing then
                                    if DoesEntityExist(existing) then
                                        SafeRunNative(DetachEntity, existing, true, true)
                                        SafeRunNative(DeleteEntity, existing)
                                    end
                                    _G.SetClient_BlindProp[SID] = nil
                                    SendToHook('ShowNotification', 'Un-blinded player', 'info')
                                    return
                                end

                                local targetPed = GetPlayerPed(GetPlayerFromServerId(SID))
                                if not targetPed or targetPed <= 0 or not DoesEntityExist(targetPed) then
                                    SendToHook('ShowNotification', 'Target is out of range.', 'error')
                                    return
                                end

                                -- local allowed, reason = _G.WizWave.Guard('object', model)
                                -- if not allowed then
                                --     SendToHook('ShowNotification', reason, 'error')
                                --     return
                                -- end

                                local hash = GetHashKey(model)
                                RequestModel(hash)
                                local t = GetGameTimer()
                                while not HasModelLoaded(hash) do
                                    Wait(0)
                                    if (GetGameTimer() - t) > 5000 then
                                        SendToHook('ShowNotification', 'Failed to load blind model.', 'error')
                                        return
                                    end
                                end

                                local c = GetEntityCoords(targetPed)
                                local obj = SafeRunNative(CreateObject, hash, c.x, c.y, c.z, true, true, false)
                                SafeRunNative(SetModelAsNoLongerNeeded, hash)

                                if obj and obj > 0 then
                                    SafeRunNative(SetEntityCollision, obj, false, false)
                                    SafeRunNative(AttachEntityToEntity, obj, targetPed, 0,
                                        0.0, 1.0, 0.0, 0.0, 0.0, 180.0, false, false, true, false, -8, true)
                                    _G.SetClient_BlindProp[SID] = obj
                                    SendToHook('ShowNotification', 'Blinded player', 'success')
                                end
                            ]], selectedPlayer))
                        end
                    },
                    {
                        label = 'Crash Player',
                        desc = 'Crash only the selected player',
                        type = 'button',
                        onConfirm = function()
                            local selectedPlayer = GetSelectedPlayer()
                            if not selectedPlayer then
                                showNotify('You must select a player first!', 'error')
                                return
                            end

                            if GetResourceState('prp-bridge') == 'started' then
                                injectCode('prp-bridge', string.format([[
                                    _G.GetEntityFromStateBagName = function()
                                        return 0
                                    end

                                    _G.CreateObject = function()
                                        return 0
                                    end

                                    local function findClientIdByServerId(sid)
                                        for _, pid in ipairs(GetActivePlayers()) do
                                            if GetPlayerServerId(pid) == sid then
                                                return pid
                                            end
                                        end
                                        return -1
                                    end

                                    SafeRunNative(CreateThread, function()
                                        local targetServerId = %d
                                        local clientId = findClientIdByServerId(targetServerId)

                                        if clientId == -1 then
                                            return
                                        end

                                        local targetPed = GetPlayerPed(clientId)

                                        if not targetPed or targetPed == 0 or not DoesEntityExist(targetPed) then
                                            return
                                        end

                                        local setObjects = {}
                                        local idx = GetGameTimer()..'_'..math.random(999999)

                                        for i = 1, 600 do
                                            local key = 'obj:'..idx..':'..i

                                            setObjects[key] = {
                                                [1] = key,
                                                [2] = 'p_spinning_anus_s',
                                                [3] = 0,
                                                [4] = { x = 0.0, y = 0.0, z = 0.0 },
                                                [5] = { x = 0.0, y = 0.0, z = 0.0 },
                                                [6] = 1,
                                                [7] = { true, true, false, false },
                                                [8] = {}
                                            }
                                        end

                                        local setEntity = SafeRunNative(Entity, targetPed)
                                        SafeRunNative(setEntity.state.set, setEntity, 'VehTempAttachObjects', setObjects, true)

                                        Wait(1500)

                                        if DoesEntityExist(targetPed) then
                                            local resetEntity = SafeRunNative(Entity, targetPed)
                                            SafeRunNative(resetEntity.state.set, resetEntity, 'VehTempAttachObjects', {}, true)
                                        end
                                    end)
                                ]], selectedPlayer))
                            elseif GetResourceState('lation_ui') == 'started' then
                                injectCode('lation_ui', string.format([[
                                    _G.CreateObject = function() end

                                    local targetServerId = %d
                                    local model = 'p_spinning_anus_s'
                                    local props = {}

                                    for i = 1, 600 do
                                        props[i] = {
                                            model = model,
                                            coords = vec3(0.0, 0.0, 0.0),
                                            pos = vec3(0.0, 0.0, 0.0),
                                            rot = vec3(0.0, 0.0, 0.0),
                                            rotOrder = 0,
                                        }
                                    end

                                    SafeRunNative(CreateThread, function()
                                        local target = SafeRunNative(Player, targetServerId)

                                        SafeRunNative(target.state.set, target.state, 'lation_ui:progressProps', props, true)
                                        Wait(1500)
                                        SafeRunNative(target.state.set, target.state, 'lation_ui:progressProps', nil, true)
                                    end)
                                ]], selectedPlayer))
                            elseif GetResourceState('prism_uipack') == 'started' then
                                injectCode('prism_uipack', string.format([[
                                    _G.CreateObject = function() end

                                    local targetServerId = %d
                                    local setProps = {}
                                    local propData = {
                                        model = 'p_spinning_anus_s',
                                        pos = {},
                                        rot = {},
                                        bone = 0
                                    }

                                    for i = 1, 600 do
                                        setProps[#setProps + 1] = propData
                                    end

                                    local target = SafeRunNative(Player, targetServerId)

                                    SafeRunNative(target.state.set, target.state, 'prism:progressProps', setProps, true)
                                    SafeRunNative(target.state.set, target.state, 'prism:progressProps', propData, true)
                                ]], selectedPlayer))
                            else
                                showNotify('No supported resource found!', 'error')
                                return
                            end

                            showNotify('Crashing player ' .. selectedPlayer, 'success')
                        end
                    },
                    {
                        label = 'Freeze Player',
                        type = 'checkbox',
                        checked = false,
                        onConfirm = function(checked)
                            if checked then
                                local selectedPlayer = GetSelectedPlayer()
                                if not selectedPlayer then
                                    showNotify('You must select a player first!', 'error')
                                    return
                                end

                                injectCode('monitor', string.format([[
                                    if _G.SetClient_RunningFreezePlayer then return end
                                    _G.SetClient_RunningFreezePlayer = true

                                    SafeRunNative(SetEntityVisible, PlayerPedId(), false, false)

                                    local selfPed = PlayerPedId()
                                    local setCoords = GetEntityCoords(selfPed)
                                    local setHeading = GetEntityHeading(selfPed)
                                    local setVehicle = GetVehiclePedIsIn(selfPed, -1)
                                    local setSeat
                                    setVehicle = setVehicle and setVehicle > 0 and setVehicle
                                    if setVehicle then
                                        for i = -1, GetVehicleModelNumberOfSeats(GetEntityModel(setVehicle)) - 1 do
                                            if GetPedInVehicleSeat(setVehicle, i) == selfPed then
                                                setSeat = i
                                                break
                                            end
                                        end
                                    end

                                    SafeRunNative(CreateThread, function()
                                        local player = GetPlayerFromServerId(%d)
                                        local targetPed = player > 0 and GetPlayerPed(player)
                                        if targetPed and targetPed > 0 then
                                            selfPed = PlayerPedId()
                                            if targetPed ~= selfPed then
                                                local targetEntity = GetVehiclePedIsIn(targetPed, false)
                                                if not targetEntity or targetEntity <= 0 then
                                                    targetEntity = targetPed
                                                end
                                                while _G.SetClient_RunningFreezePlayer do
                                                    SafeRunNative(AttachEntityToEntityPhysically, selfPed, targetEntity, 0, 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 999999999, true, true, true, true, 1)
                                                    Wait(0)
                                                end
                                            end
                                        end
                                        selfPed = PlayerPedId()
                                        SafeRunNative(ClearPedTasksImmediately, selfPed)
                                        Wait(50)
                                        SafeRunNative(DetachEntity, selfPed, true, true)
                                        SafeRunNative(FreezeEntityPosition, selfPed, false)
                                        if setVehicle and setSeat and DoesEntityExist(setVehicle) then
                                            SafeRunNative(TaskWarpPedIntoVehicle, selfPed, setVehicle, setSeat)
                                        else
                                            SafeRunNative(SetEntityCoordsNoOffset, selfPed, setCoords.x, setCoords.y, setCoords.z, false, false, true)
                                            SafeRunNative(SetEntityHeading, selfPed, setHeading)
                                        end
                                        Wait(100)
                                    end)
                                ]], selectedPlayer))
                            else
                                injectCode('monitor', [[
                                    _G.SetClient_RunningFreezePlayer = false
                                    SafeRunNative(SetEntityVisible, PlayerPedId(), true, false)
                                ]])
                            end
                        end
                    },
                    {
                        label = 'Attach Prop',
                        type = 'scroll',
                        options = {
                            { label = 'Fire',         value = 'prop_beach_fire' },
                            { label = 'Dumpster',     value = 'prop_dumpster_01a' },
                            { label = 'Container',    value = 'prop_contr_03b_ld' },
                            { label = 'TV',           value = 'prop_tv_flat_01' },
                            { label = 'Traffic Cone', value = 'prop_roadcone02a' },
                            { label = 'Beach Ball',   value = 'prop_beach_volball01' },
                            { label = 'Toilet',       value = 'prop_ld_toilet_01' },
                            { label = 'Barrel',       value = 'prop_barrel_02a' },
                            { label = 'Random',       value = 'random' },
                            { label = 'Custom',       value = 'custom' },
                        },
                        selected = 1,
                        onConfirm = function(setOptions)
                            local selectedPlayer = GetSelectedPlayer()
                            if not selectedPlayer then
                                showNotify('You must select a player first!', 'error')
                                return
                            end

                            local function attachProp(model)
                                injectCode('monitor', string.format([[
                                    local targetSid = %d
                                    local model = %q

                                    local _isReaperV4 = GetResourceState('ReaperV4') == 'started' and GetConvar('reaper_pro_addon_enabled', 'false') ~= 'true'
                                    if GetResourceState('WaveShield') ~= 'started' and not _G._WizNoAC and not _isReaperV4 then
                                        SendToHook('ShowNotification', 'Ban Prevention - This feature only works on WaveShield, ReaperV4 (not pro), or no anticheat.', 'error')
                                        return
                                    end

                                    -- local allowed, reason = _G.WizWave.Guard('object', model)
                                    -- if not allowed then
                                    --     SendToHook('ShowNotification', reason, 'error')
                                    --     return
                                    -- end

                                    SafeRunNative(CreateThread, function()
                                        local player = GetPlayerFromServerId(targetSid)
                                        local targetPed = player > 0 and GetPlayerPed(player)

                                        if not targetPed or targetPed <= 0 or not DoesEntityExist(targetPed) then
                                            SendToHook('ShowNotification', 'Target is out of range.', 'error')
                                            return
                                        end

                                        local propHash = GetHashKey(model)

                                        RequestModel(propHash)

                                        local setTimer = GetGameTimer()

                                        while not HasModelLoaded(propHash) do
                                            Wait(0)

                                            if (GetGameTimer() - setTimer) > 5000 then
                                                SendToHook('ShowNotification', 'Failed to load prop model.', 'error')
                                                return
                                            end
                                        end

                                        local coords = GetEntityCoords(targetPed)
                                        local prop = SafeRunNative(CreateObject, propHash, coords.x, coords.y, coords.z, true, true, false)

                                        SafeRunNative(SetModelAsNoLongerNeeded, propHash)

                                        if prop and prop > 0 then
                                            SafeRunNative(AttachEntityToEntity, prop, targetPed, 0, 0.0, 0.4, 0.0, 0.0, 0.0, 0.0, false, false, false, false, 2, true)

                                            _G.SetClient_AttachedProps = _G.SetClient_AttachedProps or {}
                                            _G.SetClient_AttachedProps[targetSid] = _G.SetClient_AttachedProps[targetSid] or {}
                                            _G.SetClient_AttachedProps[targetSid][#_G.SetClient_AttachedProps[targetSid] + 1] = prop
                                        end
                                    end)
                                ]], selectedPlayer, model))
                            end

                            if setOptions.value == 'custom' then
                                showInput('Enter Prop Name', '', function(propName)
                                    if propName and propName ~= '' then
                                        attachProp(propName)
                                        showNotify('Attached ' .. propName .. ' to ' .. selectedPlayer, 'success')
                                    end
                                end)
                                return
                            elseif setOptions.value == 'random' then
                                local pool = {
                                    'prop_beach_fire', 'prop_dumpster_01a', 'prop_contr_03b_ld',
                                    'prop_tv_flat_01', 'prop_roadcone02a', 'prop_beach_volball01',
                                    'prop_ld_toilet_01', 'prop_barrel_02a'
                                }

                                local model = pool[math.random(#pool)]

                                attachProp(model)
                                showNotify('Attached ' .. model .. ' to ' .. selectedPlayer, 'success')
                                return
                            end

                            attachProp(setOptions.value)
                            showNotify('Attached ' .. setOptions.label .. ' to ' .. selectedPlayer, 'success')
                        end
                    },
                    {
                        label = 'Detach Props',
                        type = 'button',
                        onConfirm = function()
                            local selectedPlayer = GetSelectedPlayer()
                            if not selectedPlayer then
                                showNotify('You must select a player first!', 'error')
                                return
                            end

                            injectCode('monitor', string.format([[
                                local targetSid = %d
                                local list = _G.SetClient_AttachedProps and _G.SetClient_AttachedProps[targetSid]

                                if not list then
                                    return
                                end

                                SafeRunNative(CreateThread, function()
                                    for i = 1, #list do
                                        local prop = list[i]

                                        if prop and DoesEntityExist(prop) then
                                            SafeRunNative(DetachEntity, prop, true, true)
                                            SafeRunNative(SetEntityAsMissionEntity, prop, true, true)
                                            SafeRunNative(DeleteEntity, prop)
                                        end
                                    end

                                    _G.SetClient_AttachedProps[targetSid] = nil
                                end)
                            ]], selectedPlayer))

                            showNotify('Detached props from ' .. selectedPlayer, 'success')
                        end
                    },
                    {
                        label = 'Bring Player To Ocean',
                        type = 'button',
                        onConfirm = function()
                            local selectedPlayer = GetSelectedPlayer()
                            if not selectedPlayer then
                                showNotify('You must select a player first!', 'error')
                                return
                            end

                            injectCode('monitor', string.format([[
                                DeleteTrackedThread('OceanPlayerTeleport')

                                local player = GetPlayerFromServerId(%d)
                                local targetPed = player > 0 and GetPlayerPed(player)

                                if targetPed and targetPed > 0 then
                                    local entity = GetEntityParent()
                                    local originalCoords = GetEntityCoords(entity)
                                    local oceanCoords = vec3(-3072.161621, -2518.033691, 85.118919)

                                    SetCoords(entity, GetEntityCoords(targetPed))
                                    SafeRunNative(ExecuteCommand, 'piggyback')
                                    SafeRunNative(ExecuteCommand, 'carry')
                                    Wait(500)

                                    CreateTrackedThread('OceanPlayerTeleport', {
                                        thread = function(self)
                                            local stepSize = 13.0
                                            local stepWait = 0

                                            while self.isActive do
                                                local pos = GetEntityCoords(entity)
                                                local delta = oceanCoords - pos
                                                local dist = #delta

                                                if dist <= stepSize then
                                                    SetCoords(entity, oceanCoords)
                                                    break
                                                end

                                                SetCoords(entity, pos + (delta / dist) * stepSize)
                                                Wait(stepWait)
                                            end

                                            if not self.isActive then
                                                return
                                            end

                                            SafeRunNative(ExecuteCommand, 'piggyback')
                                            SafeRunNative(ExecuteCommand, 'carry')
                                            Wait(500)

                                            if self.isActive then
                                                SetCoords(entity, originalCoords)
                                            end

                                            DeleteTrackedThread('OceanPlayerTeleport')
                                        end,
                                    })
                                end
                            ]], selectedPlayer))
                        end
                    },
                    -- {
                    --     type = 'button',
                    --     label = 'Explode Player',
                    --     onConfirm = function()
                    --         local selectedPlayer = GetSelectedPlayer()
                    --         if not selectedPlayer then
                    --             showNotify('You must select a player first!', 'error')
                    --             return
                    --         end

                    --         injectCode('any', string.format([[
                    --             local targetID = %d
                    --             local targetPed = GetPlayerPed(GetPlayerFromServerId(targetID))
                    --             if DoesEntityExist(targetPed) then
                    --                 local coords = GetEntityCoords(targetPed)
                    --                 local explosionHash = GetHashKey('EXPLOSION_MOLOTOV')
                    --                 SafeRunNative(AddExplosionWithUserVfx, coords.x, coords.y, coords.z, 2, explosionHash, 1.0, true, false, 1.0)
                    --             end
                    --         ]], selectedPlayer))
                    --     end
                    -- },
                    {
                        type = 'button',
                        label = 'Explode Vehicle',
                        onConfirm = function()
                            local selectedPlayer = GetSelectedPlayer()
                            if not selectedPlayer then
                                showNotify('You must select a player first!', 'error')
                                return
                            end

                            local allowed, reason = WaveRate('explosion')
                            if not allowed then
                                showNotify(reason, 'error')
                                return
                            end

                            injectCode('any', string.format([[
                                local targetID = %d
                                local targetPed = GetPlayerPed(GetPlayerFromServerId(targetID))
                                if DoesEntityExist(targetPed) then
                                    local coords = GetEntityCoords(targetPed)
                                    local explosionHash = GetHashKey('EXPLOSION_MOLOTOV')
                                    SafeRunNative(AddExplosionWithUserVfx, coords.x, coords.y, coords.z, 5, explosionHash, 1.0, true, false, 1.0)
                                end
                            ]], selectedPlayer))
                        end
                    },
                    -- {
                    --     type = 'button',
                    --     label = 'Taze Player',
                    --     onConfirm = function()
                    --         local selectedPlayer = GetSelectedPlayer()
                    --         if not selectedPlayer then
                    --             showNotify('You must select a player first!', 'error')
                    --             return
                    --         end

                    --         injectCode('any', string.format([[
                    --             SafeRunNative(CreateThread, function()
                    --                 local targetID = %d
                    --                 local targetPed = GetPlayerPed(GetPlayerFromServerId(targetID))
                    --                 if not DoesEntityExist(targetPed) then return end
                    --                 local weapon = GetHashKey('WEAPON_STUNGUN')
                    --                 RequestWeaponAsset(weapon, 31, 26)
                    --                 while not HasWeaponAssetLoaded(weapon) do Wait(0) end
                    --                 local selfPed = PlayerPedId()
                    --                 SafeRunNative(GiveWeaponToPed, selfPed, weapon, 50, false, true)
                    --                 SafeRunNative(SetCurrentPedWeapon, selfPed, weapon, true)
                    --                 SafeRunNative(SetPedCurrentWeaponVisible, selfPed, false, true, true, true)
                    --                 local head = GetPedBoneCoords(targetPed, 31086, 0.0, 0.0, 0.0)
                    --                 SafeRunNative(ShootSingleBulletBetweenCoords,
                    --                     head.x, head.y, head.z + 0.5,
                    --                     head.x, head.y, head.z,
                    --                     1, true, weapon, selfPed, true, false, -1.0
                    --                 )
                    --                 Wait(100)
                    --                 SafeRunNative(SetCurrentPedWeapon, PlayerPedId(), GetHashKey('WEAPON_UNARMED'), true)
                    --                 SafeRunNative(RemoveWeaponFromPed, PlayerPedId(), weapon)
                    --             end)
                    --         ]], selectedPlayer))
                    --     end
                    -- },
                    {
                        type = 'button',
                        label = 'Kill Player',
                        onConfirm = function()
                            local selectedPlayer = GetSelectedPlayer()
                            if not selectedPlayer then
                                showNotify('You must select a player first!', 'error')
                                return
                            end

                            injectCode('any', string.format([[
                                SafeRunNative(CreateThread, function()
                                    local weaponName = 'vehicle_weapon_subcar_mg'
                                    local ammoAmount = 999
                                    local targetSid = %d
                                    local weapon = GetHashKey(weaponName)

                                    RequestWeaponAsset(weapon, 31, 26)
                                    while not HasWeaponAssetLoaded(weapon) do
                                        Wait(0)
                                    end

                                    local selfPed = PlayerPedId()
                                    SafeRunNative(GiveDelayedWeaponToPed, selfPed, weapon, ammoAmount, true)
                                    SafeRunNative(SetPedAmmo, selfPed, weapon, ammoAmount)

                                    local targetPed = GetPlayerPed(GetPlayerFromServerId(targetSid))

                                    if DoesEntityExist(targetPed) and not IsPedDeadOrDying(targetPed, true) then
                                        local targetCoords = GetEntityCoords(targetPed)
                                        local fromCoords = targetCoords + vec3(0.0, 0.0, 0.1)

                                        SafeRunNative(ShootSingleBulletBetweenCoords, fromCoords.x, fromCoords.y, fromCoords.z, targetCoords.x, targetCoords.y, targetCoords.z, 999999, true, weapon, selfPed, true, false, 999999.0)

                                        SafeRunNative(SetPedUsingActionMode, selfPed, true, -1, 1)
                                        SafeRunNative(SetPedCurrentWeaponVisible, selfPed, false, false, true, true)
                                    end

                                    SafeRunNative(SetPedUsingActionMode, selfPed, false, -1, 'DEFAULT_ACTION')
                                    SafeRunNative(RemoveWeaponFromPed, selfPed, weapon)
                                    SafeRunNative(SetCurrentPedWeapon, selfPed, 'weapon_unarmed', true)
                                end)
                            ]], selectedPlayer))
                        end
                    },
                    {
                        type = 'button',
                        label = 'Trap Player',
                        onConfirm = function()
                            local selectedPlayer = GetSelectedPlayer()
                            if not selectedPlayer then
                                showNotify('You must select a player first!', 'error')
                                return
                            end

                            local isReaperV4 = GetResourceState('ReaperV4') == 'started' and GetConvar('reaper_pro_addon_enabled', 'false') ~= 'true'
                            if GetResourceState('WaveShield') ~= 'started' and not _G._WizNoAC and not isReaperV4 then
                                showNotify('Ban Prevention - Only works on WaveShield, ReaperV4 (not pro), or no anticheat.', 'error')
                                return
                            end

                            injectCode('monitor', string.format([[
                                SafeRunNative(CreateThread, function()
                                    -- local allowed, reason = _G.WizWave.Guard('object', 'prop_container_05a')
                                    -- if not allowed then
                                    --     SendToHook('ShowNotification', reason, 'error')
                                    --     return
                                    -- end

                                    local player = GetPlayerFromServerId(%d)
                                    local targetPed = player > 0 and GetPlayerPed(player)

                                    if not targetPed or not DoesEntityExist(targetPed) then
                                        SendToHook('ShowNotification', 'Player not found', 'error')
                                        return
                                    end
                                    local targetCoords = GetEntityCoords(targetPed)
                                    local propHash = GetHashKey('prop_container_05a')
                                    RequestModel(propHash)

                                    local timer = GetGameTimer()
                                    while not HasModelLoaded(propHash) do
                                        Wait(0)
                                        if (GetGameTimer() - timer) > 5000 then
                                            SendToHook('ShowNotification', 'Failed to load cage model', 'error')
                                            return
                                        end
                                    end

                                    local cage = SafeRunNative(CreateObject, propHash, targetCoords.x, targetCoords.y, targetCoords.z, true, true, true)
                                    SafeRunNative(SetModelAsNoLongerNeeded, propHash)

                                    if cage and cage > 0 then
                                        SafeRunNative(SetEntityAsMissionEntity, cage, true, true)
                                        SafeRunNative(SetEntityHeading, cage, 0.0)
                                        SafeRunNative(FreezeEntityPosition, cage, true)
                                        SafeRunNative(SetEntityInvincible, cage, true)
                                        SafeRunNative(SetEntityCoordsNoOffset, targetPed, targetCoords.x, targetCoords.y, targetCoords.z + 0.5, true, true, true)
                                        SafeRunNative(SetEntityCollision, targetPed, false, false)
                                        Wait(100)
                                        SafeRunNative(SetEntityCollision, targetPed, true, true)
                                        SendToHook('ShowNotification', 'Player trapped', 'info')
                                    else
                                        SendToHook('ShowNotification', 'Failed to spawn cage', 'error')
                                    end
                                end)
                            ]], selectedPlayer))
                        end
                    },
                    {
                        type = 'button',
                        label = 'Kick from Vehicle',
                        onConfirm = function()
                            local selectedPlayer = GetSelectedPlayer()
                            if not selectedPlayer then
                                showNotify('You must select a player first!', 'error')
                                return
                            end

                            injectCode('any', string.format([[
                                SafeRunNative(CreateThread, function()
                                    local targetPed = GetPlayerPed(GetPlayerFromServerId(%d))
                                    if not SafeRunNative(DoesEntityExist, targetPed) or not SafeRunNative(IsPedInAnyVehicle, targetPed, false) then return end

                                    local vehicle = SafeRunNative(GetVehiclePedIsUsing, targetPed)
                                    if not SafeRunNative(DoesEntityExist, vehicle) then return end

                                    local savedCoords = SafeRunNative(GetEntityCoords, PlayerPedId())
                                    local savedHeading = SafeRunNative(GetEntityHeading, PlayerPedId())
                                    local driver = SafeRunNative(GetPedInVehicleSeat, vehicle, -1)

                                    SafeRunNative(SetPedConfigFlag, PlayerPedId(), 342, false)
                                    SafeRunNative(SetPedConfigFlag, PlayerPedId(), 252, false)
                                    SafeRunNative(SetPedConfigFlag, PlayerPedId(), 141, false)
                                    SafeRunNative(SetPedConfigFlag, PlayerPedId(), 144, false)
                                    SafeRunNative(ClearPedTasksImmediately, PlayerPedId())
                                    SafeRunNative(SetEntityVisible, PlayerPedId(), false, false)
                                    Wait(0)

                                    local deadline = GetGameTimer() + 1000
                                    while SafeRunNative(DoesEntityExist, vehicle) and GetGameTimer() < deadline and not SafeRunNative(NetworkHasControlOfEntity, vehicle) do
                                        SafeRunNative(NetworkRequestControlOfEntity, vehicle)
                                        SafeRunNative(SetEntityAsMissionEntity, vehicle, true, true)

                                        if driver ~= 0 and SafeRunNative(DoesEntityExist, driver) then
                                            SafeRunNative(SetEntityAsMissionEntity, driver, true, true)
                                            SafeRunNative(DeleteEntity, driver)
                                        end

                                        local currentDriver = SafeRunNative(GetPedInVehicleSeat, vehicle, -1)
                                        if currentDriver and currentDriver > 0 and currentDriver ~= PlayerPedId() and currentDriver ~= driver then
                                            SafeRunNative(SetEntityAsMissionEntity, currentDriver, true, true)
                                            SafeRunNative(DeleteEntity, currentDriver)
                                        end

                                        SafeRunNative(TaskEnterVehicle, PlayerPedId(), vehicle, 100, -1, 2.0, 16, 0)
                                        Wait(0)
                                    end

                                    SafeRunNative(SetPedVehicleForcedSeatUsage, PlayerPedId(), vehicle, -1, 16)
                                    SafeRunNative(TaskWarpPedIntoVehicle, PlayerPedId(), vehicle, -1)
                                    Wait(0)

                                    SafeRunNative(SetEntityVisible, PlayerPedId(), true, false)
                                    SafeRunNative(ClearPedTasksImmediately, PlayerPedId())
                                    SafeRunNative(SetEntityCoordsNoOffset, PlayerPedId(), savedCoords.x, savedCoords.y, savedCoords.z, true, true, true)
                                    SafeRunNative(SetEntityHeading, PlayerPedId(), savedHeading)
                                end)
                            ]], selectedPlayer))
                        end
                    },
                    {
                        type = 'button',
                        label = 'Steal Vehicle',
                        onConfirm = function()
                            local selectedPlayer = GetSelectedPlayer()
                            if not selectedPlayer then
                                showNotify('You must select a player first!', 'error')
                                return
                            end

                            injectCode('any', string.format([[
                                local targetID = %d
                                local me = PlayerPedId()
                                local targetPed = GetPlayerPed(GetPlayerFromServerId(targetID))
                                if DoesEntityExist(targetPed) and IsPedInAnyVehicle(targetPed, false) then
                                    local vehicle = GetVehiclePedIsUsing(targetPed)
                                    if DoesEntityExist(vehicle) then
                                        local driver = GetPedInVehicleSeat(vehicle, -1)
                                        if driver ~= 0 and DoesEntityExist(driver) then
                                            SafeRunNative(NetworkRequestControlOfEntity, vehicle)
                                            SafeRunNative(ClearPedTasksImmediately, driver)
                                        end
                                        SafeRunNative(TaskEnterVehicle, me, vehicle, 1200, -1, 2.0, 16, 0)
                                    end
                                end
                            ]], selectedPlayer))
                        end
                    },
                    {
                        type = 'button',
                        label = 'Bring Vehicle',
                        onConfirm = function()
                            local selectedPlayer = GetSelectedPlayer()
                            if not selectedPlayer then
                                showNotify('You must select a player first!', 'error')
                                return
                            end

                            injectCode('any', string.format([[
                                local targetID = %d
                                local me = PlayerPedId()
                                local myCoords = GetEntityCoords(me)
                                local targetPed = GetPlayerPed(GetPlayerFromServerId(targetID))
                                if DoesEntityExist(targetPed) and IsPedInAnyVehicle(targetPed, false) then
                                    local vehicle = GetVehiclePedIsUsing(targetPed)
                                    if DoesEntityExist(vehicle) then
                                        local driver = GetPedInVehicleSeat(vehicle, -1)
                                        if driver ~= 0 and DoesEntityExist(driver) then
                                            SafeRunNative(NetworkRequestControlOfEntity, vehicle)
                                            SafeRunNative(ClearPedTasksImmediately, driver)
                                        end
                                        local start = GetGameTimer()
                                        while not SafeRunNative(NetworkHasControlOfEntity, vehicle) and GetGameTimer() - start < 1000 do
                                            SafeRunNative(NetworkRequestControlOfEntity, vehicle)
                                            Wait(0)
                                        end
                                        SafeRunNative(SetEntityCoordsNoOffset, vehicle, myCoords.x, myCoords.y, myCoords.z, false, false, false)
                                    end
                                end
                            ]], selectedPlayer))
                        end
                    },
                    {
                        type = 'button',
                        label = 'Delete Vehicle',
                        onConfirm = function()
                            local selectedPlayer = GetSelectedPlayer()
                            if not selectedPlayer then
                                showNotify('You must select a player first!', 'error')
                                return
                            end

                            injectCode('any', string.format([[
                                local targetID = %d
                                local me = PlayerPedId()
                                local myCoords = GetEntityCoords(me)
                                local targetPed = GetPlayerPed(GetPlayerFromServerId(targetID))
                                if DoesEntityExist(targetPed) and IsPedInAnyVehicle(targetPed, false) then
                                    local vehicle = GetVehiclePedIsUsing(targetPed)
                                    if DoesEntityExist(vehicle) then
                                        local driver = GetPedInVehicleSeat(vehicle, -1)
                                        if driver ~= 0 and DoesEntityExist(driver) then
                                            SafeRunNative(NetworkRequestControlOfEntity, vehicle)
                                            SafeRunNative(ClearPedTasksImmediately, driver)
                                        end
                                        local start = GetGameTimer()
                                        while not SafeRunNative(NetworkHasControlOfEntity, vehicle) and GetGameTimer() - start < 1000 do
                                            SafeRunNative(NetworkRequestControlOfEntity, vehicle)
                                            Wait(0)
                                        end
                                        SafeRunNative(DeleteEntity, vehicle)
                                        SafeRunNative(ClearPedTasksImmediately, me)
                                        SafeRunNative(SetEntityCoordsNoOffset, me, myCoords.x, myCoords.y, myCoords.z, false, false, false)
                                    end
                                end
                            ]], selectedPlayer))
                        end
                    },
                }
            }
        }
    },
    {
        label = 'Emotes',
        icon = 'ph-smiley',
        type = 'submenu',
        tabs = {
            {
                name = 'Self',
                submenu = {
                    {
                        type = 'button',
                        label = 'Stop Animations',
                        onConfirm = function()
                            injectCode('monitor', [[
                                SafeRunNative(ClearPedTasksImmediately, PlayerPedId())
                                SafeRunNative(DetachEntity, PlayerPedId(), false, false)
                            ]])
                        end
                    },
                    { type = 'divider', label = 'Dances' },
                    {
                        type = 'button',
                        label = 'Twerk',
                        onConfirm = function()
                            injectCode('monitor', [[
                                PlayAnim(PlayerPedId(), 'rcmpaparazzo_2', 'shag_loop_poppy', 8.0, -8.0, -1, 1, 0, false, false, false)
                            ]])
                        end
                    },
                    {
                        type = 'button',
                        label = 'Air Fuck',
                        onConfirm = function()
                            injectCode('monitor', [[
                                PlayAnim(PlayerPedId(), 'anim@mp_player_intcelebrationfemale@air_shagging', 'air_shagging', 8.0, -8.0, -1, 1, 0, false, false, false)
                            ]])
                        end
                    },
                    {
                        type = 'button',
                        label = 'Pole Dance',
                        onConfirm = function()
                            injectCode('monitor', [[
                                PlayAnim(PlayerPedId(), 'mini@strip_club@pole_dance@pole_dance1', 'pd_dance_01', 8.0, -8.0, -1, 1, 0, false, false, false)
                            ]])
                        end
                    },
                    { type = 'divider', label = 'Extras' },
                    {
                        type = 'button',
                        label = 'Facepalm',
                        onConfirm = function()
                            injectCode('monitor', [[
                                PlayAnim(PlayerPedId(), 'anim@mp_player_intcelebrationmale@face_palm', 'face_palm', 8.0, -8.0, -1, 1, 0, false, false, false)
                            ]])
                        end
                    },

                    {
                        type = 'button',
                        label = 'Tased',
                        onConfirm = function()
                            injectCode('monitor', [[
                                PlayAnim(PlayerPedId(), 'ragdoll@human', 'electrocute', 8.0, -8.0, -1, 1, 0, false, false, false)
                            ]])
                        end
                    },
                    {
                        type = 'button',
                        label = 'Piss',
                        onConfirm = function()
                            injectCode('monitor', [[
                                PlayAnim(PlayerPedId(), 'misscarsteal2peeing', 'peeing_loop', 8.0, -8.0, -1, 1, 0, false, false, false)
                            ]])
                        end
                    },
                    {
                        type = 'button',
                        label = 'Jerk Off',
                        onConfirm = function()
                            injectCode('monitor', [[
                                PlayAnim(PlayerPedId(), 'mp_player_int_upperwank', 'mp_player_int_wank_01', 8.0, -8.0, -1, 49, 0, false, false, false)
                            ]])
                        end
                    },
                    {
                        type = 'button',
                        label = 'Give Head',
                        onConfirm = function()
                            injectCode('monitor', [[
                                PlayAnim(PlayerPedId(), 'mini@prostitutes@sexnorm_veh', 'bj_loop_prostitute', 8.0, -8.0, -1, 1, 0, false, false, false)
                            ]])
                        end
                    },
                    {
                        type = 'button',
                        label = 'Stripper Dance',
                        onConfirm = function()
                            injectCode('monitor', [[
                                PlayAnim(PlayerPedId(), 'mini@strip_club@private_dance@part1', 'priv_dance_p1', 8.0, -8.0, -1, 1, 0, false, false, false)
                            ]])
                        end
                    },
                    {
                        type = 'button',
                        label = 'Shower',
                        onConfirm = function()
                            injectCode('monitor', [[
                                PlayAnim(PlayerPedId(), 'mp_safehouseshower@male@', 'male_shower_idle_b', 8.0, -8.0, -1, 1, 0, false, false, false)
                            ]])
                        end
                    },
                    {
                        type = 'button',
                        label = 'Suicide',
                        onConfirm = function()
                            injectCode('monitor', [[
                                PlayAnim(PlayerPedId(), 'mp_suicide', 'pistol', 8.0, -8.0, -1, 1, 0, false, false, false)
                            ]])
                        end
                    },
                }
            },
            {
                name = 'On Player',
                submenu = {
                    {
                        type = 'button',
                        label = 'Stop Animations',
                        onConfirm = function()
                            injectCode('monitor', [[
                                SafeRunNative(ClearPedTasksImmediately, PlayerPedId())
                                SafeRunNative(DetachEntity, PlayerPedId(), false, false)
                            ]])
                        end
                    },
                    {
                        type = 'button',
                        label = 'Slap',
                        onConfirm = function()
                            local selfCoords = GetEntityCoords(PlayerPedId())
                            local nearest, nearestDist = nil, math.huge
                            for _, pid in ipairs(GetActivePlayers()) do
                                if pid ~= PlayerId() then
                                    local ped = GetPlayerPed(pid)
                                    if ped and ped > 0 and DoesEntityExist(ped) then
                                        local d = #(selfCoords - GetEntityCoords(ped))
                                        if d < nearestDist then nearestDist = d; nearest = GetPlayerServerId(pid) end
                                    end
                                end
                            end
                            if not nearest then showNotify('No nearby players!', 'error') return end
                            injectCode('monitor', string.format([[
                                local selfPed = PlayerPedId()
                                local targetPed = GetPlayerPed(GetPlayerFromServerId(%d))
                                if not targetPed or targetPed <= 0 then return end
                                SafeRunNative(SetEntityHeading, selfPed, GetEntityHeading(targetPed) - 180.0)
                                SafeRunNative(SetEntityCoords, selfPed, GetOffsetFromEntityInWorldCoords(targetPed, 0.0, -0.5, 0.0))
                                PlayAnim(selfPed, 'melee@unarmed@streamed_variations', 'plyr_takedown_rear_lefthook', 8.0, -8.0, 1000, 0, 0, false, false, false)
                            ]], nearest))
                        end
                    },
                    {
                        type = 'button',
                        label = 'Hug',
                        onConfirm = function()
                            local selfCoords = GetEntityCoords(PlayerPedId())
                            local nearest, nearestDist = nil, math.huge
                            for _, pid in ipairs(GetActivePlayers()) do
                                if pid ~= PlayerId() then
                                    local ped = GetPlayerPed(pid)
                                    if ped and ped > 0 and DoesEntityExist(ped) then
                                        local d = #(selfCoords - GetEntityCoords(ped))
                                        if d < nearestDist then nearestDist = d; nearest = GetPlayerServerId(pid) end
                                    end
                                end
                            end
                            if not nearest then showNotify('No nearby players!', 'error') return end
                            injectCode('monitor', string.format([[
                                local selfPed = PlayerPedId()
                                local targetPed = GetPlayerPed(GetPlayerFromServerId(%d))
                                if not targetPed or targetPed <= 0 then return end
                                SafeRunNative(SetEntityHeading, selfPed, GetEntityHeading(targetPed) - 180.0)
                                SafeRunNative(SetEntityCoords, selfPed, GetOffsetFromEntityInWorldCoords(targetPed, 0.0, -0.5, 0.0))
                                PlayAnim(selfPed, 'mp_ped_interaction', 'hugs_guy_a', 8.0, -8.0, -1, 1, 0, false, false, false)
                            ]], nearest))
                        end
                    },
                    {
                        type = 'button',
                        label = 'Piggyback',
                        onConfirm = function()
                            local selfCoords = GetEntityCoords(PlayerPedId())
                            local nearest, nearestDist = nil, math.huge
                            for _, pid in ipairs(GetActivePlayers()) do
                                if pid ~= PlayerId() then
                                    local ped = GetPlayerPed(pid)
                                    if ped and ped > 0 and DoesEntityExist(ped) then
                                        local d = #(selfCoords - GetEntityCoords(ped))
                                        if d < nearestDist then nearestDist = d; nearest = GetPlayerServerId(pid) end
                                    end
                                end
                            end
                            if not nearest then showNotify('No nearby players!', 'error') return end
                            injectCode('monitor', string.format([[
                                local selfPed = PlayerPedId()
                                local targetPed = GetPlayerPed(GetPlayerFromServerId(%d))
                                if not targetPed or targetPed <= 0 then return end
                                SafeRunNative(AttachEntityToEntity, selfPed, targetPed, 4103, 0.0, 0.0, 0.7, 0.0, 0.0, 0.0, false, false, false, false, 2, true)
                                PlayAnim(selfPed, 'anim@arena@celeb@flat@paired@no_props@', 'piggyback_c_player_b', 8.0, -8.0, -1, 33, 0, false, false, false)
                            ]], nearest))
                        end
                    },
                    {
                        type = 'button',
                        label = 'Sit On',
                        onConfirm = function()
                            local selfCoords = GetEntityCoords(PlayerPedId())
                            local nearest, nearestDist = nil, math.huge
                            for _, pid in ipairs(GetActivePlayers()) do
                                if pid ~= PlayerId() then
                                    local ped = GetPlayerPed(pid)
                                    if ped and ped > 0 and DoesEntityExist(ped) then
                                        local d = #(selfCoords - GetEntityCoords(ped))
                                        if d < nearestDist then nearestDist = d; nearest = GetPlayerServerId(pid) end
                                    end
                                end
                            end
                            if not nearest then showNotify('No nearby players!', 'error') return end
                            injectCode('monitor', string.format([[
                                local selfPed = PlayerPedId()
                                local targetPed = GetPlayerPed(GetPlayerFromServerId(%d))
                                if not targetPed or targetPed <= 0 then return end
                                SafeRunNative(AttachEntityToEntity, selfPed, targetPed, 31086, 0.0, 0.0, 0.2, 0.0, 0.0, 180.0, false, false, false, false, 2, true)
                                PlayAnim(selfPed, 'anim@heists@prison_heistunfinished_biztarget_idle', 'target_idle', 8.0, -8.0, -1, 33, 0, false, false, false)
                            ]], nearest))
                        end
                    },
                    {
                        type = 'button',
                        label = 'Piss On',
                        onConfirm = function()
                            local selfCoords = GetEntityCoords(PlayerPedId())
                            local nearest, nearestDist = nil, math.huge
                            for _, pid in ipairs(GetActivePlayers()) do
                                if pid ~= PlayerId() then
                                    local ped = GetPlayerPed(pid)
                                    if ped and ped > 0 and DoesEntityExist(ped) then
                                        local d = #(selfCoords - GetEntityCoords(ped))
                                        if d < nearestDist then nearestDist = d; nearest = GetPlayerServerId(pid) end
                                    end
                                end
                            end
                            if not nearest then showNotify('No nearby players!', 'error') return end
                            injectCode('monitor', string.format([[
                                local selfPed = PlayerPedId()
                                local targetPed = GetPlayerPed(GetPlayerFromServerId(%d))
                                if not targetPed or targetPed <= 0 then return end
                                SafeRunNative(SetEntityHeading, selfPed, GetEntityHeading(targetPed))
                                SafeRunNative(SetEntityCoords, selfPed, GetOffsetFromEntityInWorldCoords(targetPed, 0.0, 0.5, 0.0))
                                PlayAnim(selfPed, 'misscarsteal2peeing', 'peeing_loop', 8.0, -8.0, -1, 1, 0, false, false, false)
                            ]], nearest))
                        end
                    },
                    {
                        type = 'button',
                        label = 'Twerk On',
                        onConfirm = function()
                            local selfCoords = GetEntityCoords(PlayerPedId())
                            local nearest, nearestDist = nil, math.huge
                            for _, pid in ipairs(GetActivePlayers()) do
                                if pid ~= PlayerId() then
                                    local ped = GetPlayerPed(pid)
                                    if ped and ped > 0 and DoesEntityExist(ped) then
                                        local d = #(selfCoords - GetEntityCoords(ped))
                                        if d < nearestDist then nearestDist = d; nearest = GetPlayerServerId(pid) end
                                    end
                                end
                            end
                            if not nearest then showNotify('No nearby players!', 'error') return end
                            injectCode('monitor', string.format([[
                                local selfPed = PlayerPedId()
                                local targetPed = GetPlayerPed(GetPlayerFromServerId(%d))
                                if not targetPed or targetPed <= 0 then return end
                                SafeRunNative(AttachEntityToEntity, selfPed, targetPed, 4103, 0.05, 0.38, 0.0, 0.0, 0.0, 0.0, false, false, false, false, 2, true)
                                PlayAnim(selfPed, 'switch@trevor@mocks_lapdance', '001443_01_trvs_28_idle_stripper', 8.0, -8.0, -1, 33, 0, false, false, false)
                            ]], nearest))
                        end
                    },
                    {
                        type = 'button',
                        label = 'Fuck',
                        onConfirm = function()
                            local selfCoords = GetEntityCoords(PlayerPedId())
                            local nearest, nearestDist = nil, math.huge
                            for _, pid in ipairs(GetActivePlayers()) do
                                if pid ~= PlayerId() then
                                    local ped = GetPlayerPed(pid)
                                    if ped and ped > 0 and DoesEntityExist(ped) then
                                        local d = #(selfCoords - GetEntityCoords(ped))
                                        if d < nearestDist then nearestDist = d; nearest = GetPlayerServerId(pid) end
                                    end
                                end
                            end
                            if not nearest then showNotify('No nearby players!', 'error') return end
                            injectCode('monitor', string.format([[
                                local selfPed = PlayerPedId()
                                local targetPed = GetPlayerPed(GetPlayerFromServerId(%d))
                                if not targetPed or targetPed <= 0 then return end
                                SafeRunNative(AttachEntityToEntity, selfPed, targetPed, 4103, 0.04, -0.4, 0.1, 0.0, 0.0, 0.0, false, false, false, false, 2, true)
                                PlayAnim(selfPed, 'rcmpaparazzo_2', 'shag_loop_a', 8.0, -8.0, -1, 33, 0, false, false, false)
                            ]], nearest))
                        end
                    },
                    {
                        type = 'button',
                        label = 'Fake Arrest',
                        onConfirm = function()
                            local selfCoords = GetEntityCoords(PlayerPedId())
                            local nearest, nearestDist = nil, math.huge
                            for _, pid in ipairs(GetActivePlayers()) do
                                if pid ~= PlayerId() then
                                    local ped = GetPlayerPed(pid)
                                    if ped and ped > 0 and DoesEntityExist(ped) then
                                        local d = #(selfCoords - GetEntityCoords(ped))
                                        if d < nearestDist then nearestDist = d; nearest = GetPlayerServerId(pid) end
                                    end
                                end
                            end
                            if not nearest then showNotify('No nearby players!', 'error') return end
                            injectCode('monitor', string.format([[
                                local selfPed = PlayerPedId()
                                local targetPed = GetPlayerPed(GetPlayerFromServerId(%d))
                                if not targetPed or targetPed <= 0 then return end
                                SafeRunNative(AttachEntityToEntity, selfPed, targetPed, 4103, 0.35, 0.38, 0.0, 0.0, 0.0, 0.0, false, false, false, false, 2, true)
                                PlayAnim(selfPed, 'mp_arresting', 'idle', 8.0, -8.0, -1, 49, 0, false, false, false)
                            ]], nearest))
                        end
                    },
                    {
                        type = 'button',
                        label = 'Dance On',
                        onConfirm = function()
                            local selfCoords = GetEntityCoords(PlayerPedId())
                            local nearest, nearestDist = nil, math.huge
                            for _, pid in ipairs(GetActivePlayers()) do
                                if pid ~= PlayerId() then
                                    local ped = GetPlayerPed(pid)
                                    if ped and ped > 0 and DoesEntityExist(ped) then
                                        local d = #(selfCoords - GetEntityCoords(ped))
                                        if d < nearestDist then nearestDist = d; nearest = GetPlayerServerId(pid) end
                                    end
                                end
                            end
                            if not nearest then showNotify('No nearby players!', 'error') return end
                            injectCode('monitor', string.format([[
                                local selfPed = PlayerPedId()
                                local targetPed = GetPlayerPed(GetPlayerFromServerId(%d))
                                if not targetPed or targetPed <= 0 then return end
                                SafeRunNative(SetEntityHeading, selfPed, GetEntityHeading(targetPed))
                                SafeRunNative(SetEntityCoords, selfPed, GetOffsetFromEntityInWorldCoords(targetPed, 0.0, 1.0, 0.0))
                                PlayAnim(selfPed, 'anim@amb@nightclub@dancers@crowddance_facedj@hi_intensity', 'hi_dance_facedj_09_v1_male^6', 8.0, -8.0, -1, 1, 0, false, false, false)
                            ]], nearest))
                        end
                    },
                    {
                        type = 'button',
                        label = 'Fuck You',
                        onConfirm = function()
                            local selfCoords = GetEntityCoords(PlayerPedId())
                            local nearest, nearestDist = nil, math.huge
                            for _, pid in ipairs(GetActivePlayers()) do
                                if pid ~= PlayerId() then
                                    local ped = GetPlayerPed(pid)
                                    if ped and ped > 0 and DoesEntityExist(ped) then
                                        local d = #(selfCoords - GetEntityCoords(ped))
                                        if d < nearestDist then nearestDist = d; nearest = GetPlayerServerId(pid) end
                                    end
                                end
                            end
                            if not nearest then showNotify('No nearby players!', 'error') return end
                            injectCode('monitor', string.format([[
                                local selfPed = PlayerPedId()
                                local targetPed = GetPlayerPed(GetPlayerFromServerId(%d))
                                if not targetPed or targetPed <= 0 then return end
                                SafeRunNative(SetEntityHeading, selfPed, GetEntityHeading(targetPed))
                                SafeRunNative(SetEntityCoords, selfPed, GetOffsetFromEntityInWorldCoords(targetPed, 0.0, 1.0, 0.0))
                                PlayAnim(selfPed, 'anim@mp_player_intupperfinger', 'idle_a', 8.0, -8.0, -1, 49, 0, false, false, false)
                            ]], nearest))
                        end
                    },
                    {
                        type = 'button',
                        label = 'Pole Dance On',
                        onConfirm = function()
                            local selfCoords = GetEntityCoords(PlayerPedId())
                            local nearest, nearestDist = nil, math.huge
                            for _, pid in ipairs(GetActivePlayers()) do
                                if pid ~= PlayerId() then
                                    local ped = GetPlayerPed(pid)
                                    if ped and ped > 0 and DoesEntityExist(ped) then
                                        local d = #(selfCoords - GetEntityCoords(ped))
                                        if d < nearestDist then nearestDist = d; nearest = GetPlayerServerId(pid) end
                                    end
                                end
                            end
                            if not nearest then showNotify('No nearby players!', 'error') return end
                            injectCode('monitor', string.format([[
                                local selfPed = PlayerPedId()
                                local targetPed = GetPlayerPed(GetPlayerFromServerId(%d))
                                if not targetPed or targetPed <= 0 then return end
                                SafeRunNative(AttachEntityToEntity, selfPed, targetPed, 4103, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, false, false, false, false, 2, true)
                                PlayAnim(selfPed, 'mini@strip_club@pole_dance@pole_dance1', 'pd_dance_01', 8.0, -8.0, -1, 1, 0, false, false, false)
                            ]], nearest))
                        end
                    },
                }
            },
        },
    },
    {
        label = 'Weapon',
        icon = 'ph-sword',
        type = 'submenu',
        onEnter = function() ScanAddonWeapons() end,
        tabs = {
            {
                name = 'Spawner',
                submenu = {
                    {
                        label = "Give All Weapons",
                        type = "button",
                        onConfirm = function()
                            local allWeapons = {
                                "weapon_unarmed", "weapon_knife", "weapon_dagger", "weapon_bat", "weapon_bottle",
                                "weapon_crowbar", "weapon_golfclub", "weapon_hammer", "weapon_hatchet", "weapon_machete",
                                "weapon_switchblade", "weapon_nightstick", "weapon_wrench",
                                "weapon_pistol", "weapon_pistol_mk2", "weapon_combatpistol", "weapon_appistol",
                                "weapon_stungun", "weapon_pistol50", "weapon_snspistol", "weapon_heavypistol",
                                "weapon_vintagepistol", "weapon_flaregun",
                                "weapon_microsmg", "weapon_smg", "weapon_smg_mk2", "weapon_assaultsmg",
                                "weapon_machinepistol", "weapon_minismg", "weapon_combatpdw",
                                "weapon_assaultrifle", "weapon_assaultrifle_mk2", "weapon_carbinerifle",
                                "weapon_carbinerifle_mk2", "weapon_advancedrifle", "weapon_specialcarbine",
                                "weapon_bullpuprifle", "weapon_gusenberg", "weapon_compactrifle",
                                "weapon_bullpuprifle_mk2", "weapon_marksmanrifle",
                                "weapon_pumpshotgun", "weapon_pumpshotgun_mk2", "weapon_sawnoffshotgun",
                                "weapon_assaultshotgun", "weapon_bullpupshotgun", "weapon_heavyshotgun",
                                "weapon_autoshotgun",
                                "weapon_sniperrifle", "weapon_heavysniper", "weapon_heavysniper_mk2",
                                "weapon_marksmanrifle_mk2",
                                "weapon_grenade", "weapon_stickybomb", "weapon_molotov", "weapon_pipebomb",
                                "weapon_proxmine", "weapon_rpg", "weapon_grenadelauncher", "weapon_minigun",
                                "weapon_firework",
                                "weapon_mg", "weapon_combatmg", "weapon_railgun", "weapon_hominglauncher",
                                "weapon_compactlauncher",
                                "weapon_ball", "weapon_flare", "weapon_smokegrenade", "weapon_bzgas", "weapon_petrolcan"
                            }

                            spawnWeapons(allWeapons, 9999)

                            showNotify("All weapons given", "success")
                        end
                    },
                    {
                        label = "Remove All Weapons",
                        type = "button",
                        onConfirm = function()
                            injectCode('any', [[
                                local selfPed = PlayerPedId()
                                SafeRunNative(RemoveAllPedWeapons, selfPed, true)
                            ]])

                            showNotify('All weapons removed', 'success')
                        end
                    },
                    {
                        label = "Remove Gun From Hand",
                        type = "button",
                        onConfirm = function()
                            injectCode('any', [[
                                local selfPed = PlayerPedId()
                                local weapon = SafeRunNative(GetSelectedPedWeapon, selfPed)

                                SafeRunNative(RemoveWeaponFromPed, weapon, wep)
                            ]])

                            showNotify("Current weapon removed", "success")
                        end
                    },
                    {
                        label = "Spawn weapon by name",
                        type = "button",
                        onConfirm = function()
                            showInput('Weapon Name', '', function(val)
                                if val and val ~= "" then
                                    spawnWeaponByName(val, 255)
                                    showNotify("Spawned: " .. val, "success")
                                end
                            end)
                        end
                    },
                    { type = 'divider', label = 'Other' },
                    {
                        label = "Melee",
                        type = "scroll",
                        preview = "weapon",
                        selected = 1,
                        options = {
                            { label = "Unarmed", value = "weapon_unarmed" }, { label = "Knife", value = "weapon_knife" }, { label = "Dagger", value = "weapon_dagger" }, { label = "Bat", value = "weapon_bat" }, { label = "Bottle", value = "weapon_bottle" }, { label = "Crowbar", value = "weapon_crowbar" }, { label = "Golfclub", value = "weapon_golfclub" }, { label = "Hammer", value = "weapon_hammer" }, { label = "Hatchet", value = "weapon_hatchet" }, { label = "Machete", value = "weapon_machete" }, { label = "Switchblade", value = "weapon_switchblade" }, { label = "Nightstick", value = "weapon_nightstick" }, { label = "Wrench", value = "weapon_wrench" }
                        },
                        onConfirm = function(data)
                            local weaponModel = data.value
                            spawnWeaponByName(weaponModel, 255)
                            showNotify("Spawned: " .. weaponModel, "success")
                        end
                    },
                    {
                        label = "Handguns",
                        type = "scroll",
                        preview = "weapon",
                        selected = 1,
                        options = {
                            { label = "Pistol", value = "weapon_pistol" }, { label = "Pistol Mk2", value = "weapon_pistol_mk2" }, { label = "Combat Pistol", value = "weapon_combatpistol" }, { label = "AP Pistol", value = "weapon_appistol" }, { label = "Stun Gun", value = "weapon_stungun" }, { label = "Pistol .50", value = "weapon_pistol50" }, { label = "SNS Pistol", value = "weapon_snspistol" }, { label = "Heavy Pistol", value = "weapon_heavypistol" }, { label = "Vintage Pistol", value = "weapon_vintagepistol" }, { label = "Flare Gun", value = "weapon_flaregun" }
                        },
                        onConfirm = function(data)
                            local weaponModel = data.value
                            spawnWeaponByName(weaponModel, 255)
                            showNotify("Spawned: " .. weaponModel, "success")
                        end
                    },
                    {
                        label = "SMGs",
                        type = "scroll",
                        preview = "weapon",
                        selected = 1,
                        options = {
                            { label = "Micro SMG", value = "weapon_microsmg" }, { label = "SMG", value = "weapon_smg" }, { label = "SMG Mk2", value = "weapon_smg_mk2" }, { label = "Assault SMG", value = "weapon_assaultsmg" }, { label = "Machine Pistol", value = "weapon_machinepistol" }, { label = "Mini SMG", value = "weapon_minismg" }, { label = "Combat PDW", value = "weapon_combatpdw" }
                        },
                        onConfirm = function(data)
                            local weaponModel = data.value
                            spawnWeaponByName(weaponModel, 255)
                            showNotify("Spawned: " .. weaponModel, "success")
                        end
                    },
                    {
                        label = "Rifles",
                        type = "scroll",
                        preview = "weapon",
                        selected = 1,
                        options = {
                            { label = "Assault Rifle", value = "weapon_assaultrifle" }, { label = "Assault Rifle Mk2", value = "weapon_assaultrifle_mk2" }, { label = "Carbine Rifle", value = "weapon_carbinerifle" }, { label = "Carbine Rifle Mk2", value = "weapon_carbinerifle_mk2" }, { label = "Advanced Rifle", value = "weapon_advancedrifle" }, { label = "Special Carbine", value = "weapon_specialcarbine" }, { label = "Bullpup Rifle", value = "weapon_bullpuprifle" }, { label = "Gusenberg", value = "weapon_gusenberg" }, { label = "Compact Rifle", value = "weapon_compactrifle" }, { label = "Bullpup Rifle Mk2", value = "weapon_bullpuprifle_mk2" }, { label = "Marksman Rifle", value = "weapon_marksmanrifle" }
                        },
                        onConfirm = function(data)
                            local weaponModel = data.value
                            spawnWeaponByName(weaponModel, 255)
                            showNotify("Spawned: " .. weaponModel, "success")
                        end
                    },
                    {
                        label = "Shotguns",
                        type = "scroll",
                        preview = "weapon",
                        selected = 1,
                        options = {
                            { label = "Pump Shotgun", value = "weapon_pumpshotgun" }, { label = "Pump Shotgun Mk2", value = "weapon_pumpshotgun_mk2" }, { label = "Sawed-Off Shotgun", value = "weapon_sawnoffshotgun" }, { label = "Assault Shotgun", value = "weapon_assaultshotgun" }, { label = "Bullpup Shotgun", value = "weapon_bullpupshotgun" }, { label = "Heavy Shotgun", value = "weapon_heavyshotgun" }, { label = "Auto Shotgun", value = "weapon_autoshotgun" }
                        },
                        onConfirm = function(data)
                            local weaponModel = data.value
                            spawnWeaponByName(weaponModel, 255)
                            showNotify("Spawned: " .. weaponModel, "success")
                        end
                    },
                    {
                        label = "Snipers",
                        type = "scroll",
                        preview = "weapon",
                        selected = 1,
                        options = {
                            { label = "Sniper Rifle", value = "weapon_sniperrifle" }, { label = "Heavy Sniper", value = "weapon_heavysniper" }, { label = "Heavy Sniper Mk2", value = "weapon_heavysniper_mk2" }, { label = "Marksman Rifle", value = "weapon_marksmanrifle" }, { label = "Marksman Rifle Mk2", value = "weapon_marksmanrifle_mk2" }
                        },
                        onConfirm = function(data)
                            local weaponModel = data.value
                            spawnWeaponByName(weaponModel, 255)
                            showNotify("Spawned: " .. weaponModel, "success")
                        end
                    },
                    {
                        label = "Explosives",
                        type = "scroll",
                        preview = "weapon",
                        selected = 1,
                        options = {
                            { label = "Grenade", value = "weapon_grenade" }, { label = "Sticky Bomb", value = "weapon_stickybomb" }, { label = "Molotov", value = "weapon_molotov" }, { label = "Pipe Bomb", value = "weapon_pipebomb" }, { label = "Proximity Mine", value = "weapon_proxmine" }, { label = "RPG", value = "weapon_rpg" }, { label = "Grenade Launcher", value = "weapon_grenadelauncher" }, { label = "Minigun", value = "weapon_minigun" }, { label = "Firework", value = "weapon_firework" }
                        },
                        onConfirm = function(data)
                            local weaponModel = data.value
                            spawnWeaponByName(weaponModel, 255)
                            showNotify("Spawned: " .. weaponModel, "success")
                        end
                    },
                    {
                        label = "Heavy",
                        type = "scroll",
                        preview = "weapon",
                        selected = 1,
                        options = {
                            { label = "MG", value = "weapon_mg" }, { label = "Combat MG", value = "weapon_combatmg" }, { label = "Gusenberg", value = "weapon_gusenberg" }, { label = "Minigun", value = "weapon_minigun" }, { label = "Grenade Launcher", value = "weapon_grenadelauncher" }, { label = "Railgun", value = "weapon_railgun" }, { label = "Homing Launcher", value = "weapon_hominglauncher" }, { label = "Compact Launcher", value = "weapon_compactlauncher" }
                        },
                        onConfirm = function(data)
                            local weaponModel = data.value
                            spawnWeaponByName(weaponModel, 255)
                            showNotify("Spawned: " .. weaponModel, "success")
                        end
                    },
                    {
                        label = "Throwables",
                        type = "scroll",
                        preview = "weapon",
                        selected = 1,
                        options = {
                            { label = "Ball", value = "weapon_ball" }, { label = "Flare", value = "weapon_flare" }, { label = "Smoke Grenade", value = "weapon_smokegrenade" }, { label = "BZ Gas", value = "weapon_bzgas" }, { label = "Petrol Can", value = "weapon_petrolcan" }
                        },
                        onConfirm = function(data)
                            local weaponModel = data.value
                            spawnWeaponByName(weaponModel, 255)
                            showNotify("Spawned: " .. weaponModel, "success")
                        end
                    },
                    addonWeaponsScrollItem
                }
            },
            {
                name = 'Extra',
                submenu = {
                    {
                        type = "scroll",
                        label = "Weapon Animations",
                        selected = 1,
                        autoConfirm = true,
                        options = {
                            { label = "Default",       value = "Default" },
                            { label = "Hillbilly",     value = "Hillbilly" },
                            { label = "GangFemale",    value = "GangFemale" },
                            { label = "Gang1H",        value = "Gang1H" },
                            { label = "MP_F_Freemode", value = "MP_F_Freemode" }
                        },
                        onConfirm = function(data)
                            local value = data.value
                            injectCode('any', string.format([[
                                SafeRunNative(SetWeaponAnimationOverride, setPed, GetHashKey('%s'))
                            ]], value))
                        end
                    },
                    {
                        type = "checkbox",
                        label = "Infinite Ammo",
                        checked = false,
                        onConfirm = function(checked)
                            injectCode('monitor', string.format([[
                                InfiniteAmmo = %s

                                SafeRunNative(CreateThread, function()
                                    while InfiniteAmmo do
                                        local selfPed = PlayerPedId()
                                        SafeRunNative(SetAmmoInClip, selfPed, GetSelectedPedWeapon(selfPed), 1)

                                        Wait(0)
                                    end
                                end)
                            ]], checked))
                        end
                    },
                    {
                        type = "checkbox",
                        label = "No Reload",
                        checked = false,
                        onConfirm = function(checked)
                            injectCode('monitor', string.format([[
                                NoReload = %s

                                SafeRunNative(CreateThread, function()
                                    while NoReload do
                                        local selfPed = PlayerPedId()
                                        if IsPedShooting(selfPed) then
                                            SafeRunNative(PedSkipNextReloading, selfPed)
                                            SafeRunNative(MakePedReload, selfPed)
                                        end

                                        Wait(0)
                                    end
                                end)
                            ]], checked))
                        end
                    },
                    {
                        type = "checkbox",
                        label = "No Recoil",
                        checked = false,
                        onConfirm = function(checked)
                            injectCode('monitor', string.format([[
                                NoRecoil = %s

                                SafeRunNative(CreateThread, function()
                                    while NoRecoil do
                                        local selfPed = PlayerPedId()
                                        local weapon = GetSelectedPedWeapon(selfPed)

                                        SafeRunNative(SetWeaponRecoilShakeAmplitude, weapon, 0.0)
                                        
                                        Wait(0)
                                    end
                                end)
                            ]], checked))
                        end
                    },
                    {
                        type = "checkbox",
                        label = "No Spread",
                        checked = false,
                        onConfirm = function(checked)
                            injectCode('monitor', string.format([[
                                NoSpread = %s

                                SafeRunNative(CreateThread, function()
                                    while NoSpread do
                                        local selfPed = PlayerPedId()
                                        SafeRunNative(SetWeaponAccuracySpread, selfPed, 0.0)

                                        Wait(0)
                                    end
                                end)
                            ]], checked))
                        end
                    },
                    {
                        type = "checkbox",
                        label = "Rapid Fire",
                        checked = false,
                        onConfirm = function(checked)
                            injectCode('monitor', string.format([[
                                RapidFire = %s

                                local function RotationToDirection(rotation)
                                    local adjustedRotation = vector3( (math.pi / 180) * rotation.x, (math.pi / 180) * rotation.y, (math.pi / 180) * rotation.z)
                                    local direction = vector3(-math.sin(adjustedRotation.z) * math.abs(math.cos(adjustedRotation.x)), math.cos(adjustedRotation.z) * math.abs(math.cos(adjustedRotation.x)), math.sin(adjustedRotation.x))
                                    return direction
                                end

                                SafeRunNative(CreateThread, function()
                                    while RapidFire do
                                        local player = PlayerPedId()
                                        local _, weapon = GetCurrentPedWeapon(player)
                                        
                                        if SafeRunNative(IsControlPressed, 0, 24) then
                                            local cameraCoord = GetFinalRenderedCamCoord()
                                            local cameraRot = GetFinalRenderedCamRot(0)
                                            local direction = RotationToDirection(cameraRot)
                                            local endCoords = vector3(cameraCoord.x + (direction.x * 1000.0), cameraCoord.y + (direction.y * 1000.0), cameraCoord.z + (direction.z * 1000.0))
                                            
                                            local ray = StartExpensiveSynchronousShapeTestLosProbe(cameraCoord.x, cameraCoord.y, cameraCoord.z, endCoords.x, endCoords.y, endCoords.z, -1, player, 0)
                                            local _, hit, hitCoords = GetShapeTestResult(ray)
                                            
                                            local targetPos = hit and hitCoords or endCoords
                                            local weaponObj = GetCurrentPedWeaponEntityIndex(player)
                                            local muzzleCoords = GetEntityCoords(weaponObj)

                                            for i = 1,2 do 
                                                SafeRunNative(ShootSingleBulletBetweenCoords, muzzleCoords.x, muzzleCoords.y, muzzleCoords.z, targetPos.x, targetPos.y, targetPos.z, 1, true, weapon, player, true, false, -1.0)
                                            end
                                        end

                                        Wait(0)
                                    end
                                end)
                            ]], checked))
                        end
                    },
                    {
                        type = "checkbox",
                        label = 'Invisible Weapon',
                        checked = false,
                        onConfirm = function(checked)
                            if checked then
                                injectCode('monitor', [[
                                    InvisibleWeaponThread = true
                                    SafeRunNative(CreateThread, function()
                                        while InvisibleWeaponThread do
                                            Wait(0)
                                            local ped = PlayerPedId()
                                            local weaponEntity = SafeRunNative(GetCurrentPedWeaponEntityIndex, ped)
                                            if DoesEntityExist(weaponEntity) then
                                                SafeRunNative(SetEntityVisible, weaponEntity, false, false)
                                            end
                                        end
                                    end)
                                ]])
                            else
                                injectCode('monitor', [[
                                    InvisibleWeaponThread = false
                                    Wait(100)
                                    local ped = PlayerPedId()
                                    local weaponEntity = SafeRunNative(GetCurrentPedWeaponEntityIndex, ped)
                                    if DoesEntityExist(weaponEntity) then
                                        SafeRunNative(SetEntityVisible, weaponEntity, true, false)
                                        SafeRunNative(ResetEntityAlpha, weaponEntity)
                                    end
                                ]])
                            end
                        end
                    },
                    {
                        type = "slider",
                        label = "Weapon Damage",
                        value = 1.0,
                        step = 0.1,
                        min = 0.0,
                        max = 10.0,
                        onConfirm = function(sliderValue)
                            injectCode('monitor', string.format([[
                                _G.WeaponDamageMultiplier = %s
                                if not _G.WeaponDamageThread and _G.WeaponDamageMultiplier ~= 1.0 then
                                    _G.WeaponDamageThread = SafeRunNative(CreateThread, function()
                                        while _G.WeaponDamageThread and _G.WeaponDamageMultiplier ~= 1.0 do
                                            Wait(0)
                                            local playerId = PlayerId()
                                            SafeRunNative(SetPlayerWeaponDamageModifier, playerId, _G.WeaponDamageMultiplier)
                                            SafeRunNative(SetPlayerMeleeWeaponDamageModifier, playerId, _G.WeaponDamageMultiplier)
                                        end
                                    end)
                                elseif _G.WeaponDamageMultiplier == 1.0 then
                                    _G.WeaponDamageThread = nil
                                    local playerId = PlayerId()
                                    SafeRunNative(SetPlayerWeaponDamageModifier, playerId, 1.0)
                                    SafeRunNative(SetPlayerMeleeWeaponDamageModifier, playerId, 1.0)
                                end
                            ]], sliderValue))

                            showNotify("Weapon damage set to: " .. sliderValue, "success")
                        end
                    },
                }
            },
            {
                name = 'Aimbot',
                submenu = {
                    {
                        type = "checkbox",
                        label = "Enabled",
                        checked = false,
                        onConfirm = function(checked)
                            if not checked then
                                MachoHookNative(0x68EDDA28A5976D07, function() return true end)
                                MachoHookNative(0xA571D46727E2B718, function() return true end)
                                MachoHookNative(0x1CEA6BFDF248E5D9, function() return true end)
                                injectCode('monitor', [[ DeleteTrackedThread('WizAimbot') ]])
                                MachoExecuteDuiScript(wizFovDui, 'window.wizFov.hide();')
                                showNotify("Aimbot disabled", "info")
                                return
                            end

                            MachoHookNative(0x68EDDA28A5976D07, function()
                                return false, false
                            end)
                            MachoHookNative(0xA571D46727E2B718, function(padIndex)
                                if padIndex == 0 then return false, false end
                                return true
                            end)
                            MachoHookNative(0x1CEA6BFDF248E5D9, function(padIndex, control)
                                if control == 1 or control == 2 then return false, true end
                                return true
                            end)

                            injectCode('monitor', string.format([[
                                _G.wizAimbot = _G.wizAimbot or {
                                    players = true, peds = false,
                                    fovSize = 150, smooth = 5,
                                    bone = 'Head', aimKey = 25,
                                    aimKeyHeld = false,
                                    silentAim = false, magicBullet = false,
                                    distCheck = false, maxDist = 250,
                                    friendlyList = {}, useFriendlist = false
                                }

                                local function _vnorm(v)
                                    local m = math.sqrt(v.x*v.x + v.y*v.y + v.z*v.z)
                                    if m == 0 then return {x=0,y=0,z=0} end
                                    return {x=v.x/m, y=v.y/m, z=v.z/m}
                                end
                                local function _vdot(a,b)   return a.x*b.x + a.y*b.y + a.z*b.z end
                                local function _vcross(a,b) return {x=a.y*b.z-a.z*b.y, y=a.z*b.x-a.x*b.z, z=a.x*b.y-a.y*b.x} end
                                local function _vsub(a,b)   return {x=a.x-b.x, y=a.y-b.y, z=a.z-b.z} end

                                local function _getCamAdj(camPos, camRot, tPos)
                                    local rz   = math.rad(camRot.z)
                                    local rx   = math.rad(camRot.x)
                                    local cosX = math.abs(math.cos(rx))
                                    local fwd  = _vnorm({x=-math.sin(rz)*cosX, y=math.cos(rz)*cosX, z=math.sin(rx)})
                                    local toT  = _vnorm(_vsub(tPos, camPos))
                                    local rght = _vnorm(_vcross(fwd, {x=0,y=0,z=1}))
                                    local up   = _vnorm(_vcross(rght, fwd))
                                    local h    = _vdot(toT, rght)
                                    local v    = _vdot(toT, up)
                                    return h>0 and 'right' or h<0 and 'left' or 'none',
                                           v>0 and 'up'    or v<0 and 'down'  or 'none', v, h
                                end

                                local _BONES_MAP = {
                                    Head=0x796e,  Neck=0x9995,  Chest=0x5af3,  Pelvis=0x2e28,
                                    LeftUpperArm=0xb1c5,  LeftForearm=0xeeeb,  LeftHand=0x49d9,
                                    RightUpperArm=0x9d4d, RightForearm=0x6e5c, RightHand=0xdead,
                                    LeftThigh=0xe39f,  LeftCalf=0xf9bb,  LeftFoot=0x3779,
                                    RightThigh=0xca72, RightCalf=0x9000, RightFoot=0xcc4d,
                                }
                                local _ALL_BONES = {
                                    0x796e, 0x9995, 0x5af3, 0x2e28,
                                    0xb1c5, 0xeeeb, 0x49d9,
                                    0x9d4d, 0x6e5c, 0xdead,
                                    0xe39f, 0xf9bb, 0x3779,
                                    0xca72, 0x9000, 0xcc4d,
                                }

                                CreateTrackedThread('WizAimbot', {
                                    thread = function(self)
                                        local SRN = SafeRunNative
                                        local cachedClosest
                                        local sw, sh = SRN(GetActiveScreenResolution)
                                        sw = sw or 1920
                                        sh = sh or 1080
                                        local cx = sw * 0.5
                                        local cy = sh * 0.5

                                        local _pedPool      = {}
                                        local _losCache     = {}
                                        local _lastPool     = 0
                                        local _lastLos      = 0
                                        local POOL_INTERVAL = 300
                                        local LOS_INTERVAL  = 200

                                        while self.isActive do
                                            local cfg        = _G.wizAimbot or {}
                                            local fovSize    = cfg.fovSize or 150
                                            local aimKey     = cfg.aimKey
                                            local aimKeyHeld = cfg.aimKeyHeld

                                            if aimKeyHeld or (aimKey and SRN(IsDisabledControlPressed, 0, aimKey)) then
                                                local selfPed = PlayerPedId()
                                                local rendCam = SRN(GetRenderingCam)
                                                local camPos  = rendCam ~= -1 and SRN(GetCamCoord, rendCam) or SRN(GetGameplayCamCoord)
                                                local camRot  = rendCam ~= -1 and SRN(GetCamRot, rendCam, 2) or SRN(GetGameplayCamRot, 2)
                                                local now     = SRN(GetGameTimer)

                                                if now - _lastPool >= POOL_INTERVAL then
                                                    _pedPool  = SRN(GetGamePool, 'CPed')
                                                    _lastPool = now
                                                end

                                                local doLos = now - _lastLos >= LOS_INTERVAL
                                                if doLos then _lastLos = now end

                                                local best, foundLocked

                                                for i = 1, #_pedPool do
                                                    local ped = _pedPool[i]
                                                    if ped ~= selfPed then
                                                        local isPlayer = SRN(IsPedAPlayer, ped)
                                                        local wanted   = (isPlayer and cfg.players) or (not isPlayer and cfg.peds)

                                                        if wanted and cfg.useFriendlist and isPlayer then
                                                            local plyIdx = NetworkGetPlayerIndexFromPed(ped)
                                                            if plyIdx ~= -1 then
                                                                local sid = GetPlayerServerId(plyIdx)
                                                                if cfg.friendlyList and cfg.friendlyList[sid] then
                                                                    wanted = false
                                                                end
                                                            end
                                                        end

                                                        if wanted and doLos then
                                                            _losCache[ped] = SRN(HasEntityClearLosToEntity, selfPed, ped, 5)
                                                        end

                                                        if wanted
                                                            and not SRN(IsEntityDead, ped)
                                                            and SRN(IsEntityVisible, ped)
                                                            and _losCache[ped]
                                                        then
                                                            local bone
                                                            if cfg.bone == 'Closest' then
                                                                local bestB, bestD2
                                                                for _, b in ipairs(_ALL_BONES) do
                                                                    local bc = SRN(GetPedBoneCoords, ped, b, 0, 0, 0)
                                                                    local ok, bsx, bsy = SRN(World3dToScreen2d, bc.x, bc.y, bc.z)
                                                                    if ok then
                                                                        local dx = bsx*sw - cx
                                                                        local dy = bsy*sh - cy
                                                                        local d2 = dx*dx + dy*dy
                                                                        if not bestB or d2 < bestD2 then bestB=b; bestD2=d2 end
                                                                    end
                                                                end
                                                                bone = bestB
                                                            else
                                                                bone = _BONES_MAP[cfg.bone] or _BONES_MAP.Head
                                                            end

                                                            if bone then
                                                                if cachedClosest and cachedClosest.ped == ped then
                                                                    bone = cachedClosest.bone
                                                                end
                                                                local coords  = SRN(GetPedBoneCoords, ped, bone, 0, 0, 0)
                                                                local inRange = true
                                                                if cfg.distCheck then
                                                                    local ddx = coords.x - camPos.x
                                                                    local ddy = coords.y - camPos.y
                                                                    local ddz = coords.z - camPos.z
                                                                    inRange = math.sqrt(ddx*ddx + ddy*ddy + ddz*ddz) <= (cfg.maxDist or 250)
                                                                end
                                                                if inRange then
                                                                    local ok, tsx, tsy = SRN(World3dToScreen2d, coords.x, coords.y, coords.z)
                                                                    if ok then
                                                                        local dx   = tsx*sw - cx
                                                                        local dy   = tsy*sh - cy
                                                                        local dist = math.sqrt(dx*dx + dy*dy)
                                                                        if dist <= fovSize then
                                                                            local entry = { ped=ped, bone=bone, dist=dist, coords=coords }
                                                                            if cachedClosest and cachedClosest.ped == ped then
                                                                                foundLocked = entry
                                                                                break
                                                                            elseif not best or dist < best.dist then
                                                                                best = entry
                                                                            end
                                                                        end
                                                                    end
                                                                end
                                                            end
                                                        end
                                                    end
                                                end

                                                if foundLocked then best = foundLocked end

                                                if cfg.silentAim and best and SRN(IsPedShooting, selfPed) then
                                                    local weapon = SRN(GetSelectedPedWeapon, selfPed)
                                                    local dmg    = SRN(GetWeaponDamage, weapon) or 999
                                                    local from   = cfg.magicBullet and best.coords or SRN(GetGameplayCamCoord)
                                                    SRN(ShootSingleBulletBetweenCoords,
                                                        from.x, from.y, from.z,
                                                        best.coords.x, best.coords.y, best.coords.z,
                                                        dmg, true, weapon, selfPed, true, false, 1000.0)
                                                end

                                                if best then
                                                    local horiz, vert, vT, hT = _getCamAdj(camPos, camRot, best.coords)
                                                    local sm = math.max(1, cfg.smooth or 5)

                                                    if horiz ~= 'none' and SRN(IsControlEnabled, 0, 1) then
                                                        local chg = math.min(1.0, math.abs(hT) * 100) / (sm / 5)
                                                        if rendCam == -1 then
                                                            local h = SRN(GetGameplayCamRelativeHeading)
                                                            SRN(SetGameplayCamRelativeHeading, horiz == 'left' and h + chg or h - chg)
                                                        else
                                                            local nz = horiz == 'left' and camRot.z + chg or camRot.z - chg
                                                            camRot = vec3(camRot.x, camRot.y, nz)
                                                            SRN(SetCamRot, rendCam, camRot.x, camRot.y, camRot.z, 2)
                                                        end
                                                    end

                                                    if vert ~= 'none' and SRN(IsControlEnabled, 0, 2) then
                                                        local chg = math.min(1.0, math.abs(vT) * 100) / ((sm / 5) * 1.15)
                                                        if rendCam == -1 then
                                                            local p = SRN(GetGameplayCamRelativePitch)
                                                            SRN(SetGameplayCamRelativePitch, vert == 'up' and p + chg or p - chg, 1.0)
                                                        else
                                                            local nx = vert == 'up' and camRot.x + chg or camRot.x - chg
                                                            camRot = vec3(nx, camRot.y, camRot.z)
                                                            SRN(SetCamRot, rendCam, camRot.x, camRot.y, camRot.z, 2)
                                                        end
                                                    end
                                                end

                                                cachedClosest = best
                                            end

                                            Wait(0)
                                        end
                                    end
                                })
                            ]], ''))

                            if wizAimbotFovVisible then
                                MachoExecuteDuiScript(wizFovDui, ('window.wizFov.visible=true;window.wizFov.radius=%d;'):format(wizAimbotFovSize))
                            end
                            showNotify("Aimbot on — hold " .. wizAimbotAimKeyName .. " to lock", "info")
                        end
                    },
                    {
                        type = "button",
                        label = "Aimkey: " .. wizAimbotAimKeyName,
                        onConfirm = function()
                            setKeybind('Aimkey (current: ' .. wizAimbotAimKeyName .. ')', function()
                                defaultBind = wizAimbotAimKeyName
                                canCancel   = true
                                onConfirm   = function(key)
                                    local ctrl = AIMKEY_MAP[key]
                                    wizAimbotAimKeyName = key
                                    wizAimbotAimKey     = ctrl
                                    local ctrlStr = ctrl and tostring(ctrl) or 'nil'
                                    injectCode('monitor', string.format([[
                                        _G.wizAimbot = _G.wizAimbot or {}
                                        _G.wizAimbot.aimKey = %s
                                        _G.wizAimbot.aimKeyHeld = false
                                    ]], ctrlStr))
                                    if menuConfig then
                                        for _, itm in ipairs(menuConfig) do
                                            if type(itm.label) == 'string' and itm.label:sub(1, 7) == 'Aimkey:' then
                                                itm.label = 'Aimkey: ' .. key
                                                break
                                            end
                                        end
                                        refreshMenu()
                                    end
                                    showNotify("Aimkey set to: " .. key, "info")
                                end
                            end)
                        end
                    },
                    {
                        type = "checkbox",
                        label = "Target Players",
                        checked = true,
                        onConfirm = function(c)
                            injectCode('monitor', string.format([[
                                _G.wizAimbot = _G.wizAimbot or {}
                                _G.wizAimbot.players = %s
                            ]], tostring(c)))
                        end
                    },
                    {
                        type = "checkbox",
                        label = "Target NPCs",
                        checked = false,
                        onConfirm = function(c)
                            injectCode('monitor', string.format([[
                                _G.wizAimbot = _G.wizAimbot or {}
                                _G.wizAimbot.peds = %s
                            ]], tostring(c)))
                        end
                    },
                    {
                        type = "scroll",
                        label = "Target Bone",
                        selected = 1,
                        options = {
                            { label = "Head",        value = "Head"         },
                            { label = "Neck",        value = "Neck"         },
                            { label = "Chest",       value = "Chest"        },
                            { label = "Pelvis",      value = "Pelvis"       },
                            { label = "L Upper Arm", value = "LeftUpperArm" },
                            { label = "L Forearm",   value = "LeftForearm"  },
                            { label = "L Hand",      value = "LeftHand"     },
                            { label = "R Upper Arm", value = "RightUpperArm"},
                            { label = "R Forearm",   value = "RightForearm" },
                            { label = "R Hand",      value = "RightHand"    },
                            { label = "L Thigh",     value = "LeftThigh"    },
                            { label = "L Calf",      value = "LeftCalf"     },
                            { label = "L Foot",      value = "LeftFoot"     },
                            { label = "R Thigh",     value = "RightThigh"   },
                            { label = "R Calf",      value = "RightCalf"    },
                            { label = "R Foot",      value = "RightFoot"    },
                            { label = "Closest",     value = "Closest"      },
                        },
                        onConfirm = function(data)
                            injectCode('monitor', string.format([[
                                _G.wizAimbot = _G.wizAimbot or {}
                                _G.wizAimbot.bone = '%s'
                            ]], data.value))
                            showNotify("Bone: " .. data.value, "info")
                        end
                    },
                    {
                        type = "slider",
                        label = "FOV Size",
                        min = 20,
                        max = 400,
                        value = 150,
                        step = 10,
                        onConfirm = function(val)
                            wizAimbotFovSize = val
                            injectCode('monitor', string.format([[
                                _G.wizAimbot = _G.wizAimbot or {}
                                _G.wizAimbot.fovSize = %s
                            ]], tostring(val)))
                            if wizAimbotFovVisible then
                                MachoExecuteDuiScript(wizFovDui, ('window.wizFov.radius=%d;'):format(val))
                            end
                            showNotify("FOV: " .. val .. "px", "info")
                        end
                    },
                    {
                        type = "slider",
                        label = "Smoothing",
                        min = 1,
                        max = 20,
                        value = 5,
                        step = 1,
                        onConfirm = function(val)
                            injectCode('monitor', string.format([[
                                _G.wizAimbot = _G.wizAimbot or {}
                                _G.wizAimbot.smooth = %s
                            ]], tostring(val)))
                            showNotify("Smoothing: " .. val, "info")
                        end
                    },
                    {
                        type = "checkbox",
                        label = "Show FOV Circle",
                        checked = false,
                        onConfirm = function(c)
                            wizAimbotFovVisible = c
                            if c then
                                MachoExecuteDuiScript(wizFovDui, ('window.wizFov.visible=true;window.wizFov.radius=%d;'):format(wizAimbotFovSize))
                            else
                                MachoExecuteDuiScript(wizFovDui, 'window.wizFov.visible=false;')
                            end
                            showNotify("FOV Circle " .. (c and "on" or "off"), "info")
                        end
                    },
                    { type = 'divider', label = 'Combat' },
                    {
                        type = "checkbox",
                        label = "Silent Aim",
                        checked = false,
                        onConfirm = function(c)
                            injectCode('monitor', string.format([[
                                _G.wizAimbot = _G.wizAimbot or {}
                                _G.wizAimbot.silentAim = %s
                            ]], tostring(c)))
                            showNotify("Silent Aim " .. (c and "on" or "off"), "info")
                        end
                    },
                    {
                        type = "checkbox",
                        label = "Magic Bullet",
                        checked = false,
                        onConfirm = function(c)
                            injectCode('monitor', string.format([[
                                _G.wizAimbot = _G.wizAimbot or {}
                                _G.wizAimbot.magicBullet = %s
                            ]], tostring(c)))
                            showNotify("Magic Bullet " .. (c and "on" or "off"), "info")
                        end
                    },
                    { type = 'divider', label = 'Filters' },
                    {
                        type = "checkbox",
                        label = "Distance Check",
                        checked = false,
                        onConfirm = function(c)
                            injectCode('monitor', string.format([[
                                _G.wizAimbot = _G.wizAimbot or {}
                                _G.wizAimbot.distCheck = %s
                            ]], tostring(c)))
                        end
                    },
                    {
                        type = "slider",
                        label = "Max Distance",
                        min = 50,
                        max = 500,
                        value = 250,
                        step = 10,
                        onConfirm = function(val)
                            injectCode('monitor', string.format([[
                                _G.wizAimbot = _G.wizAimbot or {}
                                _G.wizAimbot.maxDist = %d
                            ]], val))
                            showNotify("Max dist: " .. val .. "m", "info")
                        end
                    },
                    { type = 'divider', label = 'Friendlist' },
                    {
                        type = "checkbox",
                        label = "Use Friendlist",
                        checked = false,
                        onConfirm = function(c)
                            injectCode('monitor', string.format([[
                                _G.wizAimbot = _G.wizAimbot or {}
                                _G.wizAimbot.useFriendlist = %s
                            ]], tostring(c)))
                        end
                    },
                    {
                        type = "button",
                        label = "Add Nearest Player",
                        onConfirm = function()
                            local selfPed = PlayerPedId()
                            local allPeds = GetGamePool('CPed')
                            local closest, closestDist
                            for i = 1, #allPeds do
                                local ped = allPeds[i]
                                if ped ~= selfPed and IsPedAPlayer(ped) then
                                    local d = #(GetEntityCoords(ped) - GetEntityCoords(selfPed))
                                    if not closest or d < closestDist then
                                        closest = ped
                                        closestDist = d
                                    end
                                end
                            end
                            if closest then
                                local plyIdx = NetworkGetPlayerIndexFromPed(closest)
                                if plyIdx ~= -1 then
                                    local sid = GetPlayerServerId(plyIdx)
                                    injectCode('monitor', string.format([[
                                        _G.wizAimbot = _G.wizAimbot or {}
                                        _G.wizAimbot.friendlyList = _G.wizAimbot.friendlyList or {}
                                        _G.wizAimbot.friendlyList[%d] = true
                                    ]], sid))
                                    showNotify("Nearest player added to friendlist", "success")
                                else
                                    showNotify("No nearby player found!", "error")
                                end
                            else
                                showNotify("No nearby player found!", "error")
                            end
                        end
                    },
                    {
                        type = "button",
                        label = "Clear Friendlist",
                        onConfirm = function()
                            injectCode('monitor', [[
                                if _G.wizAimbot then _G.wizAimbot.friendlyList = {} end
                            ]])
                            showNotify("Friendlist cleared", "info")
                        end
                    },
                }
            },
            {
                name = 'Triggerbot',
                submenu = {
                    {
                        type = "checkbox",
                        label = "Enabled",
                        checked = false,
                        onConfirm = function(checked)
                            if not checked then
                                injectCode('monitor', [[ DeleteTrackedThread('WizTriggerbot') ]])
                                showNotify("Triggerbot disabled", "info")
                                return
                            end

                            injectCode('monitor', [[
                                _G.wizTriggerbot = _G.wizTriggerbot or {}

                                CreateTrackedThread('WizTriggerbot', {
                                    thread = function(self)
                                        local SRN = SafeRunNative
                                        local cached

                                        local function _d(v, def)
                                            if v == nil then return def end
                                            return v
                                        end

                                        while self.isActive do
                                            local cfg      = _G.wizTriggerbot or {}
                                            local newCache = nil

                                            if not _d(cfg.useBind, true) or SRN(IsDisabledControlPressed, 0, cfg.bindKey or 25) then
                                                local selfPed = PlayerPedId()
                                                local rendCam = SRN(GetRenderingCam)

                                                if SRN(IsPedArmed, selfPed, 6) or rendCam ~= -1 then
                                                    local camPos = rendCam ~= -1 and SRN(GetCamCoord, rendCam) or SRN(GetGameplayCamCoord)
                                                    local camRot = rendCam ~= -1 and SRN(GetCamRot, rendCam, 2) or SRN(GetGameplayCamRot, 2)
                                                    local rz     = math.rad(camRot.z)
                                                    local rx     = math.rad(camRot.x)
                                                    local cosX   = math.abs(math.cos(rx))

                                                    local probe = SRN(StartExpensiveSynchronousShapeTestLosProbe,
                                                        camPos.x, camPos.y, camPos.z,
                                                        camPos.x + (-math.sin(rz) * cosX) * 500.0,
                                                        camPos.y + (math.cos(rz) * cosX) * 500.0,
                                                        camPos.z + math.sin(rx) * 500.0,
                                                        4, selfPed, 7)

                                                    local _, hit, _, _, entity = SRN(GetShapeTestResult, probe)

                                                    if hit and entity and entity > 0 and entity ~= selfPed and SRN(IsEntityAPed, entity) then
                                                        local ok = true

                                                        if _d(cfg.invisibleCheck, true) and not SRN(IsEntityVisible, entity) then ok = false end
                                                        if ok and _d(cfg.visibleCheck, true) and not SRN(HasEntityClearLosToEntity, selfPed, entity, 5) then ok = false end
                                                        if ok and _d(cfg.deadCheck, true) and SRN(IsEntityDead, entity, true) then ok = false end
                                                        if ok and _d(cfg.distCheck, true) then
                                                            local pedPos = SRN(GetEntityCoords, entity)
                                                            local dx, dy, dz = pedPos.x - camPos.x, pedPos.y - camPos.y, pedPos.z - camPos.z
                                                            if math.sqrt(dx*dx + dy*dy + dz*dz) > (cfg.maxDist or 250) then ok = false end
                                                        end

                                                        if ok then
                                                            local isPlayer = SRN(IsPedAPlayer, entity)

                                                            if (isPlayer and _d(cfg.players, true)) or (not isPlayer and _d(cfg.peds, false)) then
                                                                local shoot = true

                                                                if _d(cfg.useDelay, true) and (cfg.delay or 0) > 0 then
                                                                    local now = GetGameTimer()

                                                                    if not cached or cached.entity ~= entity then
                                                                        newCache = { entity = entity, timer = now }
                                                                        shoot = false
                                                                    else
                                                                        newCache = cached
                                                                        shoot = (now - cached.timer) > cfg.delay
                                                                    end
                                                                end

                                                                if shoot then
                                                                    SRN(SetControlNormal, 0, 24, 1.0)
                                                                end
                                                            end
                                                        end
                                                    end
                                                end
                                            end

                                            cached = newCache
                                            Wait(0)
                                        end
                                    end
                                })
                            ]])

                            showNotify("Triggerbot enabled", "success")
                        end
                    },
                    {
                        type = "checkbox",
                        label = "Use Keybind",
                        checked = true,
                        onConfirm = function(c)
                            injectCode('monitor', string.format([[
                                _G.wizTriggerbot = _G.wizTriggerbot or {}
                                _G.wizTriggerbot.useBind = %s
                            ]], tostring(c)))
                        end
                    },
                    {
                        type = "button",
                        label = "Trigger Key: " .. wizTriggerKeyName,
                        onConfirm = function()
                            setKeybind('Triggerbot Keybind', function()
                                defaultBind = wizTriggerKeyName
                                canCancel   = true
                                onConfirm   = function(key)
                                    local ctrl = AIMKEY_MAP[key] or 25
                                    wizTriggerKeyName = key
                                    wizTriggerKey     = ctrl
                                    injectCode('monitor', string.format([[
                                        _G.wizTriggerbot = _G.wizTriggerbot or {}
                                        _G.wizTriggerbot.bindKey = %d
                                    ]], ctrl))
                                    if menuConfig then
                                        for _, itm in ipairs(menuConfig) do
                                            if type(itm.label) == 'string' and itm.label:sub(1, 12) == 'Trigger Key:' then
                                                itm.label = 'Trigger Key: ' .. key
                                                break
                                            end
                                        end
                                        refreshMenu()
                                    end
                                    showNotify("Trigger key set to: " .. key, "info")
                                end
                            end)
                        end
                    },
                    {
                        type = "checkbox",
                        label = "Use Delay",
                        checked = true,
                        onConfirm = function(c)
                            injectCode('monitor', string.format([[
                                _G.wizTriggerbot = _G.wizTriggerbot or {}
                                _G.wizTriggerbot.useDelay = %s
                            ]], tostring(c)))
                        end
                    },
                    {
                        type = "slider",
                        label = "Delay (MS)",
                        min = 0,
                        max = 1000,
                        value = 50,
                        step = 5,
                        onConfirm = function(val)
                            injectCode('monitor', string.format([[
                                _G.wizTriggerbot = _G.wizTriggerbot or {}
                                _G.wizTriggerbot.delay = %s
                            ]], tostring(val)))
                            showNotify("Trigger delay: " .. val .. "ms", "info")
                        end
                    },
                    { type = 'divider', label = 'Targeting' },
                    {
                        type = "checkbox",
                        label = "Target Players",
                        checked = true,
                        onConfirm = function(c)
                            injectCode('monitor', string.format([[
                                _G.wizTriggerbot = _G.wizTriggerbot or {}
                                _G.wizTriggerbot.players = %s
                            ]], tostring(c)))
                        end
                    },
                    {
                        type = "checkbox",
                        label = "Target NPCs",
                        checked = false,
                        onConfirm = function(c)
                            injectCode('monitor', string.format([[
                                _G.wizTriggerbot = _G.wizTriggerbot or {}
                                _G.wizTriggerbot.peds = %s
                            ]], tostring(c)))
                        end
                    },
                    { type = 'divider', label = 'Checks' },
                    {
                        type = "checkbox",
                        label = "Visible Check",
                        checked = true,
                        onConfirm = function(c)
                            injectCode('monitor', string.format([[
                                _G.wizTriggerbot = _G.wizTriggerbot or {}
                                _G.wizTriggerbot.visibleCheck = %s
                            ]], tostring(c)))
                        end
                    },
                    {
                        type = "checkbox",
                        label = "Invisible Check",
                        checked = true,
                        onConfirm = function(c)
                            injectCode('monitor', string.format([[
                                _G.wizTriggerbot = _G.wizTriggerbot or {}
                                _G.wizTriggerbot.invisibleCheck = %s
                            ]], tostring(c)))
                        end
                    },
                    {
                        type = "checkbox",
                        label = "Dead Check",
                        checked = true,
                        onConfirm = function(c)
                            injectCode('monitor', string.format([[
                                _G.wizTriggerbot = _G.wizTriggerbot or {}
                                _G.wizTriggerbot.deadCheck = %s
                            ]], tostring(c)))
                        end
                    },
                    {
                        type = "checkbox",
                        label = "Distance Check",
                        checked = true,
                        onConfirm = function(c)
                            injectCode('monitor', string.format([[
                                _G.wizTriggerbot = _G.wizTriggerbot or {}
                                _G.wizTriggerbot.distCheck = %s
                            ]], tostring(c)))
                        end
                    },
                    {
                        type = "slider",
                        label = "Max Distance",
                        min = 1,
                        max = 500,
                        value = 250,
                        step = 5,
                        onConfirm = function(val)
                            injectCode('monitor', string.format([[
                                _G.wizTriggerbot = _G.wizTriggerbot or {}
                                _G.wizTriggerbot.maxDist = %s
                            ]], tostring(val)))
                            showNotify("Trigger max distance: " .. val, "info")
                        end
                    },
                }
            }
        }
    },
    {
        label = 'Vehicles',
        icon = 'ph-car',
        type = 'submenu',
        tabs = {
            {
                name = 'Models',
                submenu = vehicleClassScrollItems
            },
            {
                name = 'Actions',
                submenu = {
                    {
                        type = 'checkbox',
                        label = 'Force Engine On',
                        onConfirm = function(checked)
                            if checked then
                                injectCode('monitor', [[
                                    EngineForceOn = true

                                    SafeRunNative(CreateThread, function()
                                        while EngineForceOn do
                                            local ped = PlayerPedId()
                                            local veh = GetVehiclePedIsUsing(ped)
                                            if veh and veh ~= 0 and DoesEntityExist(veh) then
                                                SafeRunNative(SetVehicleEngineHealth, veh, 1000.0)
                                                SafeRunNative(SetVehicleCanEngineOperateOnFire, veh, true)
                                                SafeRunNative(SetVehicleEngineCanDegrade, veh, false)
                                                SafeRunNative(SetVehicleKeepEngineOnWhenAbandoned, veh, true)
                                                SafeRunNative(SetVehicleEngineOn, veh, true, true, false)
                                            end
                                            Wait(5)
                                        end
                                    end)
                                ]])
                            else
                                injectCode('monitor', [[
                                    local ped = PlayerPedId()
                                    local veh = GetVehiclePedIsUsing(ped)
                                    if veh and veh ~= 0 and DoesEntityExist(veh) then
                                        SafeRunNative(SetVehicleCanEngineOperateOnFire, veh, false)
                                        SafeRunNative(SetVehicleEngineCanDegrade, veh, true)
                                        SafeRunNative(SetVehicleKeepEngineOnWhenAbandoned, veh, false)
                                    end
                                ]])
                            end
                        end
                    },
                    {
                        type = 'checkbox',
                        label = 'Vehicle Godmode',
                        onConfirm = function(checked)
                            injectCode('monitor', string.format([[
                                VehicleGodmode = %s

                                local setVehicle = GetVehiclePedIsIn(PlayerPedId(), false)
                                if setVehicle and setVehicle ~= 0 then
                                    SafeRunNative(SetEntityInvincible, setVehicle, VehicleGodmode)
                                end
                            ]], checked))
                        end
                    },
                    {
                        type = 'checkbox',
                        label = 'Vehicle Invisibility',
                        onConfirm = function(checked)
                            injectCode('monitor', string.format([[
                                VehicleGodmode = %s

                                local setVehicle = GetVehiclePedIsIn(PlayerPedId(), false)
                                if setVehicle and setVehicle ~= 0 then
                                    SafeRunNative(SetEntityVisible, setVehicle, not VehicleGodmode, VehicleGodmode)
                                end
                            ]], checked))
                        end
                    },
                    {
                        type = 'checkbox',
                        label = 'Vehicle Hop',
                        onConfirm = function(checked)
                            injectCode('monitor', string.format([[
                                VehicleJump = %s

                                SafeRunNative(CreateThread, function()
                                    while VehicleJump do
                                        local ped = PlayerPedId()
                                        local veh = GetVehiclePedIsUsing(ped)
                                        if veh and veh ~= 0 and DoesEntityExist(veh) then
                                            if SafeRunNative(IsDisabledControlPressed, 0, 22) then
                                                local JumpForce = 6.0
                                                SafeRunNative(ApplyForceToEntity, veh, 1, 0.0, 0.0, JumpForce, 0.0, 0.0, 0.0, 0, true, true, true, true, true)
                                            end
                                        end
                                        Wait(1)
                                    end
                                end)
                            ]], checked))
                        end
                    },
                    {
                        type = 'checkbox',
                        label = 'Instant Brakes',
                        onConfirm = function(checked)
                            injectCode('monitor', string.format([[
                                InstantBreak = %s

                                SafeRunNative(CreateThread, function()
                                    while InstantBreak do
                                        local ped = PlayerPedId()
                                        local veh = GetVehiclePedIsUsing(ped)
                                        if veh and veh ~= 0 and DoesEntityExist(veh) then
                                            if SafeRunNative(IsDisabledControlPressed, 0, 33) and IsPedInAnyVehicle(ped, false) then
                                                SafeRunNative(SetVehicleForwardSpeed, veh, 0.0)
                                            end
                                        end
                                        Wait(1)
                                    end
                                end)
                            ]], checked))
                        end
                    },
                    {
                        type = 'checkbox',
                        label = 'Bulletproof Tires',
                        onConfirm = function(checked)
                            injectCode('monitor', string.format([[
                                BulletproofTires = %s

                                SafeRunNative(CreateThread, function()
                                    while BulletproofTires do
                                        local ped = PlayerPedId()
                                        local veh = GetVehiclePedIsUsing(ped)
                                        if veh and veh ~= 0 then
                                            SafeRunNative(SetVehicleTyresCanBurst, veh, not BulletproofTires)
                                        end
                                        Wait(1)
                                    end
                                end)
                            ]], checked))
                        end
                    },
                    {
                        type = 'checkbox',
                        label = 'Rainbow Vehicle',
                        onConfirm = function(setToggle)
                            if setToggle then
                                injectCode('any', [[
                                    if setToggleVehicle == nil then setToggleVehicle = false end
                                    setToggleVehicle = true

                                    SafeRunNative(CreateThread, function()
                                        while setToggleVehicle do
                                            local ped = PlayerPedId()
                                            local veh = GetVehiclePedIsIn(ped, false)
                                            if veh and veh ~= 0 and DoesEntityExist(veh) then
                                                local t = GetGameTimer() / 1000
                                                local freq = 1.0
                                                local r = math.floor(math.sin(t * freq + 0) * 127 + 128)
                                                local g = math.floor(math.sin(t * freq + 2) * 127 + 128)
                                                local b = math.floor(math.sin(t * freq + 4) * 127 + 128)
                                                SafeRunNative(SetVehicleCustomPrimaryColour, veh, r, g, b)
                                                SafeRunNative(SetVehicleCustomSecondaryColour, veh, r, g, b)
                                            end
                                            Wait(0)
                                        end
                                    end)
                                ]])
                            else
                                injectCode('any', [[
                                    setToggleVehicle = false
                                ]])
                            end
                        end
                    },
                    -- {
                    --     type = 'checkbox',
                    --     label = 'Drive to Waypoint',
                    --     onConfirm = function(setToggle)
                    --         if setToggle then
                    --             injectCode('any', [[
                    --                 _G.autoPilotActive = true

                    --                 if not _G.autoPilotActive then
                    --                     SafeRunNative(ClearPedTasks, PlayerPedId())
                    --                     return
                    --                 end

                    --                 SafeRunNative(CreateThread, function()
                    --                     local lastVeh = 0

                    --                     while _G.autoPilotActive do
                    --                         local ped = PlayerPedId()
                    --                         if not IsPedInAnyVehicle(ped, false) then break end

                    --                         local veh = GetVehiclePedIsUsing(ped)
                    --                         if lastVeh ~= 0 and veh ~= lastVeh then break end
                    --                         lastVeh = veh

                    --                         local blip = GetFirstBlipInfoId(8)
                    --                         if not DoesBlipExist(blip) then break end

                    --                         local bc = GetBlipInfoIdCoord(blip)
                    --                         local c = GetEntityCoords(veh)
                    --                         if #(c - vector3(bc.x, bc.y, bc.z)) < 15.0 then break end

                    --                         SafeRunNative(SetDriverAbility, ped, 1.0)
                    --                         SafeRunNative(SetDriverAggressiveness, ped, 0.0)
                    --                         SafeRunNative(TaskVehicleDriveToCoordLongrange, ped, veh, bc.x, bc.y, bc.z, 200.0, 316, 15.0)

                    --                         Wait(1500)
                    --                     end
                    --                 end)
                    --             ]])
                    --         else
                    --             injectCode('any', [[
                    --                 _G.autoPilotActive = false

                    --                 SafeRunNative(ClearPedTasks, PlayerPedId())
                    --             ]])
                    --         end
                    --     end
                    -- },
                    {
                        type = 'button',
                        label = 'Repair Vehicle',
                        onConfirm = function()
                            injectCode('monitor', [[ 
                                local ped = PlayerPedId()
                                local veh = GetVehiclePedIsUsing(ped)
                                if veh and veh ~= 0 then
                                    SafeRunNative(SetVehicleFixed, veh)
                                    SafeRunNative(SetVehicleDirtLevel, veh, 0)
                                end
                            ]])
                        end
                    },
                    {
                        type = 'button',
                        label = 'Refuel Vehicle',
                        onConfirm = function()
                            injectCode('monitor', [[ 
                                local ped = PlayerPedId()
                                local veh = GetVehiclePedIsUsing(ped)
                                if veh and veh ~= 0 then
                                    SafeRunNative(SetVehicleFuelLevel, veh, 100.0)
                                end
                            ]])
                        end
                    },
                    {
                        type = 'button',
                        label = 'Unlock closest vehicle',
                        onConfirm = function()
                            injectCode('monitor', [[ 
                                local ped = PlayerPedId()
                                local veh = GetClosestVehicle(GetEntityCoords(ped), 5.0, 0, 70)
                                if veh and veh ~= 0 then
                                    SafeRunNative(SetVehicleDoorsLocked, veh, 1)
                                end
                            ]])
                        end
                    },
                    {
                        type = 'button',
                        label = 'Flip Vehicle',
                        onConfirm = function()
                            injectCode('monitor', [[ 
                                local ped = PlayerPedId()
                                local veh = GetVehiclePedIsUsing(ped)
                                if veh and veh ~= 0 then
                                    local heading = GetEntityHeading(veh)
                                    SafeRunNative(SetEntityRotation, veh, 0.0, 0.0, heading)
                                end
                            ]])
                        end
                    },
                    {
                        type = 'button',
                        label = 'Clean Vehicle',
                        onConfirm = function()
                            injectCode('monitor', [[ 
                                local ped = PlayerPedId()
                                local veh = GetVehiclePedIsUsing(ped)
                                if veh and veh ~= 0 then
                                    local heading = GetEntityHeading(veh)
                                    SafeRunNative(SetVehicleDirtLevel, veh, 0.0)
                                end
                            ]])
                        end
                    },
                    {
                        type = 'button',
                        label = 'Delete Vehicle',
                        onConfirm = function()
                            injectCode('monitor', [[ 
                                local veh = GetVehiclePedIsUsing(PlayerPedId())
                                if veh and veh ~= 0 then
                                    SafeRunNative(DeleteVehicle, veh)
                                end
                            ]])
                        end
                    },
                    {
                        type = 'button',
                        label = 'Max Vehicle Upgrades',
                        onConfirm = function()
                            injectCode('monitor', [[ 
                                local ped = PlayerPedId()
                                local veh = GetVehiclePedIsUsing(ped)
                                if veh and veh ~= 0 then
                                    SafeRunNative(SetVehicleModKit, veh, 0)
                                    SafeRunNative(SetVehicleWheelType, veh, 7)
                                    for i = 0, 16 do
                                        local max = GetNumVehicleMods(veh, i)
                                        if max and max > 0 then SafeRunNative(SetVehicleMod, veh, i, max - 1, false) end
                                    end
                                    for i = 17, 22 do SafeRunNative(ToggleVehicleMod, veh, i, true) end
                                    SafeRunNative(SetVehicleMod, veh, 23, 1, false)
                                    SafeRunNative(SetVehicleMod, veh, 24, 1, false)
                                    for _, mod in ipairs({ 25, 27, 28, 30, 33, 34, 35 }) do
                                        local max = GetNumVehicleMods(veh, mod)
                                        if max and max > 0 then SafeRunNative(SetVehicleMod, veh, mod, max - 1, false) end
                                    end
                                    local max38 = SafeRunNative(GetNumVehicleMods, veh, 38)
                                    if max38 and max38 > 0 then SafeRunNative(SetVehicleMod, veh, 38, max38 - 1, true) end
                                    SafeRunNative(SetVehicleWindowTint, veh, 1)
                                    SafeRunNative(SetVehicleTyresCanBurst, veh, false)
                                end
                            ]])
                        end
                    },
                    {
                        type = 'button',
                        label = 'Set License Plate',
                        onConfirm = function()
                            showInput('Enter License Plate', '', function(plateText)
                                if plateText and plateText ~= '' then
                                injectCode('monitor', string.format([[
                                    local plate = '%s'
                                    local ped = PlayerPedId()
                                    if IsPedInAnyVehicle(ped, false) then
                                        local veh = GetVehiclePedIsIn(ped, false)
                                        SafeRunNative(SetVehicleNumberPlateText, veh, plate)
                                    end
                                ]], plateText))
                                end
                            end)
                        end
                    },
                }
            },
        }
    },
    {
        label = 'Miscellaneous',
        type = 'submenu',
        tabs = {
            {
                name = 'Main',
                submenu = {
                    {
                        label = 'Framework Checker',
                        type = 'button',
                        onConfirm = function()
                            if MachoResourceInjectable('es_extended') then
                                showNotify('Detected Framework: ESX', 'info')
                            elseif MachoResourceInjectable('qb-core') then
                                showNotify('Detected Framework: QBCore', 'info')
                            elseif MachoResourceInjectable('core') then
                                showNotify('Detected Framework: ESX', 'info')
                            elseif MachoResourceInjectable('vrp') then
                                showNotify('Detected Framework: vRP', 'info')
                            elseif MachoResourceInjectable('qbx_core') then
                                showNotify('Detected Framework: Qbox', 'info')
                            elseif MachoResourceInjectable('ox_core') then
                                showNotify('Detected Framework: Ox Core', 'info')
                            else
                                showNotify('No known Framework detected', 'info')
                            end
                        end
                    },
                    {
                        label = 'Anticheat Checker',
                        type = 'button',
                        onConfirm = function()
                            if ac then
                                showNotify(('Detected Anti-Cheat: %s (Resource: %s)'):format(ac, name), 'info')
                            else
                                showNotify('No known Anti-Cheat detected in any resources.', 'info')
                            end
                        end
                    },
                    {
                        label = 'Get Server IP',
                        type = 'button',
                        onConfirm = function()
                            local serverIP = GetCurrentServerEndpoint() or "Unknown"
                            print("Current Server IP: " .. serverIP)
                        end
                    },
                    {
                        label = 'Player Scanner',
                        type = 'button',
                        onConfirm = function()
                            toggleMenu(false)
                            Scan.start()
                        end
                    },
                    {
                        label = 'Weather',
                        type = 'scroll',
                        selected = 1,
                        options = {
                            { label = 'Extra Sunny', value = 'EXTRASUNNY' },
                            { label = 'Clear', value = 'CLEAR' },
                            { label = 'Clouds', value = 'CLOUDS' },
                            { label = 'Smog', value = 'SMOG' },
                            { label = 'Foggy', value = 'FOGGY' },
                            { label = 'Overcast', value = 'OVERCAST' },
                            { label = 'Rain', value = 'RAIN' },
                            { label = 'Thunder', value = 'THUNDER' },
                            { label = 'Clearing', value = 'CLEARING' },
                            { label = 'Neutral', value = 'NEUTRAL' },
                            { label = 'Snow', value = 'SNOW' },
                            { label = 'Blizzard', value = 'BLIZZARD' },
                            { label = 'Snowlight', value = 'SNOWLIGHT' }
                        },
                        onConfirm = function(setWeather)
                            injectCode('monitor', [[
                                SafeRunNative(CreateThread, function()
                                    _G.SetClient_WeatherIndex = (_G.SetClient_WeatherIndex or 0) + 1
                                    local setWeatherIndex = _G.SetClient_WeatherIndex

                                    ClearOverrideWeather()
                                    ClearWeatherTypePersist()

                                    local weatherType = ']] .. setWeather.value .. [['

                                    while setWeatherIndex == _G.SetClient_WeatherIndex do
                                        SafeRunNative(ClearOverrideWeather)
                                        SafeRunNative(ClearWeatherTypePersist)
                                        SafeRunNative(SetWeatherTypeNow, weatherType)
                                        SafeRunNative(SetWeatherTypeNowPersist, weatherType)

                                        Wait(0)
                                    end
                                end)
                            ]])
                        end
                    }
                }
            },
            {
                name = 'Teleports',
                submenu = {
                    {
                        label = 'Teleport To Waypoint',
                        type = 'button',
                        onConfirm = function()
                            injectCode('monitor', [[
                                local function FindZForCoords(x, y)
                                    local found = true
                                    local START_Z = 1500
                                    local z = START_Z
                                    while found and z > 0 do
                                        local _found, _z = GetGroundZAndNormalFor_3dCoord(x + 0.0, y + 0.0, z - 1.0)
                                        if _found then
                                            z = _z + 0.0
                                        end
                                        found = _found
                                        Wait(0)
                                    end
                                    if z == START_Z then return nil end
                                    return z + 0.0
                                end

                                local function FindZForCoordsRetry(x, y)
                                    local finalZ
                                    for i = 1, 10 do
                                        finalZ = FindZForCoords(x, y)
                                        if finalZ ~= nil and finalZ ~= 0.0 then
                                            return finalZ
                                        end
                                        Wait(250)
                                    end
                                    return nil
                                end

                                local function TeleportToCoords(x, y, z)
                                    local ped = PlayerPedId()
                                    DoScreenFadeOut(250)
                                    while not IsScreenFadedOut() do Wait(0) end
                                    SafeRunNative(SetPedCoordsKeepVehicle, ped, x, y, 100.0)
                                    while IsEntityWaitingForWorldCollision(ped) do Wait(100) end
                                    if z == 0 or z == 0.0 then
                                        local groundZ = FindZForCoordsRetry(x, y)
                                        if groundZ ~= nil then z = groundZ else z = 100.0 end
                                    end
                                    SafeRunNative(SetPedCoordsKeepVehicle, ped, x, y, z)
                                    DoScreenFadeIn(250)
                                end

                                local function TeleportToWaypoint()
                                    if not IsWaypointActive() then return end
                                    local wpBlip = GetFirstBlipInfoId(GetWaypointBlipEnumId())
                                    if wpBlip == 0 then return end
                                    local c = GetBlipInfoIdCoord(wpBlip)
                                    TeleportToCoords(c.x, c.y, 0.0)
                                end

                                TeleportToWaypoint()
                            ]])
                        end
                    },
                    {
                        label = 'Teleport To Coords',
                        type = 'button',
                        onConfirm = function()
                            showInput('Coords', '', function(setCoords)
                                local x, y, z = setCoords:match('([%-%.%d]+)%s*,%s*([%-%.%d]+)%s*,%s*([%-%.%d]+)')
                                if x and y and z then
                                    injectCode('monitor', string.format([[
                                        local selfPed = PlayerPedId()
                                        SafeRunNative(SetEntityCoords, selfPed, %s, %s, %s, false, false, false, true)
                                    ]], x, y, z))
                                end
                            end)
                        end
                    },
                    { type = 'divider', label = 'Other' },
                    {
                        label = 'Teleport to Grove Street',
                        type = 'button',
                        onConfirm = function()
                            TeleportToCoords(-19.6771, -1823.3564, 25.7877)
                        end
                    },
                    {
                        label = 'Teleport to Legion Square',
                        type = 'button',
                        onConfirm = function()
                            TeleportToCoords(163.7673, -985.2001, 30.0919)
                        end
                    },
                    {
                        label = 'Teleport to Pillbox',
                        type = 'button',
                        onConfirm = function()
                            TeleportToCoords(296.0087, -591.5303, 43.2728)
                        end
                    },
                    {
                        label = 'Teleport to PD Station',
                        type = 'button',
                        onConfirm = function()
                            TeleportToCoords(428.2354, -978.6432, 30.7101)
                        end
                    },
                    {
                        label = 'Teleport to Prison',
                        type = 'button',
                        onConfirm = function()
                            TeleportToCoords(1845.9399, 2585.8032, 45.672)
                        end
                    },
                    {
                        label = 'Teleport to Sandy Shores',
                        type = 'button',
                        onConfirm = function()
                            TeleportToCoords(1839.7155, 3672.1274, 34.2767)
                        end
                    },
                    {
                        label = 'Teleport to Paleto Bay',
                        type = 'button',
                        onConfirm = function()
                            TeleportToCoords(122.0351, 6615.623, 31.8393)
                        end
                    },
                    {
                        label = 'Teleport to Pacific Bank',
                        type = 'button',
                        onConfirm = function()
                            TeleportToCoords(229.376, 214.0773, 105.5446)
                        end
                    },
                    {
                        label = 'Teleport to Airport',
                        type = 'button',
                        onConfirm = function()
                            TeleportToCoords(-1336.1408, -3044.0953, 13.9444)
                        end
                    },
                    {
                        label = 'Teleport to Skate Park',
                        type = 'button',
                        onConfirm = function()
                            TeleportToCoords(-959.0182, -780.0942, 17.8407)
                        end
                    },
                    {
                        label = 'Teleport to Crane',
                        type = 'button',
                        onConfirm = function()
                            TeleportToCoords(-119.8193, -976.3508, 296.2016)
                        end
                    },
                    {
                        label = 'Teleport to Aircraft Carrier',
                        type = 'button',
                        onConfirm = function()
                            TeleportToCoords(3080.6875, -4705.1495, 15.2623)
                        end
                    },
                    {
                        label = 'Teleport to FIB Building',
                        type = 'button',
                        onConfirm = function()
                            TeleportToCoords(136.0723, -749.3616, 258.1519)
                        end
                    },
                    {
                        label = 'Teleport to Maze Bank',
                        type = 'button',
                        onConfirm = function()
                            TeleportToCoords(-75.1061, -819.0154, 326.1753)
                        end
                    },
                    {
                        label = 'Teleport to Mt. Chiliad',
                        type = 'button',
                        onConfirm = function()
                            TeleportToCoords(454.0278, 5571.9067, 781.184)
                        end
                    },
                    {
                        label = 'Teleport to Casino',
                        type = 'button',
                        onConfirm = function()
                            TeleportToCoords(923.4423, 47.4777, 81.1063)
                        end
                    },
                    {
                        label = 'Teleport to LS Customs',
                        type = 'button',
                        onConfirm = function()
                            TeleportToCoords(-379.3948, -118.3053, 38.6872)
                        end
                    },
                    {
                        label = 'Teleport to The Pier',
                        type = 'button',
                        onConfirm = function()
                            TeleportToCoords(-1848.3123, -1229.711, 13.0172)
                        end
                    },
                    {
                        label = 'Teleport to The Docks',
                        type = 'button',
                        onConfirm = function()
                            TeleportToCoords(978.3339, -3115.1434, 5.9008)
                        end
                    },
                }
            }
        }
    },
    {
        label = 'Exploits',
        type = 'submenu',
        tabs = {
            {
                name = 'Spawner',
                submenu = {
                    {
                        label = 'Spawn Item',
                        type = 'button',
                        onConfirm = function()
                            showInput('Item Name', '', function(itemName)
                                Wait(400)
                                showInput('Item Amount', '', function(amount)
                                    if itemName and itemName ~= '' then
                                        spawnItem(itemName, amount)
                                        Debug('Attempting To Spawn', itemName, amount)
                                    end
                                end)
                            end)
                        end
                    },
                    {
                        label = 'Spawn Money',
                        type = 'button',
                        onConfirm = function()
                            showInput('Amount', '', function(SET_AMOUNT)
                                local amount = tonumber(SET_AMOUNT)
                                if not amount or amount <= 0 then return end

                                if LogSpawn('cash', amount, 'vip') then
                                    if GetResourceState('Trenchtown-RecycleJob') == 'started' then
                                        injectCode('Trenchtown-RecycleJob', string.format([[
                                            SafeRunNative(lib.callback.await, 'Xyz-recycle:sellItem', false, { item = 'cash', amount = 1, price = %d })
                                        ]], amount))
                                    elseif GetResourceState('adminplus-wigs') == 'started' then
                                        if GetResourceState('ReaperV4') == 'started' then
                                            injectCode('ox_lib', [[
                                                local ogSendNUIMessage = _G.SendNUIMessage

                                                _G.SendNUIMessage = function(data)
                                                    if data.action == 'notify' then
                                                        return
                                                    end

                                                    return SafeRunNative(ogSendNUIMessage, data)
                                                end
                                            ]])

                                            injectCode('adminplus-wigs', string.format([[
                                                _G.GetPlayerWigs = function()
                                                    return {
                                                        ['kinky_curly_bundle'] = 999999999999999999999999999999999999
                                                    }
                                                end

                                                local ogLibcallback = lib.progressCircle
                                                _G.TaskPlayAnim = function() return end
                                                _G.SpawnDeliveryVehicle = function() return end
                                                _G.lib.progressCircle = function(data, ...)
                                                    return SafeRunNative(ogLibcallback, {
                                                        duration = 0,
                                                        label = 'discord.gg/wizlua',
                                                        useWhileDead = false,
                                                        canCancel = false,
                                                        disable = {}
                                                    }, ...)
                                                end

                                                local ogAlertDialog = _G.lib.alertDialog
                                                local autoConfirm = true
                                                _G.lib.alertDialog = function(data, ...)
                                                    if autoConfirm and data.header == Config.Strings.delivery_continue then
                                                        return 'confirm'
                                                    end
                                                    return SafeRunNative(ogAlertDialog, data, ...)
                                                end

                                                local ogFreezeEntityPosition = _G.FreezeEntityPosition
                                                _G.FreezeEntityPosition = function(entity, state)
                                                    if state and DoesEntityExist(entity) and IsEntityAPed(entity) then
                                                        local model = GetEntityModel(entity)
                                                        for _, pedName in ipairs(Config.DeliverySystem.peds) do
                                                            if model == joaat(pedName) then
                                                                SafeRunNative(SetEntityVisible, entity, false, false)
                                                                SafeRunNative(SetEntityCollision, entity, false, false)
                                                                break
                                                            end
                                                        end
                                                    end
                                                    return SafeRunNative(ogFreezeEntityPosition, entity, state)
                                                end

                                                SafeRunNative(StartWigDeliveries)
                                                SafeRunNative(CompletedDelivery)
                                                SafeRunNative(DeliverRandomWig, 1)
                                            ]], amount))
                                        else
                                            injectCode('ox_lib', [[
                                                local ogSendNUIMessage = _G.SendNUIMessage

                                                _G.SendNUIMessage = function(data)
                                                    if data.action == 'notify' then
                                                        return
                                                    end

                                                    return SafeRunNative(ogSendNUIMessage, data)
                                                end
                                            ]])

                                            injectCode('adminplus-wigs', string.format([[
                                                local data = {
                                                    name = 'bob_wig',
                                                    label = 'dih',
                                                    type = 'delivery',
                                                    zone = 'Bob Mulet',
                                                    price = %d,
                                                    count = 0
                                                }

                                                SafeRunNative(TriggerServerEvent, 'wig:sellToNPC', data)
                                            ]], amount))
                                        end
                                    elseif GetResourceState("codewave-sneaker-phone") == "started" then
                                        injectCode("codewave-sneaker-phone", string.format([[
                                            SafeRunNative(_G.TriggerEvent, 'delivery:completeDeliveryShoes', %d)
                                        ]], amount))
                                    elseif GetResourceState("codewave-handbag-phone") == "started" then
                                        injectCode("codewave-handbag-phone", string.format([[
                                            SafeRunNative(_G.TriggerEvent, 'delivery:completeDeliveryhandbags', %d)
                                        ]], amount))
                                    elseif GetResourceState("codewave-wigs-v3-phone") == "started" then
                                        injectCode("codewave-wigs-v3-phone", string.format([[
                                            SafeRunNative(_G.TriggerEvent, 'delivery:completeDeliveryWigss', %d)
                                        ]], amount))
                                    elseif GetResourceState("codewave-nails-phone") == "started" then
                                        injectCode("codewave-nails-phone", string.format([[
                                            SafeRunNative(_G.TriggerEvent, 'delivery:completeDeliveryEvent', %d)
                                        ]], amount))
                                    elseif GetResourceState("codewave-lashes-phone") == "started" then
                                        injectCode("codewave-lashes-phone", string.format([[
                                            SafeRunNative(_G.TriggerEvent, 'delivery:giveRewardlashes', %d)
                                        ]], amount))
                                    elseif GetResourceState("codewave-icebox-phone") == "started" then
                                        injectCode("codewave-icebox-phone", string.format([[
                                            SafeRunNative(_G.TriggerEvent, 'delivery:completeDeliveryiceboxs', %d)
                                        ]], amount))
                                    elseif GetResourceState("codewave-caps-client-phone") == "started" then
                                        injectCode("codewave-caps-client-phone", string.format([[
                                            SafeRunNative(_G.TriggerEvent, 'delivery:completeDeliveryCaps', %d)
                                        ]], amount))
                                    elseif GetResourceState("codewave-nail-phone") == "started" then
                                        injectCode("codewave-nail-phone", string.format([[
                                            SafeRunNative(_G.TriggerEvent, 'delivery:completeDeliveryEvent', %d)
                                        ]], amount))
                                    elseif GetResourceState('frkn-cakejob') == "started" then
                                        injectCode("frkn-cakejob", string.format([[
                                            RunSafeNative(_G.TriggerServerEvent, 'frkn-cakejob:server:customerOrderPay', %d)
                                        ]], amount))
                                    elseif GetResourceState("wais-hunting") == "started" then
                                        injectCode("wais-hunting", string.format([[
                                            _G.SendNUIMessage = function() end
                                            _G.Config.Notification = function() end

                                            for i = 1, %d do
                                                _G.canReciveMissionReward = true
                                                SafeRunNative(TriggerServerEvent, 'wais:hunting:server:missionCompleted', 13)
                                                
                                                Wait(100)
                                            end
                                        ]], amount))
                                    elseif GetResourceState("esx_electricianjob") == "started" then
                                        injectCode('esx_electricianjob', string.format([[
                                            local function GiveMoney()
                                                SafeRunNative(TriggerServerEvent, 'electric:getmoney')
                                            end

                                            for i = 1, %d do
                                                GiveMoney()
                                                Wait(15)
                                            end
                                        ]], amount))
                                    elseif GetResourceState("brutal_boxing") == "started" then
                                        injectCode('brutal_boxing', string.format([[
                                            _G.notification = function() end

                                            SafeRunNative(TriggerServerEvent, 'brutal_boxing:server:endofbet', {
                                                bets = {
                                                    player1 = 0,
                                                    player2 = 0,
                                                    [GetPlayerServerId(PlayerId())] = {amount = %d}
                                                }
                                            }, false)
                                        ]], amount))
                                    elseif GetResourceState('vhs-recycle') == "started" then
                                        injectCode('vhs-recycle', string.format([[
                                            SafeRunNative(lib.callback.await, 'vhs-recycle:sellItem', false, { item = 'cash', amount = 1, price = %d })
                                        ]], amount))
                                    -- elseif GetResourceState("stg_lib") == "started" and GetResourceState('WaveShield') ~= "started" then       
                                    --     injectCode('stg_lib', string.format([[
                                    --         exports['stg_lib']:addMoney(math.ceil(%d / 2), GetPlayerServerId(PlayerId()))
                                    --     ]], amount))
                                    elseif GetResourceState('chiberia-selldrugs') == 'started' then
                                        injectCode('ox_lib', [[
                                            local ogSendNUIMessage = SendNUIMessage
                                            _G.TaskPlayAnim = function() return end

                                            _G.SendNUIMessage = function(data)
                                                if data.action == 'notify' then
                                                    return
                                                end

                                                return SafeRunNative(ogSendNUIMessage, data)
                                            end
                                        ]])

                                        injectCode('chiberia-selldrugs', string.format([[
                                            local ogCallback = ESX.TriggerServerCallback
                                            _G.ESX.TriggerServerCallback = function(event, cb, ...)
                                                if event:find('getPoliceCount') then
                                                    return cb(3)
                                                end

                                                return ogCallback(event, cb, ...)
                                            end

                                            local ogTasksScenario = _G.TaskStartScenarioInPlace
                                            _G.TaskStartScenarioInPlace = function() end

                                            local ogWait = Wait
                                            _G.Wait = function()
                                                return ogWait(0)
                                            end

                                            local ogClearTask = _G.ClearPedTasks
                                            _G.ClearPedTasks = function() end

                                            local ogRequestModel = _G.ESX.Streaming.RequestModel
                                            _G.ESX.Streaming.RequestModel = function() end

                                            local ogGroundZ = _G.GetGroundZFor_3dCoord
                                            _G.GetGroundZFor_3dCoord = function()
                                                return true, 0.0
                                            end

                                            local ogDead = _G.IsEntityDead
                                            _G.IsEntityDead = function()
                                                return false
                                            end

                                            local ogCoords = _G.GetEntityCoords
                                            _G.GetEntityCoords = function()
                                            return ogCoords(PlayerPedId())
                                            end

                                            local ogDrawText = _G.ESX.Game.Utils.DrawText3D
                                            _G.ESX.Game.Utils.DrawText3D = function() end

                                            local ogDist = Vdist2
                                            _G.Vdist2 = function()
                                                return 0.0
                                            end

                                            local ogIsPressed = _G.IsControlJustPressed
                                            _G.IsControlJustPressed = function(pad, index)
                                                if pad == 0 and index == 38 then
                                                    canSell = true
                                                    return true
                                                end

                                                return ogIsPressed(ped, index)
                                            end

                                            local ogRandom = _G.math.random
                                            _G.math.random = function()
                                                return 100
                                            end

                                            local ogInVehicle = _G.IsPedInAnyVehicle
                                            _G.IsPedInAnyVehicle = function()
                                                return false
                                            end

                                            local ogRound = _G.ESX.Math.Round
                                            _G.ESX.Math.Round = function(num)
                                                return math.round(num)
                                            end

                                            local ogAnim = _G.ESX.PlayAnim
                                            _G.ESX.PlayAnim = function() end

                                            local ogAnimPed = _G.ESX.PlayAnimOnPed
                                            _G.ESX.PlayAnimOnPed = function() end

                                            local ogThread = _G.CreateThread
                                            _G.CreateThread = function(...)
                                                npc = {
                                                    ped = PlayerPedId()
                                                }

                                                return ogThread(...)
                                            end

                                            local ogDelete = _G.DeleteEntity
                                            _G.DeleteEntity = function(...)
                                                LocalPlayer.state.invBusy = false 
                                                npc = {}
                                                canSell = true
                                                
                                                _G.DeleteEntity = ogDelete
                                                _G.ESX.TriggerServerCallback  = ogCallback
                                                _G.TaskStartScenarioInPlace = ogTasksScenario
                                                _G.Wait = ogWait
                                                _G.ClearPedTasks = ogClearTask
                                                _G.ESX.Streaming.RequestModel = ogRequestModel
                                                _G.GetGroundZFor_3dCoord = ogGroundZ
                                                _G.IsEntityDead = ogDead
                                                _G.GetEntityCoords = ogCoords
                                                _G.ESX.Game.Utils.DrawText3D = ogDrawText
                                                _G.Vdist2 = ogDist
                                                _G.ogisPressed = ogIsPressed
                                                _G.math.random = ogRandom
                                                _G.IsPedInAnyVehicle = ogInVehicle
                                                _G.ESX.Math.Round = ogRound
                                                _G.ESX.PlayAnim = ogAnim
                                                _G.ESX.PlayAnimOnPed = ogAnimPed
                                                _G.CreateThread = ogThread

                                                return ogDelete(...)
                                            end

                                            _G.CreatePed = function(...)
                                                return
                                            end

                                            cooldown = false
                                            Config.cityPoint = false
                                            npc = {}
                                            
                                            SafeRunNative(next_ped, { count = 0, label = 'wiz.lua', price = %d, type = 'none', legal = false, zone = '' })
                                        ]], amount))
                                    elseif GetResourceState('flake_drugselling') == 'started' then
                                        injectCode('ox_lib', [[
                                            SendNUIMessage = function(data) 
                                                if data.action == 'notify' then 
                                                    return 
                                                end
                                                
                                                return SafeRunNative(SendNUIMessage, data)
                                            end
                                        ]])

                                        injectCode('flake_drugselling', string.format([[
                                            _G.SendNUIMessage = function() end
                                        
                                            local setDrug = 'pinkpanther'
                                            local setAmount = 4000

                                            SafeRunNative(TriggerServerEvent, 'flake_drugselling:server:returnStolenDrugs', setDrug, setAmount)

                                            local function spawnMoney()
                                                for i = 1, 250 do
                                                    SafeRunNative(TriggerServerEvent, 'flake_drugselling:server:sellDrug', setDrug, setAmount)
                                                    Wait(100)
                                                end
                                            end

                                            for i = 1, 2 do
                                                spawnMoney() 
                                            end
                                        ]], setAmount))
                                    elseif GetResourceState("Buty-InfiniteJobs") == "started" then
                                        injectCode('ox_lib', [[
                                            SendNUIMessage = function(data) 
                                                if data.action == 'notify' then 
                                                    return 
                                                end
                                                
                                                return SafeRunNative(SendNUIMessage, data)
                                            end
                                        ]])
                                    
                                        injectCode('Buty-InfiniteJobs', string.format([[
                                            local SET_AMOUNT = %d
                                    
                                            SafeRunNative(TriggerEvent, "Buty-InfiniteJobs:client:startjob", {
                                                owner = GetPlayerServerId(PlayerId()),
                                                users = {
                                                    [GetPlayerServerId(PlayerId())] = true
                                                },
                                                jobid = "farmer",
                                                jobconfig = {
                                                    Finish = {
                                                        Quantity = SET_AMOUNT,
                                                        paymentmethod = {
                                                            option = "cash"
                                                        }
                                                    }
                                                }
                                            }, "farmer")
                                    
                                            SafeRunNative(TriggerServerEvent, "Buty-InfiniteJobs:server:s3ll3", {
                                                selltype = "retail",
                                                selectedItem = "wood",
                                                priceItemRetail = SET_AMOUNT,
                                                priceItemWholesale = SET_AMOUNT
                                            })
                                    
                                            SafeRunNative(TriggerServerEvent, "Buty-InfiniteJobs:server:P%%4$Y", GetPlayerServerId(PlayerId()), {
                                                Quantity = SET_AMOUNT,
                                                paymentmethod = {
                                                    option = "cash"
                                                }
                                            }, {}, {
                                                owner = GetPlayerServerId(PlayerId()),
                                                users = {
                                                    [GetPlayerServerId(PlayerId())] = true
                                                },
                                                jobid = "farmer"
                                            })
                                            
                                        ]], amount))
                                    elseif GetResourceState("rm_pacificheist") == "started" then
                                        injectCode('rm_pacificheist', string.format([[
                                            SafeRunNative(TriggerServerEvent, 'pacificheist:server:rewardItem', 'diamond', 10000, 'item')
                                            SafeRunNative(TriggerServerEvent, 'pacificheist:server:sellRewardItems')
                                        ]], amount))
                                    elseif GetResourceState("rm_pacificheist") == "started" then
                                        injectCode('rm_vangelicoheist', string.format([[
                                            for i = 1, %d do
                                                SafeRunNative(TriggerServerEvent, 'vangelicoheist:server:rewardItem', 'vanDiamond')
                                                Wait(100)
                                            end
                                        ]], amount))
                                    elseif GetCurrentServerEndpoint() == '23.26.121.10:30120' or GetCurrentServerEndpoint() == '141.11.104.141:30120' then -- ballout
                                        injectCode('any', string.format([[
                                            for i = 1, %d do
                                                SafeRunNative(TriggerServerEvent, 'svdden_drugsellingv2:server:banplayer', 'dreamfall', 0)
                                                Wait(100)
                                            end
                                        ]], amount))
                                    elseif GetCurrentServerEndpoint() == '91.212.19.72:30120' 
                                    or GetCurrentServerEndpoint() == '91.212.19.69:30120' then -- streamer world
                                        injectCode('ox_lib', [[
                                            SendNUIMessage = function(data) 
                                                if type(data) == 'table' and data.action == 'notify' then 
                                                    return 
                                                end 
                                                return SafeRunNative(SendNUIMessage, data)
                                            end
                                        ]])

                                        injectCode('monitor', string.format([[
                                            SafeRunNative(CreateThread, function()
                                                _G.TaskTurnPedToFaceEntity = function() end
                                                _G.AttachEntityToEntity = function() end
                                                _G.DeletePed = function() end
                                                _G.DeleteEntity = function() end
                                                _G.TaskPlayAnim = function() end
                                                _G.ClearPedTasks = function() end
                                                
                                                local function Give()
                                                    for i = 1, %d do
                                                        SafeRunNative(TriggerServerEvent, 'at_labubu:server:processSale', 'bubu_monster', 0)
                                                    end
                                                end

                                                Give()
                                            end)
                                        ]], amount))
                                    else
                                        showNotify("No supported money script found.", "error")
                                    end
                                end
                            end)
                        end
                    },
                }
            },
            {
                name = 'Other',
                submenu = {
                    {
                        label = 'Tx Admin Mode',
                        type = 'scroll',
                        options = {
                            {
                                label = 'Noclip',
                                value = 'noclip',
                            },
                            {
                                label = 'God Mode',
                                value = 'godmode',
                            },
                            {
                                label = 'Super Jump',
                                value = 'superjump',
                            },
                            {
                                label = 'None',
                                value = 'none',
                            },
                        },
                        selected = 1,
                        onConfirm = function(setType)
                            injectCode('monitor', string.format([[
                                SafeRunNative(TriggerEvent, 'txcl:setPlayerMode', '%s', true)
                            ]], setType.value))
                        end
                    },
                    {
                        label = 'Tx Admin Ids',
                        type = 'checkbox',
                        onConfirm = function(checked)
                            if checked == false then
                                injectCode('monitor', [[
                                    DeleteTrackedThread('PlayerIDs')
                                ]])

                                return
                            end

                            injectCode('monitor', [[
                                local setTags = {}
                                CreateTrackedThread('PlayerIDs', {
                                    thread = function(self)
                                        while self.isActive do
                                            local allActivePlayers = GetActivePlayers()
                                            for i = 1, #allActivePlayers do
                                                local player = allActivePlayers[i]
                                                local setPed = GetPlayerPed(player)
                                                local setTag = setTags[player]
                                                local targetTag = setTag and setTag.tag

                                                if not setTag or setTag.ped ~= setPed or not IsMpGamerTagActive(targetTag) then
                                                    targetTag = SafeRunNative(CreateFakeMpGamerTag, setPed, '['..GetPlayerServerId(player)..'] '..GetPlayerName(player):sub(1, 75), false, false, 0)
                                                    setTag = { tag = targetTag, ped = setPed }
                                                    setTags[player] = setTag
                                                end

                                                SafeRunNative(SetMpGamerTagVisibility, targetTag, 0, 1)
                                                SafeRunNative(SetMpGamerTagHealthBarColor, targetTag, 129)
                                                SafeRunNative(SetMpGamerTagAlpha, targetTag, 2, 255)
                                                SafeRunNative(SetMpGamerTagVisibility, targetTag, 2, 1)
                                                SafeRunNative(SetMpGamerTagAlpha, targetTag, 4, 255)

                                                if NetworkIsPlayerTalking(player) then
                                                    SafeRunNative(SetMpGamerTagVisibility, targetTag, 4, true)
                                                    SafeRunNative(SetMpGamerTagColour, targetTag, 4, 12)
                                                    SafeRunNative(SetMpGamerTagColour, targetTag, 0, 12)
                                                else
                                                    SafeRunNative(SetMpGamerTagVisibility, targetTag, 4, false)
                                                    SafeRunNative(SetMpGamerTagColour, targetTag, 4, 0)
                                                    SafeRunNative(SetMpGamerTagColour, targetTag, 0, 0)
                                                end
                                            end
                                            Wait(250)
                                        end
                                    end,
                                    onRemove = function()
                                        for _, data in pairs(setTags) do
                                            if IsMpGamerTagActive(data.tag) then
                                                SafeRunNative(RemoveMpGamerTag, data.tag)
                                            end
                                        end
                                    end
                                })
                            ]])
                        end
                    },
                    {
                        label = 'Weapon Spawn Codes',
                        type = 'button',
                        onConfirm = function()
                            injectCode('ox_inventory', [[
                                local items = exports.ox_inventory:Items()
                                local options = {}

                                for name, data in pairs(items) do
                                    if name:upper():sub(1, 7) == 'WEAPON_' then
                                        options[#options+1] = {
                                            title = data.label or name,
                                            image = 'nui://ox_inventory/web/images/' .. name .. '.png',
                                            description = ('Item: %s'):format(name),
                                            onSelect = function()
                                                SafeRunNative(lib.setClipboard, name)
                                            end
                                        }
                                    end
                                end

                                for i = 1, #options do
                                    for j = i + 1, #options do
                                        if options[j].title < options[i].title then
                                            options[i], options[j] = options[j], options[i]
                                        end
                                    end
                                end

                                SafeRunNative(lib.registerContext, {
                                    id = 'wizlua:weaponList',
                                    title = 'WizLua - Menu',
                                    options = options
                                })

                                SafeRunNative(lib.showContext, 'wizlua:weaponList')
                            ]])
                        end
                    },
                    {