From d09a0dc32ab18b5947a7c8dbbe642564d75ade51 Mon Sep 17 00:00:00 2001 From: doku <89829952+dokusaido@users.noreply.github.com> Date: Sun, 17 Mar 2024 14:35:02 +1100 Subject: [PATCH 1/5] Update --- README.md | 6 ++++++ client/main.lua | 25 +++++++++++++++++++++++++ server/main.lua | 24 ++++++++++++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/README.md b/README.md index deae6f74..cd83f953 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,9 @@ Police Job for QB-Core Framework :police_officer: - /takedrivinglicense - Takes the driving license from nearby player. - /takedna [id] - Takes a DNA sample from the player. +# Additional Commands +- /pboat - Spawn a police boat + ## Installation ### Manual - Download the script and put it in the `[qb]` directory. @@ -103,6 +106,8 @@ ensure qb-policejob ``` ## Configuration +
+ Click to Expand - Config ``` Config = {} @@ -497,3 +502,4 @@ Config.Items = { -- Items to be displayed on Armory } } ``` +
diff --git a/client/main.lua b/client/main.lua index f24724ae..0d3950ca 100644 --- a/client/main.lua +++ b/client/main.lua @@ -221,3 +221,28 @@ CreateThread(function() EndTextCommandSetBlipName(blip) end end) + +-- Spawn Police Boat +RegisterNetEvent('policejob:checkProximityToWater', function() + local playerPed = PlayerPedId() + local playerCoords = GetEntityCoords(playerPed) + if IsEntityInWater(playerPed) then + TriggerServerEvent('policejob:spawnVehicleForPlayer') + else + QBCore.Functions.Notify('You need to be near water to do this.', 'error') + end +end) + +RegisterNetEvent('policejob:pboat', function(vehicleName) + local playerPed = PlayerPedId() + local pos = GetEntityCoords(playerPed) + local vehicleHash = GetHashKey(vehicleName) + + RequestModel(vehicleHash) + while not HasModelLoaded(vehicleHash) do + Wait(1) + end + + local spawnedVehicle = CreateVehicle(vehicleHash, pos.x, pos.y, pos.z, GetEntityHeading(playerPed), true, false) + SetPedIntoVehicle(playerPed, spawnedVehicle, -1) +end) \ No newline at end of file diff --git a/server/main.lua b/server/main.lua index 3dcfccf7..76b3b2b7 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1110,3 +1110,27 @@ CreateThread(function() UpdateBlips() end end) + +-- Police Boat Spawn +TriggerEvent('QBCore:GetObject', function(obj) QBCore = obj end) + +RegisterCommand('pboat', function(source, args, rawCommand) + local Player = QBCore.Functions.GetPlayer(source) + if Player then + local playerJob = Player.PlayerData.job.name + if playerJob == 'police' then + TriggerClientEvent('policejob:checkProximityToWater', source) + else + TriggerClientEvent('QBCore:Notify', source, 'You do not have the required job to do this.', 'error') + end + end +end, false) + +RegisterNetEvent('policejob:spawnVehicleForPlayer', function() + local source = source + local Player = QBCore.Functions.GetPlayer(source) + if Player then + -- Replace 'vehicleNameHere' with the code/name of the vehicle you want to spawn + TriggerClientEvent('policejob:pboat', source, 'dinghy4') + end +end) \ No newline at end of file From 330c3c7ba2aeb279334ad993f6ce2cbb430eeb76 Mon Sep 17 00:00:00 2001 From: doku <89829952+dokusaido@users.noreply.github.com> Date: Sun, 17 Mar 2024 14:51:33 +1100 Subject: [PATCH 2/5] Update main.lua --- server/main.lua | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/server/main.lua b/server/main.lua index 76b3b2b7..ae55fbdf 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1115,22 +1115,22 @@ end) TriggerEvent('QBCore:GetObject', function(obj) QBCore = obj end) RegisterCommand('pboat', function(source, args, rawCommand) - local Player = QBCore.Functions.GetPlayer(source) - if Player then - local playerJob = Player.PlayerData.job.name - if playerJob == 'police' then - TriggerClientEvent('policejob:checkProximityToWater', source) - else - TriggerClientEvent('QBCore:Notify', source, 'You do not have the required job to do this.', 'error') - end + local boatModel = args[1] -- Assuming the first argument is the boat model + if boatModel and Config.AllowedBoats[boatModel] then + TriggerClientEvent('policejob:checkProximityToWater', source, boatModel) + else + TriggerClientEvent('QBCore:Notify', source, 'Invalid or unspecified boat model.', 'error') end end, false) -RegisterNetEvent('policejob:spawnVehicleForPlayer', function() +RegisterNetEvent('policejob:spawnVehicleForPlayer', function(vehicleName) local source = source local Player = QBCore.Functions.GetPlayer(source) if Player then - -- Replace 'vehicleNameHere' with the code/name of the vehicle you want to spawn - TriggerClientEvent('policejob:pboat', source, 'dinghy4') + if Config.AllowedBoats[vehicleName] then + TriggerClientEvent('policejob:pboat', source, vehicleName) + else + TriggerClientEvent('QBCore:Notify', source, 'This boat cannot be spawned.', 'error') + end end end) \ No newline at end of file From 81e6e17983746d17e4ee59ac8e510ff9d8a685cc Mon Sep 17 00:00:00 2001 From: doku <89829952+dokusaido@users.noreply.github.com> Date: Sun, 17 Mar 2024 14:55:57 +1100 Subject: [PATCH 3/5] Update --- config.lua | 2 +- server/main.lua | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/config.lua b/config.lua index 35c5f4e3..17919917 100644 --- a/config.lua +++ b/config.lua @@ -248,4 +248,4 @@ Config.VehicleSettings = { }, ['livery'] = 1, } -} +} \ No newline at end of file diff --git a/server/main.lua b/server/main.lua index ae55fbdf..6662c1e6 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1115,22 +1115,21 @@ end) TriggerEvent('QBCore:GetObject', function(obj) QBCore = obj end) RegisterCommand('pboat', function(source, args, rawCommand) - local boatModel = args[1] -- Assuming the first argument is the boat model - if boatModel and Config.AllowedBoats[boatModel] then - TriggerClientEvent('policejob:checkProximityToWater', source, boatModel) - else - TriggerClientEvent('QBCore:Notify', source, 'Invalid or unspecified boat model.', 'error') + local Player = QBCore.Functions.GetPlayer(source) + if Player then + local playerJob = Player.PlayerData.job.name + if playerJob == 'police' then + TriggerClientEvent('policejob:checkProximityToWater', source) + else + TriggerClientEvent('QBCore:Notify', source, 'You do not have the required job to do this.', 'error') + end end end, false) -RegisterNetEvent('policejob:spawnVehicleForPlayer', function(vehicleName) +RegisterNetEvent('policejob:spawnVehicleForPlayer', function() local source = source local Player = QBCore.Functions.GetPlayer(source) if Player then - if Config.AllowedBoats[vehicleName] then - TriggerClientEvent('policejob:pboat', source, vehicleName) - else - TriggerClientEvent('QBCore:Notify', source, 'This boat cannot be spawned.', 'error') - end + TriggerClientEvent('policejob:pboat', source, 'predator') -- Replace 'predator' with the name of the vehicle you want to spawn end end) \ No newline at end of file From 105a6df5721accf17370eda6d803ed4c8c0c7087 Mon Sep 17 00:00:00 2001 From: doku <89829952+dokusaido@users.noreply.github.com> Date: Sun, 17 Mar 2024 15:48:18 +1100 Subject: [PATCH 4/5] Update README.md --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index cd83f953..c2941e02 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,17 @@ Police Job for QB-Core Framework :police_officer: # Additional Commands - /pboat - Spawn a police boat +
+ Click to Expand - Add to '''qb-radialmenu/config.lua''' +{ + id = 'pboat', + title = 'Police Boat', + icon = 'ship', + type = 'command', + event = 'pboat', + shouldClose = true + }, +
## Installation ### Manual From 82689745e2d31e9f70450192dd0a2a75d6c1ee16 Mon Sep 17 00:00:00 2001 From: doku <89829952+dokusaido@users.noreply.github.com> Date: Sun, 17 Mar 2024 15:49:41 +1100 Subject: [PATCH 5/5] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c2941e02..aa8efbf0 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,8 @@ Police Job for QB-Core Framework :police_officer: # Additional Commands - /pboat - Spawn a police boat
- Click to Expand - Add to '''qb-radialmenu/config.lua''' + Click to Expand - Add to qb-radialmenu/config.lua +''' { id = 'pboat', title = 'Police Boat', @@ -105,6 +106,7 @@ Police Job for QB-Core Framework :police_officer: event = 'pboat', shouldClose = true }, +'''
## Installation