diff --git a/client/main.lua b/client/main.lua index a239887..83ecc4c 100644 --- a/client/main.lua +++ b/client/main.lua @@ -40,7 +40,7 @@ local function robKeyLoop() isTakingKeys = true TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 1) - QBCore.Functions.Progressbar("steal_keys", Lang:t("progress.takekeys"), 2500, false, false, { + QBCore.Functions.Progressbar('steal_keys', Lang:t('progress.takekeys'), 2500, false, false, { disableMovement = false, disableCarMovement = true, disableMouse = false, @@ -66,7 +66,7 @@ local function robKeyLoop() end end end - -- Parked car logic + -- Parked car logic elseif driver == 0 and entering ~= lastPickedVehicle and not HasKeys(plate) and not isTakingKeys then QBCore.Functions.TriggerCallback('qb-vehiclekeys:server:checkPlayerOwned', function(playerOwned) if not playerOwned then @@ -77,7 +77,6 @@ local function robKeyLoop() end end end, plate) - end end @@ -91,7 +90,7 @@ local function robKeyLoop() sleep = 0 local vehiclePos = GetOffsetFromEntityInWorldCoords(vehicle, 0.0, 1.0, 0.5) - DrawText3D(vehiclePos.x, vehiclePos.y, vehiclePos.z, Lang:t("info.skeys")) + DrawText3D(vehiclePos.x, vehiclePos.y, vehiclePos.z, Lang:t('info.skeys')) SetVehicleEngineOn(vehicle, false, false, true) if IsControlJustPressed(0, 74) then @@ -133,7 +132,7 @@ end function isBlacklistedVehicle(vehicle) local isBlacklisted = false - for _,v in ipairs(Config.NoLockVehicles) do + for _, v in ipairs(Config.NoLockVehicles) do if joaat(v) == GetEntityModel(vehicle) then isBlacklisted = true break; @@ -144,17 +143,19 @@ function isBlacklistedVehicle(vehicle) end function addNoLockVehicles(model) - Config.NoLockVehicles[#Config.NoLockVehicles+1] = model + Config.NoLockVehicles[#Config.NoLockVehicles + 1] = model end + exports('addNoLockVehicles', addNoLockVehicles) function removeNoLockVehicles(model) - for k,v in pairs(Config.NoLockVehicles) do + for k, v in pairs(Config.NoLockVehicles) do if v == model then Config.NoLockVehicles[k] = nil end end end + exports('removeNoLockVehicles', removeNoLockVehicles) @@ -162,7 +163,7 @@ exports('removeNoLockVehicles', removeNoLockVehicles) ----------------------- ---- Client Events ---- ----------------------- -RegisterKeyMapping('togglelocks', Lang:t("info.tlock"), 'keyboard', 'L') +RegisterKeyMapping('togglelocks', Lang:t('info.tlock'), 'keyboard', 'L') RegisterCommand('togglelocks', function() local ped = PlayerPedId() if IsPedInAnyVehicle(ped, false) then @@ -176,7 +177,7 @@ RegisterCommand('togglelocks', function() end end) -RegisterKeyMapping('engine', Lang:t("info.engine"), 'keyboard', 'G') +RegisterKeyMapping('engine', Lang:t('info.engine'), 'keyboard', 'G') RegisterCommand('engine', function() local vehicle = GetVehicle() if vehicle and IsPedInVehicle(PlayerPedId(), vehicle) then @@ -235,12 +236,12 @@ RegisterNetEvent('qb-vehiclekeys:client:GiveKeys', function(id) if targetVehicle then local targetPlate = QBCore.Functions.GetPlate(targetVehicle) if HasKeys(targetPlate) then - if id and type(id) == "number" then -- Give keys to specific ID + if id and type(id) == 'number' then -- Give keys to specific ID GiveKeys(id, targetPlate) else if IsPedSittingInVehicle(PlayerPedId(), targetVehicle) then -- Give keys to everyone in vehicle local otherOccupants = GetOtherPlayersInVehicle(targetVehicle) - for p=1,#otherOccupants do + for p = 1, #otherOccupants do TriggerServerEvent('qb-vehiclekeys:server:GiveVehicleKeys', GetPlayerServerId(NetworkGetPlayerIndexFromPed(otherOccupants[p])), targetPlate) end else -- Give keys to closest player @@ -248,7 +249,7 @@ RegisterNetEvent('qb-vehiclekeys:client:GiveKeys', function(id) end end else - QBCore.Functions.Notify(Lang:t("notify.ydhk"), 'error') + QBCore.Functions.Notify(Lang:t('notify.ydhk'), 'error') end end end) @@ -257,12 +258,11 @@ RegisterNetEvent('QBCore:Client:EnteringVehicle', function() robKeyLoop() end) -RegisterNetEvent('weapons:client:DrawWeapon', function() +RegisterNetEvent('qb-weapons:client:DrawWeapon', function() Wait(2000) robKeyLoop() end) - RegisterNetEvent('lockpicks:UseLockpick', function(isAdvanced) local ped = PlayerPedId() local pos = GetEntityCoords(ped) @@ -284,21 +284,21 @@ RegisterNetEvent('lockpicks:UseLockpick', function(isAdvanced) if GetPedInVehicleSeat(vehicle, -1) == PlayerPedId() then TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', QBCore.Functions.GetPlate(vehicle)) else - QBCore.Functions.Notify(Lang:t("notify.vlockpick"), 'success') + QBCore.Functions.Notify(Lang:t('notify.vlockpick'), 'success') TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(vehicle), 1) end else TriggerServerEvent('hud:server:GainStress', math.random(1, 4)) - AttemptPoliceAlert("steal") + AttemptPoliceAlert('steal') end if isAdvanced then if chance <= Config.RemoveLockpickAdvanced then - TriggerServerEvent("qb-vehiclekeys:server:breakLockpick", "advancedlockpick") + TriggerServerEvent('qb-vehiclekeys:server:breakLockpick', 'advancedlockpick') end else if chance <= Config.RemoveLockpickNormal then - TriggerServerEvent("qb-vehiclekeys:server:breakLockpick", "lockpick") + TriggerServerEvent('qb-vehiclekeys:server:breakLockpick', 'lockpick') end end end) @@ -312,10 +312,11 @@ end) ---- Functions ---- ----------------------- function openmenu() - TriggerServerEvent("InteractSound_SV:PlayWithinDistance", 0.5, "key", 0.3) + TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 0.5, 'key', 0.3) SendNUIMessage({ casemenue = 'open' }) SetNuiFocus(true, true) end + function ToggleEngine(veh) if veh then local EngineOn = GetIsVehicleEngineRunning(veh) @@ -349,7 +350,7 @@ function ToggleVehicleLockswithoutnui(veh) loadAnimDict(Config.LockToggleAnimation.AnimDict) TaskPlayAnim(ped, Config.LockToggleAnimation.AnimDict, Config.LockToggleAnimation.Anim, 8.0, -8.0, -1, 52, 0, false, false, false) - TriggerServerEvent("InteractSound_SV:PlayWithinDistance", 5.0, Config.LockAnimSound, 0.5) + TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 5.0, Config.LockAnimSound, 0.5) end Citizen.CreateThread(function() @@ -357,7 +358,7 @@ function ToggleVehicleLockswithoutnui(veh) if IsEntityPlayingAnim(ped, Config.LockToggleAnimation.AnimDict, Config.LockToggleAnimation.Anim, 3) then StopAnimTask(ped, Config.LockToggleAnimation.AnimDict, Config.LockToggleAnimation.Anim, 8.0) end - TriggerServerEvent("InteractSound_SV:PlayWithinDistance", 5, Config.LockToggleSound, 0.3) + TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 5, Config.LockToggleSound, 0.3) if object ~= 0 and DoesEntityExist(object) then DeleteObject(object) @@ -368,10 +369,10 @@ function ToggleVehicleLockswithoutnui(veh) NetworkRequestControlOfEntity(veh) if vehLockStatus == 1 then TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 2) - QBCore.Functions.Notify(Lang:t("notify.vlock"), "primary") + QBCore.Functions.Notify(Lang:t('notify.vlock'), 'primary') else TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 1) - QBCore.Functions.Notify(Lang:t("notify.vunlock"), "success") + QBCore.Functions.Notify(Lang:t('notify.vunlock'), 'success') end SetVehicleLights(veh, 2) @@ -382,7 +383,7 @@ function ToggleVehicleLockswithoutnui(veh) Wait(300) ClearPedTasks(ped) else - QBCore.Functions.Notify(Lang:t("notify.ydhk"), 'error') + QBCore.Functions.Notify(Lang:t('notify.ydhk'), 'error') end else TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 1) @@ -395,7 +396,7 @@ function GiveKeys(id, plate) if distance < 1.5 and distance > 0.0 then TriggerServerEvent('qb-vehiclekeys:server:GiveVehicleKeys', id, plate) else - QBCore.Functions.Notify(Lang:t("notify.nonear"),'error') + QBCore.Functions.Notify(Lang:t('notify.nonear'), 'error') end end @@ -408,6 +409,7 @@ end function HasKeys(plate) return KeysList[plate] end + exports('HasKeys', HasKeys) function loadAnimDict(dict) @@ -416,6 +418,7 @@ function loadAnimDict(dict) Wait(0) end end + -- If in vehicle returns that, otherwise tries 3 different raycasts to get the vehicle they are facing. -- Raycasts picture: https://i.imgur.com/FRED0kV.png @@ -423,15 +426,12 @@ function GetVehicle() local ped = PlayerPedId() local pos = GetEntityCoords(ped) local vehicle = GetVehiclePedIsIn(PlayerPedId()) - while vehicle == 0 do vehicle = QBCore.Functions.GetClosestVehicle() if #(pos - GetEntityCoords(vehicle)) > Config.LockToggleDist then - QBCore.Functions.Notify(Lang:t("notify.vehclose"), "error") return end end - if not IsEntityAVehicle(vehicle) then vehicle = nil end return vehicle end @@ -447,7 +447,7 @@ function AreKeysJobShared(veh) for _, vehicle in pairs(v.vehicles) do if string.upper(vehicle) == string.upper(vehName) then if not HasKeys(vehPlate) then - TriggerServerEvent("qb-vehiclekeys:server:AcquireVehicleKeys", vehPlate) + TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', vehPlate) end return true end @@ -463,9 +463,9 @@ function ToggleVehicleLocks(veh) if HasKeys(QBCore.Functions.GetPlate(veh)) or AreKeysJobShared(veh) then local ped = PlayerPedId() local vehLockStatus = GetVehicleDoorLockStatus(veh) - loadAnimDict("anim@mp_player_intmenu@key_fob@") + loadAnimDict('anim@mp_player_intmenu@key_fob@') TaskPlayAnim(ped, 'anim@mp_player_intmenu@key_fob@', 'fob_click', 3.0, 3.0, -1, 49, 0, false, false, false) - TriggerServerEvent("InteractSound_SV:PlayWithinDistance", 5, "lock", 0.3) + TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 5, 'lock', 0.3) NetworkRequestControlOfEntity(veh) while NetworkGetEntityOwner(veh) ~= 128 do NetworkRequestControlOfEntity(veh) @@ -473,7 +473,7 @@ function ToggleVehicleLocks(veh) end if vehLockStatus == 1 then TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 2) - QBCore.Functions.Notify(Lang:t("notify.vlock"), "primary") + QBCore.Functions.Notify(Lang:t('notify.vlock'), 'primary') end SetVehicleLights(veh, 2) Wait(250) @@ -483,7 +483,7 @@ function ToggleVehicleLocks(veh) Wait(300) ClearPedTasks(ped) else - QBCore.Functions.Notify(Lang:t("notify.ydhk"), 'error') + QBCore.Functions.Notify(Lang:t('notify.ydhk'), 'error') end else TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 1) @@ -497,13 +497,13 @@ function ToggleVehicleunLocks(veh) if HasKeys(QBCore.Functions.GetPlate(veh)) or AreKeysJobShared(veh) then local ped = PlayerPedId() local vehLockStatus = GetVehicleDoorLockStatus(veh) - loadAnimDict("anim@mp_player_intmenu@key_fob@") + loadAnimDict('anim@mp_player_intmenu@key_fob@') TaskPlayAnim(ped, 'anim@mp_player_intmenu@key_fob@', 'fob_click', 3.0, 3.0, -1, 49, 0, false, false, false) - TriggerServerEvent("InteractSound_SV:PlayWithinDistance", 5, "lock", 0.3) + TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 5, 'lock', 0.3) NetworkRequestControlOfEntity(veh) if vehLockStatus == 2 then TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 1) - QBCore.Functions.Notify(Lang:t("notify.vunlock"), "success") + QBCore.Functions.Notify(Lang:t('notify.vunlock'), 'success') end SetVehicleLights(veh, 2) Wait(250) @@ -513,22 +513,23 @@ function ToggleVehicleunLocks(veh) Wait(300) ClearPedTasks(ped) else - QBCore.Functions.Notify(Lang:t("notify.ydhk"), 'error') + QBCore.Functions.Notify(Lang:t('notify.ydhk'), 'error') end else TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 1) end end end + function ToggleVehicleTrunk(veh) if veh then if not isBlacklistedVehicle(veh) then if HasKeys(QBCore.Functions.GetPlate(veh)) or AreKeysJobShared(veh) then local ped = PlayerPedId() local boot = GetEntityBoneIndexByName(GetVehiclePedIsIn(PlayerPedId(), false), 'boot') - loadAnimDict("anim@mp_player_intmenu@key_fob@") + loadAnimDict('anim@mp_player_intmenu@key_fob@') TaskPlayAnim(ped, 'anim@mp_player_intmenu@key_fob@', 'fob_click', 3.0, 3.0, -1, 49, 0, false, false, false) - TriggerServerEvent("InteractSound_SV:PlayWithinDistance", 5, "lock", 0.3) + TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 5, 'lock', 0.3) NetworkRequestControlOfEntity(veh) if boot ~= -1 or DoesEntityExist(veh) then if trunkclose == true then @@ -556,21 +557,22 @@ function ToggleVehicleTrunk(veh) trunkclose = true ClearPedTasks(ped) end - end + end else - QBCore.Functions.Notify(Lang:t("notify.ydhk"), 'error') + QBCore.Functions.Notify(Lang:t('notify.ydhk'), 'error') end else TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 1) end end end + function GetOtherPlayersInVehicle(vehicle) local otherPeds = {} - for seat=-1,GetVehicleModelNumberOfSeats(GetEntityModel(vehicle))-2 do + for seat = -1, GetVehicleModelNumberOfSeats(GetEntityModel(vehicle)) - 2 do local pedInSeat = GetPedInVehicleSeat(vehicle, seat) if IsPedAPlayer(pedInSeat) and pedInSeat ~= PlayerPedId() then - otherPeds[#otherPeds+1] = pedInSeat + otherPeds[#otherPeds + 1] = pedInSeat end end return otherPeds @@ -578,10 +580,10 @@ end function GetPedsInVehicle(vehicle) local otherPeds = {} - for seat=-1,GetVehicleModelNumberOfSeats(GetEntityModel(vehicle))-2 do + for seat = -1, GetVehicleModelNumberOfSeats(GetEntityModel(vehicle)) - 2 do local pedInSeat = GetPedInVehicleSeat(vehicle, seat) if not IsPedAPlayer(pedInSeat) and pedInSeat ~= 0 then - otherPeds[#otherPeds+1] = pedInSeat + otherPeds[#otherPeds + 1] = pedInSeat end end return otherPeds @@ -599,7 +601,6 @@ function IsBlacklistedWeapon() return false end - function Hotwire(vehicle, plate) local hotwireTime = math.random(Config.minHotwireTime, Config.maxHotwireTime) local ped = PlayerPedId() @@ -607,31 +608,31 @@ function Hotwire(vehicle, plate) SetVehicleAlarm(vehicle, true) SetVehicleAlarmTimeLeft(vehicle, hotwireTime) - QBCore.Functions.Progressbar("hotwire_vehicle", Lang:t("progress.hskeys"), hotwireTime, false, true, { + QBCore.Functions.Progressbar('hotwire_vehicle', Lang:t('progress.hskeys'), hotwireTime, false, true, { disableMovement = true, disableCarMovement = true, disableMouse = false, disableCombat = true }, { - animDict = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@", - anim = "machinic_loop_mechandplayer", + animDict = 'anim@amb@clubhouse@tutorial@bkr_tut_ig3@', + anim = 'machinic_loop_mechandplayer', flags = 16 }, {}, {}, function() -- Done - StopAnimTask(ped, "anim@amb@clubhouse@tutorial@bkr_tut_ig3@", "machinic_loop_mechandplayer", 1.0) + StopAnimTask(ped, 'anim@amb@clubhouse@tutorial@bkr_tut_ig3@', 'machinic_loop_mechandplayer', 1.0) TriggerServerEvent('hud:server:GainStress', math.random(1, 4)) if (math.random() <= Config.HotwireChance) then TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate) else - QBCore.Functions.Notify(Lang:t("notify.fvlockpick"), "error") + QBCore.Functions.Notify(Lang:t('notify.fvlockpick'), 'error') end Wait(Config.TimeBetweenHotwires) IsHotwiring = false end, function() -- Cancel - StopAnimTask(ped, "anim@amb@clubhouse@tutorial@bkr_tut_ig3@", "machinic_loop_mechandplayer", 1.0) + StopAnimTask(ped, 'anim@amb@clubhouse@tutorial@bkr_tut_ig3@', 'machinic_loop_mechandplayer', 1.0) IsHotwiring = false end) SetTimeout(10000, function() - AttemptPoliceAlert("steal") + AttemptPoliceAlert('steal') end) IsHotwiring = false end @@ -643,29 +644,29 @@ function CarjackVehicle(target) loadAnimDict('mp_am_hold_up') local vehicle = GetVehiclePedIsUsing(target) local occupants = GetPedsInVehicle(vehicle) - for p=1,#occupants do + for p = 1, #occupants do local ped = occupants[p] CreateThread(function() - TaskPlayAnim(ped, "mp_am_hold_up", "holdup_victim_20s", 8.0, -8.0, -1, 49, 0, false, false, false) + TaskPlayAnim(ped, 'mp_am_hold_up', 'holdup_victim_20s', 8.0, -8.0, -1, 49, 0, false, false, false) PlayPain(ped, 6, 0) FreezeEntityPosition(vehicle, true) SetVehicleUndriveable(vehicle, true) end) - Wait(math.random(200,500)) + Wait(math.random(200, 500)) end -- Cancel progress bar if: Ped dies during robbery, car gets too far away CreateThread(function() while isCarjacking do local distance = #(GetEntityCoords(PlayerPedId()) - GetEntityCoords(target)) if IsPedDeadOrDying(target) or distance > 7.5 then - TriggerEvent("progressbar:client:cancel") + TriggerEvent('progressbar:client:cancel') FreezeEntityPosition(vehicle, false) SetVehicleUndriveable(vehicle, false) end Wait(100) end end) - QBCore.Functions.Progressbar("rob_keys", Lang:t("progress.acjack"), Config.CarjackingTime, false, true, {}, {}, {}, {}, function() + QBCore.Functions.Progressbar('rob_keys', Lang:t('progress.acjack'), Config.CarjackingTime, false, true, {}, {}, {}, {}, function() local hasWeapon, weaponHash = GetCurrentPedWeapon(PlayerPedId(), true) if hasWeapon and isCarjacking then local carjackChance @@ -676,23 +677,23 @@ function CarjackVehicle(target) end if math.random() <= carjackChance then local plate = QBCore.Functions.GetPlate(vehicle) - for p=1,#occupants do - local ped = occupants[p] - CreateThread(function() + for p = 1, #occupants do + local ped = occupants[p] + CreateThread(function() FreezeEntityPosition(vehicle, false) SetVehicleUndriveable(vehicle, false) TaskLeaveVehicle(ped, vehicle, 0) PlayPain(ped, 6, 0) Wait(1250) ClearPedTasksImmediately(ped) - PlayPain(ped, math.random(7,8), 0) + PlayPain(ped, math.random(7, 8), 0) MakePedFlee(ped) end) end TriggerServerEvent('hud:server:GainStress', math.random(1, 4)) TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate) else - QBCore.Functions.Notify(Lang:t("notify.cjackfail"), "error") + QBCore.Functions.Notify(Lang:t('notify.cjackfail'), 'error') FreezeEntityPosition(vehicle, false) SetVehicleUndriveable(vehicle, false) MakePedFlee(target) @@ -700,7 +701,7 @@ function CarjackVehicle(target) end isCarjacking = false Wait(2000) - AttemptPoliceAlert("carjack") + AttemptPoliceAlert('carjack') Wait(Config.DelayBetweenCarjackings) canCarjack = true end @@ -719,7 +720,7 @@ function AttemptPoliceAlert(type) chance = Config.PoliceNightAlertChance end if math.random() <= chance then - TriggerServerEvent('police:server:policeAlert', Lang:t("info.palert") .. type) + TriggerServerEvent('police:server:policeAlert', Lang:t('info.palert') .. type) end AlertSend = true SetTimeout(Config.AlertCooldown, function() @@ -742,7 +743,7 @@ function DrawText3D(x, y, z, text) end SetTextProportional(1) SetTextColour(255, 255, 255, 215) - SetTextEntry("STRING") + SetTextEntry('STRING') SetTextCentre(true) AddTextComponentString(text) SetDrawOrigin(x, y, z, 0) @@ -756,25 +757,25 @@ end ---- NUICallback ---- ----------------------- RegisterNUICallback('closui', function() - SetNuiFocus(false, false) + SetNuiFocus(false, false) end) RegisterNUICallback('unlock', function() ToggleVehicleunLocks(GetVehicle()) - SetNuiFocus(false, false) + SetNuiFocus(false, false) end) RegisterNUICallback('lock', function() ToggleVehicleLocks(GetVehicle()) - SetNuiFocus(false, false) + SetNuiFocus(false, false) end) RegisterNUICallback('trunk', function() ToggleVehicleTrunk(GetVehicle()) - SetNuiFocus(false, false) + SetNuiFocus(false, false) end) RegisterNUICallback('engine', function() ToggleEngine(GetVehicle()) - SetNuiFocus(false, false) + SetNuiFocus(false, false) end) diff --git a/server/main.lua b/server/main.lua index 499837d..3b09a5c 100644 --- a/server/main.lua +++ b/server/main.lua @@ -18,16 +18,16 @@ RegisterNetEvent('qb-vehiclekeys:server:GiveVehicleKeys', function(receiver, pla local giver = source if HasKeys(giver, plate) then - TriggerClientEvent('QBCore:Notify', giver, Lang:t("notify.vgkeys"), 'success') + TriggerClientEvent('QBCore:Notify', giver, Lang:t('notify.vgkeys'), 'success') if type(receiver) == 'table' then - for _,r in ipairs(receiver) do + for _, r in ipairs(receiver) do GiveKeys(receiver[r], plate) end else GiveKeys(receiver, plate) end else - TriggerClientEvent('QBCore:Notify', giver, Lang:t("notify.ydhk"), "error") + TriggerClientEvent('QBCore:Notify', giver, Lang:t('notify.ydhk'), 'error') end end) @@ -39,9 +39,9 @@ end) RegisterNetEvent('qb-vehiclekeys:server:breakLockpick', function(itemName) local Player = QBCore.Functions.GetPlayer(source) if not Player then return end - if not (itemName == "lockpick" or itemName == "advancedlockpick") then return end - if Player.Functions.RemoveItem(itemName, 1) then - TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items[itemName], "remove") + if not (itemName == 'lockpick' or itemName == 'advancedlockpick') then return end + if exports['qb-inventory']:RemoveItem(source, itemName, 1, false, 'qb-vehiclekeys:server:breakLockpick') then + TriggerClientEvent('qb-inventory:client:ItemBox', source, QBCore.Shared.Items[itemName], 'remove') end end) @@ -60,7 +60,7 @@ QBCore.Functions.CreateCallback('qb-vehiclekeys:server:GetVehicleKeys', function if not Player then return end local citizenid = Player.PlayerData.citizenid local keysList = {} - for plate, citizenids in pairs (VehicleList) do + for plate, citizenids in pairs(VehicleList) do if citizenids[citizenid] then keysList[plate] = true end @@ -98,9 +98,10 @@ function GiveKeys(id, plate) end if not VehicleList[plate] then VehicleList[plate] = {} end VehicleList[plate][citizenid] = true - TriggerClientEvent('QBCore:Notify', id, Lang:t("notify.vgetkeys")) + TriggerClientEvent('QBCore:Notify', id, Lang:t('notify.vgetkeys')) TriggerClientEvent('qb-vehiclekeys:client:AddKeys', id, plate) end + exports('GiveKeys', GiveKeys) function RemoveKeys(id, plate) @@ -112,6 +113,7 @@ function RemoveKeys(id, plate) TriggerClientEvent('qb-vehiclekeys:client:RemoveKeys', id, plate) end + exports('RemoveKeys', RemoveKeys) function HasKeys(id, plate) @@ -121,26 +123,27 @@ function HasKeys(id, plate) end return false end + exports('HasKeys', HasKeys) -QBCore.Commands.Add("givekeys", Lang:t("addcom.givekeys"), {{name = Lang:t("addcom.givekeys_id"), help = Lang:t("addcom.givekeys_id_help")}}, false, function(source, args) - local src = source +QBCore.Commands.Add('givekeys', Lang:t('addcom.givekeys'), { { name = Lang:t('addcom.givekeys_id'), help = Lang:t('addcom.givekeys_id_help') } }, false, function(source, args) + local src = source TriggerClientEvent('qb-vehiclekeys:client:GiveKeys', src, tonumber(args[1])) end) -QBCore.Commands.Add("addkeys", Lang:t("addcom.addkeys"), {{name = Lang:t("addcom.addkeys_id"), help = Lang:t("addcom.addkeys_id_help")}, {name = Lang:t("addcom.addkeys_plate"), help = Lang:t("addcom.addkeys_plate_help")}}, true, function(source, args) - local src = source +QBCore.Commands.Add('addkeys', Lang:t('addcom.addkeys'), { { name = Lang:t('addcom.addkeys_id'), help = Lang:t('addcom.addkeys_id_help') }, { name = Lang:t('addcom.addkeys_plate'), help = Lang:t('addcom.addkeys_plate_help') } }, true, function(source, args) + local src = source if not args[1] or not args[2] then - TriggerClientEvent('QBCore:Notify', src, Lang:t("notify.fpid")) + TriggerClientEvent('QBCore:Notify', src, Lang:t('notify.fpid')) return end GiveKeys(tonumber(args[1]), args[2]) end, 'admin') -QBCore.Commands.Add("removekeys", Lang:t("addcom.rkeys"), {{name = Lang:t("addcom.rkeys_id"), help = Lang:t("addcom.rkeys_id_help")}, {name = Lang:t("addcom.rkeys_plate"), help = Lang:t("addcom.rkeys_plate_help")}}, true, function(source, args) - local src = source +QBCore.Commands.Add('removekeys', Lang:t('addcom.rkeys'), { { name = Lang:t('addcom.rkeys_id'), help = Lang:t('addcom.rkeys_id_help') }, { name = Lang:t('addcom.rkeys_plate'), help = Lang:t('addcom.rkeys_plate_help') } }, true, function(source, args) + local src = source if not args[1] or not args[2] then - TriggerClientEvent('QBCore:Notify', src, Lang:t("notify.fpid")) + TriggerClientEvent('QBCore:Notify', src, Lang:t('notify.fpid')) return end RemoveKeys(tonumber(args[1]), args[2])