if not TLS.WeaponMenu.Enable then return end local WeaponSave = json.decode(GetResourceKvpString('tls_weapon_save')) or {} local WeaponMenu = {} local WeaponTints = { ['Normal'] = { 'Black', 'Green', 'Gold', 'Pink', 'Army', 'LSPD', 'Orange', 'Platinum', }, ['MK2'] = { 'Classic Black', 'Classic Gray', 'Classic Two Tone', 'Classic White', 'Classic Beige', 'Classic Green', 'Classic Blue', 'Classic Earth', 'Classic Brown & Black', 'Red Contrast', 'Blue Contrast', 'Yellow Contrast', 'Orange Contrast', 'Bold Pink', 'Bold Purple & Yellow', 'Bold Orange', 'Bold Green & Purple', 'Bold Red Features', 'Bold Green Features', 'Bold Cyan Features', 'Bold Yellow Features', 'Bold Red & White', 'Bold Blue & White', 'Metallic Gold', 'Metallic Platinum', 'Metallic Gray & Lilac', 'Metallic Purple & Lime', 'Metallic Red', 'Metallic Green', 'Metallic Blue', 'Metallic White & Aqua', 'Metallic Red & Yellow' } } local function DisplayKeyboard(textEntry, inputText, maxLength, isNumber) AddTextEntry('FMMC_KEY_TIP1', textEntry) DisplayOnscreenKeyboard(1, 'FMMC_KEY_TIP1', '', inputText, '', '', '', maxLength) while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do Wait(0) end if UpdateOnscreenKeyboard() ~= 2 then local result = GetOnscreenKeyboardResult() Wait(500) if isNumber then result = tonumber(result) end return result else Wait(500) return nil end end RegisterCommand(TLS.WeaponMenu.Command, function() for hash, data in pairs(WeaponConfig) do if IsWeaponValid(hash) then local index = #WeaponMenu + 1 local componentOptions = {} for component, name in pairs(data.components) do componentOptions[#componentOptions + 1] = { type = 'select', label = name, onClick = function() local ped = PlayerPedId() if not HasPedGotWeaponComponent(ped, hash, component) then GiveWeaponComponentToPed(ped, hash, component) else RemoveWeaponComponentFromPed(ped, hash, component) end end } end local weaponOptions = { { type = 'select', label = 'Toggle Weapon', onClick = function() local ped = PlayerPedId() local _, max_ammo = GetMaxAmmo(ped, hash) if not HasPedGotWeapon(ped, hash, false) then GiveWeaponToPed(ped, hash, max_ammo, false, true) else RemoveWeaponFromPed(ped, hash) end end }, { type = 'select', label = 'Max Ammo', onClick = function() local ped = PlayerPedId() local ammo_type = GetPedAmmoTypeFromWeapon(ped, hash) local _, max_ammo = GetMaxAmmoByType(ped, ammo_type) AddAmmoToPedByType(ped, ammo_type, max_ammo) end }, { type = 'list', label = 'Tint', list = data.IsMK2 and WeaponTints['MK2'] or WeaponTints['Normal'], index = 1, onChange = function(index) local ped = PlayerPedId() SetPedWeaponTintIndex(ped, hash, index - 1) end }, { type = 'submenu', id = 'components_' .. index, label = 'Components', options = componentOptions }, { type = 'submenu', id = 'saves_' .. index, label = 'Saves', options = { { type = 'select', label = 'New Weapon Save', onClick = function() local ped = PlayerPedId() local save_label = DisplayKeyboard('Save Name', '', 30) if not save_label then return end if not WeaponSave[hash] then WeaponSave[hash] = {} end if not HasPedGotWeapon(ped, hash, false) then return end local components = {} for component, name in pairs(data.components) do if HasPedGotWeaponComponent(ped, hash, component) then components[#components + 1] = component end end WeaponSave[hash][#WeaponSave[hash] + 1] = { label = save_label, tint = GetPedWeaponTintIndex(ped, hash), components = components } SetResourceKvp('tls_weapon_save', json.encode(WeaponSave)) end }, } } } local savedWeapons = WeaponSave[hash] or WeaponSave[tostring(hash)] if WeaponSave and savedWeapons then for i = 1, #savedWeapons do local save = savedWeapons[i] if save then weaponOptions[5].options[#weaponOptions[5].options + 1] = { type = 'submenu', id = 'weapon_sub_menu_save_' .. index .. i, label = save.label, options = { { type = 'select', label = 'Equip Weapon', onClick = function() local ped = PlayerPedId() local _, max_ammo = GetMaxAmmo(ped, hash) GiveWeaponToPed(ped, hash, max_ammo, false, true) for i = 1, #save.components do GiveWeaponComponentToPed(ped, hash, save.components[i]) end SetWeaponObjectTintIndex(hash, save.tint) end }, { type = 'select', label = 'Delete Weapon', onClick = function() savedWeapons[i] = nil SetResourceKvp('tls_weapon_save', json.encode(WeaponSave)) end } } } end end end WeaponMenu[#WeaponMenu + 1] = { type = 'submenu', id = 'weapon_menu_option_' .. index, label = data.name, options = weaponOptions } end end menuBuilder.create({ id = 'weapon_menu', label = 'Thinline Sanctuary', description = 'Weapon Menu', options = WeaponMenu }) menuBuilder.open('weapon_menu') end) RegisterKeyMapping(TLS.WeaponMenu.Command, 'Weapon Menu', 'keyboard', TLS.WeaponMenu.Keybind)