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 32 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
66 changes: 29 additions & 37 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ CreateThread(function()
local sleep = 1000
if LocalPlayer.state.isLoggedIn then
sleep = 100

local ped = cache.ped
local entering = GetVehiclePedIsTryingToEnter(ped)
local entering = GetVehiclePedIsTryingToEnter(cache.ped)
local carIsImmune = false
if entering ~= 0 and not isBlacklistedVehicle(entering) then
sleep = 2000
Expand Down Expand Up @@ -82,9 +80,9 @@ CreateThread(function()
end

-- Hotwiring while in vehicle, also keeps engine off for vehicles you don't own keys to
if IsPedInAnyVehicle(ped, false) and not IsHotwiring then
if cache.vehicle and not IsHotwiring then
sleep = 1000
local vehicle = GetVehiclePedIsIn(ped)
local vehicle = cache.vehicle
local plate = QBCore.Functions.GetPlate(vehicle)

if GetPedInVehicleSeat(vehicle, -1) == cache.ped and not HasKeys(plate) and not isBlacklistedVehicle(vehicle) and not AreKeysJobShared(vehicle) then
Expand Down Expand Up @@ -112,7 +110,7 @@ CreateThread(function()
end
end
if GetPedInVehicleSeat(targetveh, -1) == target and not IsBlacklistedWeapon() then
local pos = GetEntityCoords(ped, true)
local pos = GetEntityCoords(cache.ped, true)
local targetpos = GetEntityCoords(target, true)
if #(pos - targetpos) < 5.0 and not carIsImmune then
CarjackVehicle(target)
Expand All @@ -129,7 +127,7 @@ end)
function isBlacklistedVehicle(vehicle)
local isBlacklisted = false
for _,v in ipairs(Config.NoLockVehicles) do
if GetHashKey(v) == GetEntityModel(vehicle) then
if joaat(v) == GetEntityModel(vehicle) then
isBlacklisted = true
break;
end
Expand Down Expand Up @@ -171,9 +169,8 @@ end)
RegisterNetEvent('qb-vehiclekeys:client:AddKeys', function(plate)
KeysList[plate] = true

local ped = cache.ped
if IsPedInAnyVehicle(ped, false) then
local vehicle = GetVehiclePedIsIn(ped)
if cache.vehicle then
local vehicle = cache.vehicle
local vehicleplate = QBCore.Functions.GetPlate(vehicle)

if plate == vehicleplate then
Expand Down Expand Up @@ -246,8 +243,8 @@ function GiveKeys(id, plate)
end

function GetKeys()
QBCore.Functions.TriggerCallback('qb-vehiclekeys:server:GetVehicleKeys', function(keysList)
KeysList = keysList
lib.callback('qbx-vehiclekeys:server:getVehicleKeys', function(keysList)
KeysList = keysList
end)
end

Expand All @@ -256,17 +253,9 @@ function HasKeys(plate)
end
exports('HasKeys', HasKeys)

function loadAnimDict(dict)
while (not HasAnimDictLoaded(dict)) do
RequestAnimDict(dict)
Wait(0)
end
end

function GetVehicleInDirection(coordFromOffset, coordToOffset)
local ped = cache.ped
local coordFrom = GetOffsetFromEntityInWorldCoords(ped, coordFromOffset.x, coordFromOffset.y, coordFromOffset.z)
local coordTo = GetOffsetFromEntityInWorldCoords(ped, coordToOffset.x, coordToOffset.y, coordToOffset.z)
local coordFrom = GetOffsetFromEntityInWorldCoords(cache.ped, coordFromOffset.x, coordFromOffset.y, coordFromOffset.z)
local coordTo = GetOffsetFromEntityInWorldCoords(cache.ped, coordToOffset.x, coordToOffset.y, coordToOffset.z)

local rayHandle = CastRayPointToPoint(coordFrom.x, coordFrom.y, coordFrom.z, coordTo.x, coordTo.y, coordTo.z, 10, cache.ped, 0)
local _, _, _, _, vehicle = GetShapeTestResult(rayHandle)
Expand Down Expand Up @@ -319,14 +308,10 @@ function ToggleVehicleLocks(veh)
if veh then
if not isBlacklistedVehicle(veh) then
if HasKeys(QBCore.Functions.GetPlate(veh)) or AreKeysJobShared(veh) then
local ped = cache.ped
local vehLockStatus = GetVehicleDoorLockStatus(veh)

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)

lib.requestAnimDict("anim@mp_player_intmenu@key_fob@")
TaskPlayAnim(cache.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)

NetworkRequestControlOfEntity(veh)
if vehLockStatus == 1 then
TriggerServerEvent('qb-vehiclekeys:server:setVehLockState', NetworkGetNetworkIdFromEntity(veh), 2)
Expand All @@ -342,7 +327,7 @@ function ToggleVehicleLocks(veh)
Wait(200)
SetVehicleLights(veh, 0)
Wait(300)
ClearPedTasks(ped)
ClearPedTasks(cache.ped)
else
QBCore.Functions.Notify(Lang:t("notify.no_keys"), 'error')
end
Expand Down Expand Up @@ -387,8 +372,7 @@ function IsBlacklistedWeapon()
end

function LockpickDoor(isAdvanced)
local ped = cache.ped
local pos = GetEntityCoords(ped)
local pos = GetEntityCoords(cache.ped)
local vehicle = QBCore.Functions.GetClosestVehicle()

if vehicle == nil or vehicle == 0 then return end
Expand All @@ -397,8 +381,17 @@ function LockpickDoor(isAdvanced)
if GetVehicleDoorLockStatus(vehicle) <= 0 then return end

usingAdvanced = isAdvanced
Config.LockPickDoorEvent()
end
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)
else
AttemptPoliceAlert('carjack')
TriggerServerEvent('hud:server:GainStress', math.random(1, 4))
TriggerEvent('QBCore:Notify', 'You failed to lockpick.', 'error')
end
end

function LockpickFinishCallback(success)
local vehicle = QBCore.Functions.GetClosestVehicle()
Expand Down Expand Up @@ -433,7 +426,6 @@ end

function Hotwire(vehicle, plate)
local hotwireTime = math.random(Config.minHotwireTime, Config.maxHotwireTime)
local ped = cache.ped
IsHotwiring = true

SetVehicleAlarm(vehicle, true)
Expand All @@ -454,7 +446,7 @@ function Hotwire(vehicle, plate)
combat = true,
}
}) then
StopAnimTask(ped, "anim@amb@clubhouse@tutorial@bkr_tut_ig3@", "machinic_loop_mechandplayer", 1.0)
StopAnimTask(cache.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)
else
Expand All @@ -464,7 +456,7 @@ function Hotwire(vehicle, plate)
Wait(Config.TimeBetweenHotwires)
IsHotwiring = false
else
StopAnimTask(ped, "anim@amb@clubhouse@tutorial@bkr_tut_ig3@", "machinic_loop_mechandplayer", 1.0)
StopAnimTask(cache.ped, "anim@amb@clubhouse@tutorial@bkr_tut_ig3@", "machinic_loop_mechandplayer", 1.0)
IsHotwiring = false
end
SetTimeout(10000, function()
Expand All @@ -477,7 +469,7 @@ function CarjackVehicle(target)
if not Config.CarJackEnable then return end
isCarjacking = true
canCarjack = false
loadAnimDict('mp_am_hold_up')
lib.requestAnimDict('mp_am_hold_up')
local vehicle = GetVehiclePedIsUsing(target)
local occupants = GetPedsInVehicle(vehicle)
for p=1,#occupants do
Expand Down
3 changes: 0 additions & 3 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ 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)
end

-- Carjack Settings
Config.CarJackEnable = true -- True allows for the ability to car jack peds.
Expand Down
10 changes: 4 additions & 6 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
fx_version 'cerulean'
game 'gta5'

description 'https://github.com/QBCore-Remastered'
version '1.0.1'
lua54 'yes'
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',
'config.lua',
}
client_script 'client/main.lua'
server_script 'server/main.lua'

lua54 'yes'
4 changes: 2 additions & 2 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ RegisterNetEvent('qb-vehiclekeys:server:setVehLockState', function(vehNetId, sta
SetVehicleDoorsLocked(NetworkGetEntityFromNetworkId(vehNetId), state)
end)

QBCore.Functions.CreateCallback('qb-vehiclekeys:server:GetVehicleKeys', function(source, cb)
lib.callback.register('qb-vehiclekeys:server:GetVehicleKeys', function(source)
DevX32 marked this conversation as resolved.
Show resolved Hide resolved
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 Down
Loading