structura foldere
mutat kq- folders in un singur folder [kq]
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
if Config.HotKeys then
|
||||
CreateThread(function()
|
||||
while true do
|
||||
if IsControlJustPressed(0, Config.Controls.UseKey) then
|
||||
UseCommandKey()
|
||||
end
|
||||
|
||||
Wait(0)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
RegisterCommand('usekey', function()
|
||||
UseCommandKey()
|
||||
end, false)
|
||||
|
||||
-- if Config.HotKeys then
|
||||
-- if not Config.ControlerSupport then
|
||||
-- lib.addKeybind({
|
||||
-- name = 'engine',
|
||||
-- description = Lang('VEHICLEKEYS_ENGINE_TOGGLE'),
|
||||
-- defaultKey = Config.Controls.EngineControl,
|
||||
-- onPressed = function()
|
||||
-- toggleEngine()
|
||||
-- end
|
||||
-- })
|
||||
-- end
|
||||
|
||||
-- lib.addKeybind({
|
||||
-- name = 'usekey',
|
||||
-- description = Lang('VEHICLEKEYS_USE_KEY'),
|
||||
-- defaultKey = Config.Controls.UseKey,
|
||||
-- onPressed = function()
|
||||
-- UseCommandKey()
|
||||
-- end
|
||||
-- })
|
||||
|
||||
-- RegisterKeyMapping('hotwire', Lang('VEHICLEKEYS_HOTWIRE'), 'keyboard', Config.Controls.HotwireControl)
|
||||
|
||||
-- if Config.AnchorKeybind then
|
||||
-- lib.addKeybind({
|
||||
-- name = 'anchor',
|
||||
-- description = Lang('VEHICLEKEYS_ANCHOR_BOAT'),
|
||||
-- defaultKey = '',
|
||||
-- onPressed = function()
|
||||
-- ExecuteCommand('anchor')
|
||||
-- end
|
||||
-- })
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- RegisterCommand('usekey', function()
|
||||
-- UseCommandKey()
|
||||
-- end, false)
|
||||
|
||||
-- RegisterCommand('hotwire', function()
|
||||
-- HandleHotwireProcess()
|
||||
-- end, false)
|
||||
@@ -0,0 +1,379 @@
|
||||
-- Check if Context Menu is enabled in the configuration
|
||||
if not Config.Context then return end
|
||||
|
||||
function OpenMainMenu()
|
||||
local elements = {}
|
||||
|
||||
table.insert(elements, {
|
||||
title = Lang("VEHICLEKEYS_MENU_CLEAN_KEYS_TITLE"),
|
||||
description = Lang("VEHICLEKEYS_MENU_CLEAN_KEYS_DESCRIPTION"),
|
||||
icon = 'wrench',
|
||||
onSelect = function(args)
|
||||
CleanVehicleKeys()
|
||||
end,
|
||||
})
|
||||
table.insert(elements, {
|
||||
title = Lang("VEHICLEKEYS_MENU_ACCESS_ALL_KEYS_TITLE"),
|
||||
description = Lang("VEHICLEKEYS_MENU_ACCESS_ALL_KEYS_DESCRIPTION"),
|
||||
icon = 'key',
|
||||
onSelect = function(args)
|
||||
OpenAllKeysMenu()
|
||||
end,
|
||||
})
|
||||
|
||||
lib.registerContext({
|
||||
id = 'MAIN_MENU_TITLE',
|
||||
title = Lang("VEHICLEKEYS_MAIN_MENU_TITLE"),
|
||||
options = elements,
|
||||
})
|
||||
lib.showContext('MAIN_MENU_TITLE')
|
||||
end
|
||||
|
||||
|
||||
function OpenAllKeysMenu()
|
||||
local elements = {}
|
||||
local function AddKeyToAllKeysMenu(title, plate, model)
|
||||
table.insert(elements, {
|
||||
title = title,
|
||||
icon = 'key',
|
||||
onSelect = function(args)
|
||||
CreateKeyMenuItem(title, plate, model)
|
||||
end,
|
||||
})
|
||||
end
|
||||
TriggerServerCallback(Config.Eventprefix .. ':server:GetPlayerItems', function(items)
|
||||
if items then
|
||||
local keysFound = false
|
||||
for _, item in pairs(items) do
|
||||
local plate = GetPlateFromItem(item)
|
||||
local model = GetModelFromItem(item)
|
||||
if plate and model then
|
||||
keysFound = true
|
||||
AddKeyToAllKeysMenu(Lang("VEHICLEKEYS_MENU_MODEL").." " .. model .. ", ".. Lang("VEHICLEKEYS_MENU_PLATE").." " .. plate, plate, model)
|
||||
end
|
||||
end
|
||||
if not keysFound then
|
||||
table.insert(elements, {
|
||||
title = Lang("NO_KEYS_FOUND"),
|
||||
icon = 'exclamation-circle',
|
||||
disabled = true,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(elements, {
|
||||
title = Lang("BACK_TO_PREVIOUS_MENU"),
|
||||
icon = 'arrow-left',
|
||||
onSelect = function(args)
|
||||
OpenMainMenu()
|
||||
end,
|
||||
})
|
||||
|
||||
lib.registerContext({
|
||||
id = 'ALL_KEYS_MENU',
|
||||
title = Lang("VEHICLEKEYS_ALL_KEYS_MENU_TITLE"),
|
||||
options = elements,
|
||||
})
|
||||
lib.showContext('ALL_KEYS_MENU')
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
function CreateKeyMenuItem(title, plate, model)
|
||||
lib.registerContext({
|
||||
id = 'keysactions',
|
||||
title = 'Actions',
|
||||
options = {
|
||||
{
|
||||
title = Lang("VEHICLEKEYS_MENU_KEY_MENU_HEADER"),
|
||||
icon = "info",
|
||||
disabled = true,
|
||||
description = Lang("VEHICLEKEYS_MENU_KEY_MENU_MODEL") .. " " .. model .. " " ..
|
||||
Lang("VEHICLEKEYS_MENU_KEY_MENU_PLATE") .. " " .. plate
|
||||
|
||||
},
|
||||
{
|
||||
title = Lang("VEHICLEKEYS_MENU_USE_KEY_TITLE"),
|
||||
description = Lang("VEHICLEKEYS_MENU_USE_KEY_DESCRIPTION"),
|
||||
icon = "check",
|
||||
metadata = {
|
||||
{ label = 'Action', value = Lang("VEHICLEKEYS_MENU_USE_KEY_DESCRIPTION") },
|
||||
},
|
||||
onSelect = function(args)
|
||||
handleDoorLock(plate, model)
|
||||
end
|
||||
},
|
||||
{
|
||||
title = Lang("VEHICLEKEYS_MENU_GIVE_KEY_TITLE"),
|
||||
icon = "handshake",
|
||||
description = Lang("VEHICLEKEYS_MENU_GIVE_KEY_DESCRIPTION"),
|
||||
metadata = {
|
||||
{ label = 'Action', value = Lang("VEHICLEKEYS_MENU_GIVE_KEY_DESCRIPTION") },
|
||||
},
|
||||
onSelect = function(args)
|
||||
ShowNearbyPlayersMenu(plate, model)
|
||||
end
|
||||
},
|
||||
{
|
||||
title = Lang("VEHICLEKEYS_MENU_TRASH_KEY_TITLE"),
|
||||
icon = "trash",
|
||||
description = Lang("VEHICLEKEYS_MENU_TRASH_KEY_DESCRIPTION"),
|
||||
metadata = {
|
||||
{ label = 'Action', value = Lang("VEHICLEKEYS_MENU_TRASH_KEY_DESCRIPTION") },
|
||||
},
|
||||
onSelect = function(args)
|
||||
exports['qs-vehiclekeys']:RemoveKeys(plate, model)
|
||||
end
|
||||
},
|
||||
{
|
||||
title = Lang("BACK_TO_PREVIOUS_MENU"),
|
||||
icon = "arrow-left",
|
||||
onSelect = function(args)
|
||||
OpenAllKeysMenu()
|
||||
end
|
||||
},
|
||||
}
|
||||
})
|
||||
lib.showContext('keysactions')
|
||||
end
|
||||
|
||||
function getClosestVehicle(coords, maxDistance, includePlayerVehicle)
|
||||
return lib.getClosestVehicle(coords, maxDistance, includePlayerVehicle)
|
||||
end
|
||||
|
||||
function handleDoorLock(plate, model)
|
||||
local coords = GetEntityCoords(PlayerPedId())
|
||||
local vehicle, _ = getClosestVehicle(coords, 5.0, true)
|
||||
if vehicle then
|
||||
local vehiclePlate = GetVehicleNumberPlateText(vehicle)
|
||||
local vehicleModel = GetDisplayNameFromVehicleModel(GetEntityModel(vehicle))
|
||||
if vehiclePlate == plate and vehicleModel == model then
|
||||
local hasKey = exports['qs-vehiclekeys']:GetKey(plate)
|
||||
if hasKey then
|
||||
exports["qs-vehiclekeys"]:DoorLogic(vehicle)
|
||||
for door = 0, 5 do
|
||||
SetVehicleDoorShut(vehicle, door, false, false)
|
||||
end
|
||||
else
|
||||
SendTextMessage(Lang('VEHICLEKEYS_NOTIFICATION_NO_KEYS'), 'error')
|
||||
end
|
||||
else
|
||||
SendTextMessage(Lang('VEHICLEKEYS_NOTIFICATION_NO_MATCH'), 'error')
|
||||
end
|
||||
else
|
||||
SendTextMessage(Lang('VEHICLEKEYS_NOTIFICATION_NO_VEHICLES'), 'error')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function GetPlayersInRadius(x, y, z, radius)
|
||||
local currentPlayerId = GetPlayerServerId(PlayerId())
|
||||
local players = ""
|
||||
for i = 0, 255 do
|
||||
if NetworkIsPlayerActive(i) then
|
||||
local playerPed = GetPlayerPed(i)
|
||||
local playerCoords = GetEntityCoords(playerPed, false)
|
||||
local distance = GetDistanceBetweenCoords(x, y, z, playerCoords, true)
|
||||
local playerId = GetPlayerServerId(i)
|
||||
if distance <= radius and playerId ~= currentPlayerId then
|
||||
if players == "" then
|
||||
players = tostring(playerId)
|
||||
else
|
||||
players = players .. "," .. tostring(playerId)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return players
|
||||
end
|
||||
|
||||
function ShowNearbyPlayersMenu(plate, model)
|
||||
local playerPed = GetPlayerPed(-1) -- Get the player's ped
|
||||
local x, y, z = table.unpack(GetEntityCoords(playerPed, false))
|
||||
local nearbyPlayers = GetPlayersInRadius(x, y, z, 2.0)
|
||||
|
||||
local elements = {}
|
||||
|
||||
if #nearbyPlayers == 0 then
|
||||
table.insert(elements, {
|
||||
title = Lang("VEHICLEKEYS_NO_PLAYERS_FOUND"),
|
||||
icon = 'exclamation-circle',
|
||||
disabled = true,
|
||||
})
|
||||
else
|
||||
local playerIds = {}
|
||||
for playerId in nearbyPlayers:gmatch("[^,]+") do
|
||||
table.insert(playerIds, playerId)
|
||||
end
|
||||
|
||||
for _, playerId in ipairs(playerIds) do
|
||||
table.insert(elements, {
|
||||
title = playerId,
|
||||
icon = 'user',
|
||||
onSelect = function()
|
||||
CheckAndGiveKey(plate, model, playerId)
|
||||
end
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(elements, {
|
||||
title = Lang("BACK_TO_PREVIOUS_MENU"),
|
||||
icon = 'arrow-left',
|
||||
onSelect = function(args)
|
||||
CreateKeyMenuItem(title, plate, model)
|
||||
end,
|
||||
})
|
||||
|
||||
lib.registerContext({
|
||||
id = 'vehiclekeys_nearby_players',
|
||||
title = Lang("VEHICLEKEYS_NEARBY_PLAYERS_MENU_TITLE"),
|
||||
options = elements
|
||||
})
|
||||
lib.showContext('vehiclekeys_nearby_players')
|
||||
end
|
||||
|
||||
function CleanVehicleKeys()
|
||||
if Config.Framework == "esx" then
|
||||
-- ESX Framework logic
|
||||
TriggerServerCallback(Config.Eventprefix .. ':server:getVehicles', function(vehicles)
|
||||
if vehicles then
|
||||
local ownedVehicles = {}
|
||||
for _, v in pairs(vehicles) do
|
||||
local hashVehicle = v.vehicle.model
|
||||
local plate = v.vehicle.plate
|
||||
local vehicleName = GetDisplayNameFromVehicleModel(hashVehicle)
|
||||
ownedVehicles[plate] = vehicleName
|
||||
end
|
||||
TriggerServerCallback(Config.Eventprefix .. ':server:GetPlayerItems', function(items)
|
||||
if items then
|
||||
local keysRemoved = true
|
||||
for _, item in pairs(items) do
|
||||
local plate = GetPlateFromItem(item)
|
||||
local model = GetModelFromItem(item)
|
||||
if plate and model then
|
||||
if not ownedVehicles[plate] or ownedVehicles[plate] ~= model then
|
||||
exports['qs-vehiclekeys']:RemoveKeys(plate, model)
|
||||
keysRemoved = false
|
||||
end
|
||||
end
|
||||
end
|
||||
if keysRemoved then
|
||||
SendTextMessage(Lang('VEHICLEKEYS_MENU_CLEAN_KEYS_ERROR'), 'error')
|
||||
else
|
||||
SendTextMessage(Lang('VEHICLEKEYS_MENU_CLEAN_KEYS_SUCCESS'), 'inform')
|
||||
end
|
||||
else
|
||||
SendTextMessage(Lang('VEHICLEKEYS_MENU_CLEAN_KEYS_ERROR'), 'error')
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
elseif Config.Framework == "qb" then
|
||||
-- QBCore Framework logic
|
||||
TriggerServerCallback(Config.Eventprefix .. ':server:getVehicles', function(vehicles)
|
||||
if not vehicles then
|
||||
print('No vehicles received from server callback')
|
||||
return
|
||||
end
|
||||
|
||||
local ownedVehicles = {}
|
||||
for _, v in pairs(vehicles) do
|
||||
if v.vehicle and v.plate then
|
||||
local vehicleName = GetDisplayNameFromVehicleModel(v.vehicle.model)
|
||||
ownedVehicles[v.plate] = vehicleName
|
||||
else
|
||||
print('Missing vehicle or plate information:', v.vehicle, v.plate)
|
||||
end
|
||||
end
|
||||
|
||||
TriggerServerCallback(Config.Eventprefix .. ':server:GetPlayerItems', function(items)
|
||||
if items then
|
||||
local keysRemoved = true
|
||||
for _, item in pairs(items) do
|
||||
local plate = GetPlateFromItem(item)
|
||||
local model = GetModelFromItem(item)
|
||||
if plate and model then
|
||||
if not ownedVehicles[plate] or ownedVehicles[plate] ~= model then
|
||||
exports['qs-vehiclekeys']:RemoveKeys(plate, model)
|
||||
keysRemoved = false
|
||||
end
|
||||
end
|
||||
end
|
||||
if keysRemoved then
|
||||
SendTextMessage(Lang('VEHICLEKEYS_MENU_CLEAN_KEYS_ERROR'), 'error')
|
||||
else
|
||||
SendTextMessage(Lang('VEHICLEKEYS_MENU_CLEAN_KEYS_SUCCESS'), 'inform')
|
||||
end
|
||||
else
|
||||
SendTextMessage(Lang('VEHICLEKEYS_MENU_CLEAN_KEYS_ERROR'), 'error')
|
||||
end
|
||||
end)
|
||||
end)
|
||||
else
|
||||
print("Invalid framework specified in configuration.")
|
||||
end
|
||||
end
|
||||
|
||||
function PlayGiveAnimation()
|
||||
local EmoteData = {
|
||||
Animation = 'givetake1_a',
|
||||
Dictionary = 'mp_common',
|
||||
Options = {
|
||||
Duration = 2000,
|
||||
Flags = {
|
||||
Move = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
PlayEmote(EmoteData)
|
||||
end
|
||||
|
||||
function CheckAndGiveKey(plate, model, targetPlayerId)
|
||||
PlayGiveAnimation()
|
||||
|
||||
exports['qs-vehiclekeys']:RemoveKeys(plate, model)
|
||||
TriggerServerEvent('vehiclekeys:server:givekeyother', plate, model, targetPlayerId)
|
||||
end
|
||||
|
||||
RegisterNetEvent('vehiclekeys:client:givekeyclient')
|
||||
AddEventHandler('vehiclekeys:client:givekeyclient', function(plate, model)
|
||||
PlayGiveAnimation()
|
||||
|
||||
exports['qs-vehiclekeys']:GiveKeys(plate, model)
|
||||
end)
|
||||
|
||||
|
||||
function PlayEmote(animationData)
|
||||
local dict = animationData.Dictionary
|
||||
local anim = animationData.Animation
|
||||
|
||||
local function LoadAnimationDict(dict, timeout)
|
||||
RequestAnimDict(dict)
|
||||
local startTick = GetGameTimer()
|
||||
while not HasAnimDictLoaded(dict) do
|
||||
Citizen.Wait(0)
|
||||
if GetGameTimer() - startTick > timeout then
|
||||
print("Failed to load animation dictionary: " .. dict)
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function PlayAnimation()
|
||||
if not LoadAnimationDict(dict, 500) then
|
||||
return
|
||||
end
|
||||
TaskPlayAnim(PlayerPedId(), dict, anim, 2.0, 2.0, animationData.Options.Duration, 0, 0, false, false, false)
|
||||
RemoveAnimDict(dict)
|
||||
end
|
||||
|
||||
PlayAnimation()
|
||||
end
|
||||
|
||||
|
||||
RegisterCommand("openkeys", function(source, args, rawCommand)
|
||||
OpenMainMenu()
|
||||
end, false)
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
RegisterNetEvent(Config.Eventprefix .. ':client:toggleEngine', function(forcestate)
|
||||
toggleEngine(forcestate)
|
||||
end)
|
||||
|
||||
function toggleEngine(forcestate)
|
||||
|
||||
-- local playerPed = PlayerPedId()
|
||||
-- local vehicle = GetVehiclePedIsIn(playerPed, false)
|
||||
-- if not vehicle or vehicle == 0 or IsPauseMenuActive() then return end
|
||||
|
||||
-- local isDriver = GetPedInVehicleSeat(vehicle, -1) == playerPed
|
||||
-- local hasKey = exports['qs-vehiclekeys']:GetKey(GetVehicleNumberPlateText(vehicle)) or not Config.ToggleEngineRequireKeys
|
||||
-- local isJobShared = AreKeysJobShared(vehicle)
|
||||
|
||||
-- if not (isDriver and (hasKey or isJobShared)) then
|
||||
-- return SendTextMessage(Lang('VEHICLEKEYS_NOTIFICATION_NO_PERMISSION'), 'error')
|
||||
-- end
|
||||
|
||||
-- local engineRunning = GetIsVehicleEngineRunning(vehicle)
|
||||
-- if forcestate ~= nil then
|
||||
-- if Config.EngineInteriorLights then
|
||||
-- SetVehicleInteriorlight(vehicle, forcestate)
|
||||
-- end
|
||||
-- SetVehicleEngineOn(vehicle, forcestate, false, true)
|
||||
-- else
|
||||
-- if engineRunning then
|
||||
-- if Config.EngineInteriorLights then
|
||||
-- SetVehicleInteriorlight(vehicle, false)
|
||||
-- end
|
||||
-- SetVehicleEngineOn(vehicle, false, false, true)
|
||||
-- SendTextMessage(Lang('VEHICLEKEYS_NOTIFICATION_ENGINE_STOPPED'), 'error')
|
||||
-- else
|
||||
-- if Config.EngineInteriorLights then
|
||||
-- SetVehicleInteriorlight(vehicle, true)
|
||||
-- end
|
||||
-- SetVehicleEngineOn(vehicle, true, false, true)
|
||||
-- SendTextMessage(Lang('VEHICLEKEYS_NOTIFICATION_ENGINE_STARTED'), 'success')
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
|
||||
-- exports('toggleEngine', toggleEngine)
|
||||
|
||||
function isEngineRunning(vehicle)
|
||||
local playerPed = PlayerPedId()
|
||||
vehicle = vehicle or GetVehiclePedIsIn(playerPed, false)
|
||||
if vehicle and vehicle ~= 0 then
|
||||
local engineRunning = GetIsVehicleEngineRunning(vehicle)
|
||||
if engineRunning == '1' then
|
||||
engineRunning = true
|
||||
end
|
||||
return engineRunning
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
exports('isEngineRunning', isEngineRunning)
|
||||
@@ -0,0 +1,31 @@
|
||||
exports('GiveKeysAuto', function()
|
||||
GiveKeysAuto()
|
||||
end)
|
||||
|
||||
exports('GetKeyAuto', function()
|
||||
return GetKeyAuto()
|
||||
end)
|
||||
|
||||
exports('RemoveKeysAuto', function()
|
||||
RemoveKeysAuto()
|
||||
end)
|
||||
|
||||
exports('GiveKeys', function(plate, model, bypassKeyCheck)
|
||||
GiveKeys(plate, model, bypassKeyCheck)
|
||||
end)
|
||||
|
||||
exports('RemoveKeys', function(plate, model)
|
||||
RemoveKeys(plate, model)
|
||||
end)
|
||||
|
||||
exports('GetKey', function(plate)
|
||||
return GetKey(plate)
|
||||
end)
|
||||
|
||||
exports('OpenCar', function(vehicle)
|
||||
DoorLogic(vehicle)
|
||||
end)
|
||||
|
||||
exports('CloseCar', function(vehicle)
|
||||
DoorLogic(vehicle)
|
||||
end)
|
||||
@@ -0,0 +1,53 @@
|
||||
-- OX inventory
|
||||
if Config.InventoryScript ~= 'ox' then
|
||||
return
|
||||
end
|
||||
|
||||
local ox_inventory = exports.ox_inventory
|
||||
exports('useKey', function(data, slot)
|
||||
ox_inventory:useItem(data, function(data)
|
||||
if data then
|
||||
TriggerEvent(Config.Eventprefix..':client:UseKey', data.metadata.plate, data.metadata.model)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
exports('usePlate', function(data, slot)
|
||||
ox_inventory:useItem(data, function(data)
|
||||
if data then
|
||||
TriggerEvent(Config.Eventprefix..':client:UsePlate', data.metadata.plate)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
exports('useCarlockpick', function(data, slot)
|
||||
ox_inventory:useItem(data, function(data)
|
||||
if data then
|
||||
useLockpick(false)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
exports('useAdvancedCarlockpick', function(data, slot)
|
||||
ox_inventory:useItem(data, function(data)
|
||||
if data then
|
||||
useLockpick(true)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
exports('useVehiclegps', function(data, slot)
|
||||
ox_inventory:useItem(data, function(data)
|
||||
if data then
|
||||
TriggerEvent(Config.Eventprefix..':client:UseGPS')
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
exports('useVehicletracker', function(data, slot)
|
||||
ox_inventory:useItem(data, function(data)
|
||||
if data then
|
||||
TriggerEvent(Config.Eventprefix..':client:UseTracker')
|
||||
end
|
||||
end)
|
||||
end)
|
||||
@@ -0,0 +1,307 @@
|
||||
--[[
|
||||
██████╗░░█████╗░██████╗░██╗░█████╗░██╗░░░░░ ███╗░░░███╗███████╗███╗░░██╗██╗░░░██╗
|
||||
██╔══██╗██╔══██╗██╔══██╗██║██╔══██╗██║░░░░░ ████╗░████║██╔════╝████╗░██║██║░░░██║
|
||||
██████╔╝███████║██║░░██║██║███████║██║░░░░░ ██╔████╔██║█████╗░░██╔██╗██║██║░░░██║
|
||||
██╔══██╗██╔══██║██║░░██║██║██╔══██║██║░░░░░ ██║╚██╔╝██║██╔══╝░░██║╚████║██║░░░██║
|
||||
██║░░██║██║░░██║██████╔╝██║██║░░██║███████╗ ██║░╚═╝░██║███████╗██║░╚███║╚██████╔╝
|
||||
╚═╝░░╚═╝╚═╝░░╚═╝╚═════╝░╚═╝╚═╝░░╚═╝╚══════╝ ╚═╝░░░░░╚═╝╚══════╝╚═╝░░╚══╝░╚═════╝░
|
||||
]]--
|
||||
|
||||
-- Check if Radial is enabled in the configuration
|
||||
if not Config.Radial then return end
|
||||
|
||||
function GetClosestVehicle()
|
||||
local playerCoords = GetEntityCoords(PlayerPedId())
|
||||
local vehicles = GetGamePool("CVehicle")
|
||||
|
||||
local closestVehicle, closestDistance
|
||||
|
||||
for _, vehicle in ipairs(vehicles) do
|
||||
local distance = #(playerCoords - GetEntityCoords(vehicle))^2
|
||||
|
||||
if not closestDistance or distance < closestDistance then
|
||||
closestVehicle = vehicle
|
||||
closestDistance = math.sqrt(distance)
|
||||
end
|
||||
end
|
||||
|
||||
return closestVehicle, closestDistance
|
||||
end
|
||||
|
||||
-- CreateThread(function()
|
||||
-- local radialItemAdded = false
|
||||
-- lib.removeRadialItem('carkeys')
|
||||
|
||||
-- while true do
|
||||
-- Wait(1000)
|
||||
-- local maxDistance = 4.0
|
||||
-- local vehicle, distance = GetClosestVehicle()
|
||||
|
||||
-- if vehicle and distance < maxDistance then
|
||||
-- local plate = GetVehicleNumberPlateText(vehicle)
|
||||
-- local hasKey = exports['qs-vehiclekeys']:GetKey(plate)
|
||||
|
||||
-- if hasKey and not radialItemAdded then
|
||||
-- lib.addRadialItem({
|
||||
-- {
|
||||
-- id = 'carkeys',
|
||||
-- label = Lang('VEHICLEKEYS_RADIAL_VEHICLEKEYS_LABEL'),
|
||||
-- icon = "key",
|
||||
-- onSelect = function()
|
||||
-- exports["qs-vehiclekeys"]:DoorLogic(vehicle)
|
||||
-- end
|
||||
-- }
|
||||
-- })
|
||||
-- radialItemAdded = true
|
||||
-- elseif not hasKey and radialItemAdded then
|
||||
-- lib.removeRadialItem('carkeys')
|
||||
-- radialItemAdded = false
|
||||
-- end
|
||||
-- else
|
||||
-- if radialItemAdded then
|
||||
-- lib.removeRadialItem('carkeys')
|
||||
-- radialItemAdded = false
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
-- end)
|
||||
|
||||
|
||||
--[[
|
||||
█▀▀ ▄▀█ █▀█ █▀▄ █▀█ █▀█ █▀█ █▀
|
||||
█▄▄ █▀█ █▀▄ █▄▀ █▄█ █▄█ █▀▄ ▄█
|
||||
]]--
|
||||
|
||||
lib.registerRadial({
|
||||
id = 'car_doors',
|
||||
items = {
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_REARRIGHT_LABEL'),
|
||||
icon = 'car-side',
|
||||
onSelect = function()
|
||||
doorToggle(3)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_TRUNK_LABEL'),
|
||||
icon = 'car-rear',
|
||||
onSelect = function()
|
||||
doorToggle(5)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_PASSENGER_LABEL'),
|
||||
icon = 'car-side',
|
||||
onSelect = function()
|
||||
doorToggle(1)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_DRIVER_LABEL'),
|
||||
icon = 'car-side',
|
||||
onSelect = function()
|
||||
doorToggle(0)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_HOOD_LABEL'),
|
||||
icon = 'car',
|
||||
onSelect = function()
|
||||
doorToggle(4)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_REARLEFT_LABEL'),
|
||||
icon = 'car-side',
|
||||
onSelect = function()
|
||||
doorToggle(2)
|
||||
end
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
--[[
|
||||
█▀▀ ▄▀█ █▀█ █░█░█ █ █▄░█ █▀▄ █▀█ █░█░█ █▀
|
||||
█▄▄ █▀█ █▀▄ ▀▄▀▄▀ █ █░▀█ █▄▀ █▄█ ▀▄▀▄▀ ▄█
|
||||
]]--
|
||||
|
||||
lib.registerRadial({
|
||||
id = 'car_windows',
|
||||
items = {
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_REARRIGHT_LABEL'),
|
||||
icon = 'caret-right',
|
||||
onSelect = function()
|
||||
windowToggle(2, 3)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_PASSENGER_LABEL'),
|
||||
icon = 'caret-up',
|
||||
onSelect = function()
|
||||
windowToggle(1, 1)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_DRIVER_LABEL'),
|
||||
icon = 'caret-up',
|
||||
onSelect = function()
|
||||
windowToggle(0, 0)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_REARLEFT_LABEL'),
|
||||
icon = 'caret-left',
|
||||
onSelect = function()
|
||||
windowToggle(3, 2)
|
||||
end
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
--[[
|
||||
█▀▀ ▄▀█ █▀█ █▀ █▀▀ ▄▀█ ▀█▀ █▀
|
||||
█▄▄ █▀█ █▀▄ ▄█ ██▄ █▀█ ░█░ ▄█
|
||||
]]--
|
||||
|
||||
lib.registerRadial({
|
||||
id = 'car_seats',
|
||||
items = {
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_REARRIGHT_LABEL'),
|
||||
icon = 'caret-right',
|
||||
onSelect = function()
|
||||
changeSeat(2)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_PASSENGER_LABEL'),
|
||||
icon = 'caret-up',
|
||||
onSelect = function()
|
||||
changeSeat(0)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_DRIVER_LABEL'),
|
||||
icon = 'caret-up',
|
||||
onSelect = function()
|
||||
changeSeat(-1)
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_REARLEFT_LABEL'),
|
||||
icon = 'caret-left',
|
||||
onSelect = function()
|
||||
changeSeat(1)
|
||||
end
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
--[[
|
||||
█░█ █▀▀ █░█ █ █▀▀ █░░ █▀▀ █▀▄▀█ █▀▀ █▄░█ █░█
|
||||
▀▄▀ ██▄ █▀█ █ █▄▄ █▄▄ ██▄ █░▀░█ ██▄ █░▀█ █▄█
|
||||
]]--
|
||||
|
||||
lib.registerRadial({
|
||||
id = 'vehicle_menu',
|
||||
items = {
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_VEHICLEENGINE_LABEL'),
|
||||
icon = 'power-off',
|
||||
onSelect = function()
|
||||
toggleEngine()
|
||||
end
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_VEHICLEDOORS_LABEL'),
|
||||
icon = 'door-closed',
|
||||
menu = 'car_doors'
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_VEHICLEWINDOWS_LABEL'),
|
||||
icon = 'window-maximize',
|
||||
menu = 'car_windows'
|
||||
},
|
||||
{
|
||||
label = Lang('VEHICLEKEYS_RADIAL_VEHICLECHAIRS_LABEL'),
|
||||
icon = 'chair',
|
||||
menu = 'car_seats'
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
--[[
|
||||
█░█ █▀▀ █░█ █ █▀▀ █░░ █▀▀ █▀▀ █░█ █▀▀ █▀▀ █▄▀
|
||||
▀▄▀ ██▄ █▀█ █ █▄▄ █▄▄ ██▄ █▄▄ █▀█ ██▄ █▄▄ █░█
|
||||
]]--
|
||||
|
||||
lib.onCache('vehicle', function(value)
|
||||
if value then
|
||||
lib.addRadialItem({
|
||||
{
|
||||
id = 'vehicle',
|
||||
label = Lang('VEHICLEKEYS_RADIAL_VEHICLE_LABEL'),
|
||||
icon = 'car',
|
||||
menu = 'vehicle_menu'
|
||||
}
|
||||
})
|
||||
lib.removeRadialItem('carkeys')
|
||||
else
|
||||
lib.removeRadialItem('vehicle')
|
||||
end
|
||||
end)
|
||||
|
||||
--[[
|
||||
█▀▀ █░█ █▄░█ █▀▀ ▀█▀ █ █▀█ █▄░█ █▀▄ █▀█ █▀█ █▀█ ▀█▀ █▀█ █▀▀ █▀▀ █░░ █▀▀
|
||||
█▀░ █▄█ █░▀█ █▄▄ ░█░ █ █▄█ █░▀█ █▄▀ █▄█ █▄█ █▀▄ ░█░ █▄█ █▄█ █▄█ █▄▄ ██▄
|
||||
]]--
|
||||
|
||||
function doorToggle(door)
|
||||
if GetVehicleDoorAngleRatio(cache.vehicle, door) > 0.0 then
|
||||
SetVehicleDoorShut(cache.vehicle, door, false, false)
|
||||
else
|
||||
SetVehicleDoorOpen(cache.vehicle, door, false, false)
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
█▀▀ █░█ █▄░█ █▀▀ ▀█▀ █ █▀█ █▄░█ █▀▀ █░█ ▄▀█ █▄░█ █▀▀ █▀▀ █▀ █▀▀ ▄▀█ ▀█▀
|
||||
█▀░ █▄█ █░▀█ █▄▄ ░█░ █ █▄█ █░▀█ █▄▄ █▀█ █▀█ █░▀█ █▄█ ██▄ ▄█ ██▄ █▀█ ░█░
|
||||
]]--
|
||||
|
||||
function changeSeat(seat)
|
||||
if IsVehicleSeatFree(cache.vehicle, seat) then
|
||||
lib.progressCircle({
|
||||
duration = 1000,
|
||||
position = 'bottom',
|
||||
label = Lang("VEHICLEKEYS_RADIAL_CHANGE_SEAT_PROGRESS"),
|
||||
useWhileDead = false,
|
||||
canCancel = true,
|
||||
disable = { car = true },
|
||||
anim = {
|
||||
dict = 'anim@veh@low@vigilante@front_ps@enter_exit',
|
||||
clip = 'shuffle_seat',
|
||||
flag = 16
|
||||
},
|
||||
})
|
||||
SetPedIntoVehicle(cache.ped, cache.vehicle, seat)
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
█▀▀ █░█ █▄░█ █▀▀ ▀█▀ █ █▀█ █▄░█ █░█░█ █ █▄░█ █▀▄ █▀█ █░█░█ ▀█▀ █▀█ █▀▀ █▀▀ █░░ █▀▀
|
||||
█▀░ █▄█ █░▀█ █▄▄ ░█░ █ █▄█ █░▀█ ▀▄▀▄▀ █ █░▀█ █▄▀ █▄█ ▀▄▀▄▀ ░█░ █▄█ █▄█ █▄█ █▄▄ ██▄
|
||||
]]--
|
||||
|
||||
local windows = { true, true, true, true }
|
||||
|
||||
function windowToggle(window, door)
|
||||
if GetIsDoorValid(cache.vehicle, door) and windows[window + 1] then
|
||||
RollDownWindow(cache.vehicle, window)
|
||||
windows[window + 1] = false
|
||||
else
|
||||
RollUpWindow(cache.vehicle, window)
|
||||
windows[window + 1] = true
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user