Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates #7

Merged
merged 34 commits into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
cd37bcf
Update config.lua
DevX32 Jul 28, 2023
06cdadd
Update main.lua
DevX32 Sep 3, 2023
af52cf0
Update main.lua
DevX32 Sep 3, 2023
609abd7
Merge branch 'Qbox-project:main' into main
DevX32 Sep 3, 2023
4183b72
Update README.md
DevX32 Sep 3, 2023
fe44700
Update fxmanifest.lua
DevX32 Sep 3, 2023
1faa9b9
Update config.lua
DevX32 Sep 6, 2023
216bd61
Update config.lua
DevX32 Sep 6, 2023
d576af7
Update fxmanifest.lua
DevX32 Sep 6, 2023
59c69cf
Update config.lua
DevX32 Sep 12, 2023
c723935
Update README.md
DevX32 Sep 12, 2023
98a26e8
Update README.md
DevX32 Sep 12, 2023
3b84bfa
Merge branch 'Qbox-project:main' into main
DevX32 Sep 12, 2023
e6a3471
Update main.lua
DevX32 Sep 15, 2023
fbb73d2
Update main.lua
DevX32 Sep 15, 2023
b8b859b
Update main.lua
DevX32 Sep 15, 2023
e05e9dc
Update fxmanifest.lua
DevX32 Sep 15, 2023
1938f0c
Update main.lua
DevX32 Sep 15, 2023
5cb41cc
Update config.lua
DevX32 Sep 15, 2023
10531b6
Update main.lua
DevX32 Sep 15, 2023
5377b92
Update main.lua
DevX32 Sep 15, 2023
2feb072
Update main.lua
DevX32 Sep 15, 2023
908ad8f
Update main.lua
DevX32 Sep 15, 2023
e48a5d4
Update main.lua
DevX32 Sep 15, 2023
b797d0e
Update main.lua
DevX32 Sep 15, 2023
8ac1768
Update main.lua
DevX32 Sep 15, 2023
0216f01
Update fxmanifest.lua
DevX32 Sep 16, 2023
3a27553
Update main.lua
DevX32 Sep 16, 2023
cacc8ba
Update main.lua
DevX32 Sep 16, 2023
c666382
Update main.lua
DevX32 Sep 16, 2023
6f2329f
Update main.lua
DevX32 Sep 17, 2023
462e63a
correct callback
DevX32 Sep 17, 2023
1520fdd
Update server/main.lua
DevX32 Sep 17, 2023
27fd08c
Merge branch 'main' into main
Manason Sep 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 1)
TriggerServerEvent('qbx-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('qb-vehiclekeys:server:AcquireVehicleKeys', plate)
TriggerServerEvent('qbx-vehiclekeys:server:AcquireVehicleKeys', plate)
isTakingKeys = false
else
isTakingKeys = false
end
end
elseif Config.LockNPCDrivingCars then
TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 2)
TriggerServerEvent('qbx-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 2)
else
TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 1)
TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate)
TriggerServerEvent('qbx-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 1)
TriggerServerEvent('qbx-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('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 2)
TriggerServerEvent('qbx-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 2)
else
TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(entering), 1)
TriggerServerEvent('qbx-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("qb-vehiclekeys:client:ToggleEngine")
TriggerEvent("qbx-vehiclekeys:client:ToggleEngine")
end)

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

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

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

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

RegisterNetEvent('qb-vehiclekeys:client:ToggleEngine', function()
RegisterNetEvent('qbx-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('qb-vehiclekeys:client:ToggleEngine', function()
end
end)

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

if targetVehicle then
Expand All @@ -210,7 +210,7 @@ RegisterNetEvent('qb-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('qb-vehiclekeys:server:GiveVehicleKeys', GetPlayerServerId(NetworkGetPlayerIndexFromPed(otherOccupants[p])), targetPlate)
TriggerServerEvent('qbx-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('qb-vehiclekeys:server:AcquireVehicleKeys', plate)
TriggerServerEvent('qbx-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('qb-vehiclekeys:server:GiveVehicleKeys', id, plate)
TriggerServerEvent('qbx-vehiclekeys:server:GiveVehicleKeys', id, plate)
else
QBCore.Functions.Notify(Lang:t("notify.not_near"), 'error')
end
end

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

NetworkRequestControlOfEntity(veh)
if vehLockStatus == 1 then
TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 2)
TriggerServerEvent('qbx-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 2)
QBCore.Functions.Notify(Lang:t("notify.vehicle_locked"), 'inform')
else
TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 1)
TriggerServerEvent('qbx-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('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 1)
TriggerServerEvent('qbx-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('qb-vehiclekeys:server:AcquireVehicleKeys', QBCore.Functions.GetPlate(vehicle))
TriggerServerEvent('qbx-vehiclekeys:server:AcquireVehicleKeys', QBCore.Functions.GetPlate(vehicle))
else
QBCore.Functions.Notify(Lang:t("notify.vehicle_lockedpick"), 'success')
TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(vehicle), 1)
TriggerServerEvent('qbx-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("qb-vehiclekeys:server:breakLockpick", "advancedlockpick")
TriggerServerEvent("qbx-vehiclekeys:server:breakLockpick", "advancedlockpick")
end
else
if chance <= Config.RemoveLockpickNormal then
TriggerServerEvent("qb-vehiclekeys:server:breakLockpick", "lockpick")
TriggerServerEvent("qbx-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('qb-vehiclekeys:server:AcquireVehicleKeys', plate)
TriggerServerEvent('qbx-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('qb-vehiclekeys:server:AcquireVehicleKeys', plate)
TriggerServerEvent('qbx-vehiclekeys:server:AcquireVehicleKeys', plate)
else
QBCore.Functions.Notify(Lang:t("notify.carjack_failed"), 'error')
MakePedFlee(target)
Expand Down
13 changes: 11 additions & 2 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,17 @@ Config.LockNPCParkedCars = true -- Lock state for NPC parked cars [true = locked
-- Lockpick Settings
Config.RemoveLockpickNormal = 0.5 -- Chance to remove lockpick on fail
Config.RemoveLockpickAdvanced = 0.2 -- Chance to remove advanced lockpick on fail
Config.LockPickDoorEvent = function() -- This function is called when a player attempts to lock pick a vehicle
TriggerEvent('qb-lockpick:client:openLockpick', LockpickFinishCallback)
Config.LockPickDoorEvent = function()
lib.requestAnimDict('veh@break_in@0h@p_m_one@')
TaskPlayAnim(cache.ped, 'veh@break_in@0h@p_m_one@', "low_force_entry_ds", 3.0, 3.0, -1, 16, 0, 0, 0, 0)
local success = lib.skillCheck({'easy', 'easy', {areaSize = 60, speedMultiplier = 1}, 'medium'}, {'1', '2', '3', '4'})
if success then
LockpickFinishCallback(success)
DevX32 marked this conversation as resolved.
Show resolved Hide resolved
else
AttemptPoliceAlert('carjack')
TriggerServerEvent('hud:server:GainStress', math.random(1, 4))
lib.notify({ description = 'You failed to lockpick.', type = 'error' })
end
end

-- Carjack Settings
Expand Down
6 changes: 3 additions & 3 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
fx_version 'cerulean'
game 'gta5'

description 'https://github.com/QBCore-Remastered'
version '1.0.1'
description 'https://github.com/Qbox-project'
version '1.0.0'

shared_scripts {
'@qb-core/shared/locale.lua',
'@qbx-core/shared/locale.lua',
'locales/en.lua',
'locales/*.lua',
'@ox_lib/init.lua',
Expand Down
18 changes: 9 additions & 9 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ local VehicleList = {}

-- Event to give keys. receiver can either be a single id, or a table of ids.
-- Must already have keys to the vehicle, trigger the event from the server, or pass forcegive paramter as true.
RegisterNetEvent('qb-vehiclekeys:server:GiveVehicleKeys', function(receiver, plate)
RegisterNetEvent('qbx-vehiclekeys:server:GiveVehicleKeys', function(receiver, plate)
local giver = source

if HasKeys(giver, plate) then
Expand All @@ -31,12 +31,12 @@ RegisterNetEvent('qb-vehiclekeys:server:GiveVehicleKeys', function(receiver, pla
end
end)

RegisterNetEvent('qb-vehiclekeys:server:AcquireVehicleKeys', function(plate)
RegisterNetEvent('qbx-vehiclekeys:server:AcquireVehicleKeys', function(plate)
local src = source
GiveKeys(src, plate)
end)

RegisterNetEvent('qb-vehiclekeys:server:breakLockpick', function(itemName)
RegisterNetEvent('qbx-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
Expand All @@ -45,19 +45,19 @@ RegisterNetEvent('qb-vehiclekeys:server:breakLockpick', function(itemName)
end
end)

RegisterNetEvent('qb-vehiclekeys:server:setVehLockState', function(vehNetId, state)
RegisterNetEvent('qbx-vehiclekeys:server:setVehLockState', function(vehNetId, state)
SetVehicleDoorsLocked(NetworkGetEntityFromNetworkId(vehNetId), state)
end)

QBCore.Functions.CreateCallback('qb-vehiclekeys:server:GetVehicleKeys', function(source, cb)
lib.callback.register('qbx-vehiclekeys:server:GetVehicleKeys', function(source)
local citizenid = QBCore.Functions.GetPlayer(source).PlayerData.citizenid
local keysList = {}
for plate, citizenids in pairs (VehicleList) do
if citizenids[citizenid] then
keysList[plate] = true
end
end
cb(keysList)
return keysList
end)

-----------------------
Expand All @@ -70,7 +70,7 @@ function GiveKeys(id, plate)
VehicleList[plate][citizenid] = true

TriggerClientEvent('QBCore:Notify', id, Lang:t('notify.keys_taken'))
TriggerClientEvent('qb-vehiclekeys:client:AddKeys', id, plate)
TriggerClientEvent('qbx-vehiclekeys:client:AddKeys', id, plate)
end

function RemoveKeys(id, plate)
Expand All @@ -80,7 +80,7 @@ function RemoveKeys(id, plate)
VehicleList[plate][citizenid] = nil
end

TriggerClientEvent('qb-vehiclekeys:client:RemoveKeys', id, plate)
TriggerClientEvent('qbx-vehiclekeys:client:RemoveKeys', id, plate)
end

function HasKeys(id, plate)
Expand All @@ -104,7 +104,7 @@ lib.addCommand('givekeys', {
restricted = false,
}, function (source, args)
local src = source
TriggerClientEvent('qb-vehiclekeys:client:GiveKeys', src, args.id)
TriggerClientEvent('qbx-vehiclekeys:client:GiveKeys', src, args.id)
end)

lib.addCommand('addkeys', {
Expand Down
Loading