Skip to content

Commit

Permalink
Update main.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
DevX32 authored Sep 15, 2023
1 parent 3b84bfa commit e6a3471
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ CreateThread(function()
if not isTakingKeys then
isTakingKeys = true

TriggerServerEvent('qbx-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 1)
TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 1)
if lib.progressCircle({
duration = 2500,
label = Lang:t("progress.takekeys"),
Expand All @@ -51,17 +51,17 @@ CreateThread(function()
car = true,
},
}) then
TriggerServerEvent('qbx-vehiclekeys:server:AcquireVehicleKeys', plate)
TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate)
isTakingKeys = false
else
isTakingKeys = false
end
end
elseif Config.LockNPCDrivingCars then
TriggerServerEvent('qbx-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 2)
TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 2)
else
TriggerServerEvent('qbx-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 1)
TriggerServerEvent('qbx-vehiclekeys:server:AcquireVehicleKeys', plate)
TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 1)
TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate)

--Make passengers flee
local pedsInVehicle = GetPedsInVehicle(entering)
Expand All @@ -74,9 +74,9 @@ CreateThread(function()
-- Parked car logic
elseif driver == 0 and entering ~= lastPickedVehicle and not HasKeys(plate) and not isTakingKeys then
if Config.LockNPCParkedCars then
TriggerServerEvent('qbx-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 2)
TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 2)
else
TriggerServerEvent('qbx-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 1)
TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 1)
end
end
end
Expand Down Expand Up @@ -149,7 +149,7 @@ end)

RegisterKeyMapping('engine', Lang:t("info.engine"), 'keyboard', 'G')
RegisterCommand('engine', function()
TriggerEvent("qbx-vehiclekeys:client:ToggleEngine")
TriggerEvent("qb-vehiclekeys:client:ToggleEngine")
end)

AddEventHandler('onResourceStart', function(resourceName)
Expand All @@ -168,7 +168,7 @@ RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
KeysList = {}
end)

RegisterNetEvent('qbx-vehiclekeys:client:AddKeys', function(plate)
RegisterNetEvent('qb-vehiclekeys:client:AddKeys', function(plate)
KeysList[plate] = true

local ped = cache.ped
Expand All @@ -182,11 +182,11 @@ RegisterNetEvent('qbx-vehiclekeys:client:AddKeys', function(plate)
end
end)

RegisterNetEvent('qbx-vehiclekeys:client:RemoveKeys', function(plate)
RegisterNetEvent('qb-vehiclekeys:client:RemoveKeys', function(plate)
KeysList[plate] = nil
end)

RegisterNetEvent('qbx-vehiclekeys:client:ToggleEngine', function()
RegisterNetEvent('qb-vehiclekeys:client:ToggleEngine', function()
local EngineOn = GetIsVehicleEngineRunning(GetVehiclePedIsIn(cache.ped))
local vehicle = GetVehiclePedIsIn(cache.ped, true)
if HasKeys(QBCore.Functions.GetPlate(vehicle)) then
Expand All @@ -198,7 +198,7 @@ RegisterNetEvent('qbx-vehiclekeys:client:ToggleEngine', function()
end
end)

RegisterNetEvent('qbx-vehiclekeys:client:GiveKeys', function(id)
RegisterNetEvent('qb-vehiclekeys:client:GiveKeys', function(id)
local targetVehicle = GetVehicle()

if targetVehicle then
Expand All @@ -210,7 +210,7 @@ RegisterNetEvent('qbx-vehiclekeys:client:GiveKeys', function(id)
if IsPedSittingInVehicle(cache.ped, targetVehicle) then -- Give keys to everyone in vehicle
local otherOccupants = GetOtherPlayersInVehicle(targetVehicle)
for p=1,#otherOccupants do
TriggerServerEvent('qbx-vehiclekeys:server:GiveVehicleKeys', GetPlayerServerId(NetworkGetPlayerIndexFromPed(otherOccupants[p])), targetPlate)
TriggerServerEvent('qb-vehiclekeys:server:GiveVehicleKeys', GetPlayerServerId(NetworkGetPlayerIndexFromPed(otherOccupants[p])), targetPlate)
end
else -- Give keys to closest player
GiveKeys(GetPlayerServerId(QBCore.Functions.GetClosestPlayer()), targetPlate)
Expand All @@ -228,7 +228,7 @@ end)

-- Backwards Compatibility ONLY -- Remove at some point --
RegisterNetEvent('vehiclekeys:client:SetOwner', function(plate)
TriggerServerEvent('qbx-vehiclekeys:server:AcquireVehicleKeys', plate)
TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate)
end)
-- Backwards Compatibility ONLY -- Remove at some point --

Expand All @@ -239,14 +239,14 @@ end)
function GiveKeys(id, plate)
local distance = #(GetEntityCoords(cache.ped) - GetEntityCoords(GetPlayerPed(GetPlayerFromServerId(id))))
if distance < 1.5 and distance > 0.0 then
TriggerServerEvent('qbx-vehiclekeys:server:GiveVehicleKeys', id, plate)
TriggerServerEvent('qb-vehiclekeys:server:GiveVehicleKeys', id, plate)
else
QBCore.Functions.Notify(Lang:t("notify.not_near"), 'error')
end
end

function GetKeys()
lib.callback('qbx-vehiclekeys:server:GetVehicleKeys', function(keysList)
lib.callback('qb-vehiclekeys:server:GetVehicleKeys', function(keysList)
KeysList = keysList
end)
end
Expand Down Expand Up @@ -305,7 +305,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("qbx-vehiclekeys:server:AcquireVehicleKeys", vehPlate)
TriggerServerEvent("qb-vehiclekeys:server:AcquireVehicleKeys", vehPlate)
end
return true
end
Expand All @@ -329,10 +329,10 @@ function ToggleVehicleLocks(veh)

NetworkRequestControlOfEntity(veh)
if vehLockStatus == 1 then
TriggerServerEvent('qbx-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 2)
TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 2)
QBCore.Functions.Notify(Lang:t("notify.vehicle_locked"), 'inform')
else
TriggerServerEvent('qbx-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 1)
TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 1)
QBCore.Functions.Notify(Lang:t("notify.vehicle_unlocked"), 'inform')
end

Expand All @@ -347,7 +347,7 @@ function ToggleVehicleLocks(veh)
QBCore.Functions.Notify(Lang:t("notify.no_keys"), 'error')
end
else
TriggerServerEvent('qbx-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 1)
TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 1)
end
end
end
Expand Down Expand Up @@ -409,10 +409,10 @@ function LockpickFinishCallback(success)
lastPickedVehicle = vehicle

if GetPedInVehicleSeat(vehicle, -1) == cache.ped then
TriggerServerEvent('qbx-vehiclekeys:server:AcquireVehicleKeys', QBCore.Functions.GetPlate(vehicle))
TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', QBCore.Functions.GetPlate(vehicle))
else
QBCore.Functions.Notify(Lang:t("notify.vehicle_lockedpick"), 'success')
TriggerServerEvent('qbx-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(vehicle), 1)
TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(vehicle), 1)
end

else
Expand All @@ -422,11 +422,11 @@ function LockpickFinishCallback(success)

if usingAdvanced then
if chance <= Config.RemoveLockpickAdvanced then
TriggerServerEvent("qbx-vehiclekeys:server:breakLockpick", "advancedlockpick")
TriggerServerEvent("qb-vehiclekeys:server:breakLockpick", "advancedlockpick")
end
else
if chance <= Config.RemoveLockpickNormal then
TriggerServerEvent("qbx-vehiclekeys:server:breakLockpick", "lockpick")
TriggerServerEvent("qb-vehiclekeys:server:breakLockpick", "lockpick")
end
end
end
Expand Down Expand Up @@ -456,7 +456,7 @@ function Hotwire(vehicle, plate)
}) then
StopAnimTask(ped, "anim@amb@clubhouse@tutorial@bkr_tut_ig3@", "machinic_loop_mechandplayer", 1.0)
if (math.random() <= Config.HotwireChance) then
TriggerServerEvent('qbx-vehiclekeys:server:AcquireVehicleKeys', plate)
TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate)
else
TriggerServerEvent('hud:server:GainStress', math.random(1, 4))
QBCore.Functions.Notify(Lang:t("notify.failed_lockedpick"), 'error')
Expand Down Expand Up @@ -531,7 +531,7 @@ function CarjackVehicle(target)
end)
end
TriggerServerEvent('hud:server:GainStress', math.random(1, 4))
TriggerServerEvent('qbx-vehiclekeys:server:AcquireVehicleKeys', plate)
TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate)
else
QBCore.Functions.Notify(Lang:t("notify.carjack_failed"), 'error')
MakePedFlee(target)
Expand Down

0 comments on commit e6a3471

Please sign in to comment.