Skip to content

Commit

Permalink
Merge pull request #15 from gononono64/main
Browse files Browse the repository at this point in the history
(✂️ 🔨 🛠️) 🕵️ Evidence fix + feature
  • Loading branch information
GhzGarage authored May 28, 2023
2 parents d3bec2d + 386e5b8 commit 58c1ec9
Show file tree
Hide file tree
Showing 7 changed files with 382 additions and 525 deletions.
433 changes: 215 additions & 218 deletions client/evidence.lua

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/interactions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ RegisterNetEvent('police:client:GetCuffed', function(playerId, isSoftcuff)
TriggerServerEvent("police:server:SetHandcuffStatus", true)
ClearPedTasksImmediately(ped)
if Citizen.InvokeNative(0x8425C5F057012DAB,ped) ~= GetHashKey("WEAPON_UNARMED") then
SetCurrentPedWeapon(ped, `WEAPON_UNARMED`, true)
SetCurrentPedWeapon(ped, "WEAPON_UNARMED", true)
end
if not isSoftcuff then
cuffType = 16
Expand Down
2 changes: 1 addition & 1 deletion client/job.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ end
local function loadAnimDict(dict) -- interactions, job,
while (not HasAnimDictLoaded(dict)) do
RequestAnimDict(dict)
Citizen.Wait(10)
Wait(10)
end
end

Expand Down
120 changes: 0 additions & 120 deletions client/objects.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
-- Variables
local ObjectList = {}
local SpawnedSpikes = {}
local spikemodel = `P_ld_stinger_s`
local ClosestSpike = nil

-- Functions
local function GetClosestPoliceObject()
Expand All @@ -25,23 +22,6 @@ local function GetClosestPoliceObject()
return current, dist
end

function GetClosestSpike()
local pos = GetEntityCoords(PlayerPedId(), true)
local current = nil

for id, data in pairs(SpawnedSpikes) do
if current then
if #(pos - vector3(SpawnedSpikes[id].coords.x, SpawnedSpikes[id].coords.y, SpawnedSpikes[id].coords.z)) < dist then
current = id
end
else
dist = #(pos - vector3(SpawnedSpikes[id].coords.x, SpawnedSpikes[id].coords.y, SpawnedSpikes[id].coords.z))
current = id
end
end
ClosestSpike = current
end

local function DrawText3D(x, y, z, text)
SetTextScale(0.35, 0.35)
SetTextFont(4)
Expand Down Expand Up @@ -195,104 +175,4 @@ RegisterNetEvent('police:client:spawnObject', function(objectId, type, player)
object = spawnedObj,
coords = vector3(x, y, z - 0.3),
}
end)

RegisterNetEvent('police:client:SpawnSpikeStrip', function()
if #SpawnedSpikes + 1 < Config.MaxSpikes then
if PlayerJob.name == "police" and PlayerJob.onduty then
local spawnCoords = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 2.0, 0.0)
local spike = CreateObject(spikemodel, spawnCoords.x, spawnCoords.y, spawnCoords.z, 1, 1, 1)
local netid = NetworkGetNetworkIdFromEntity(spike)
SetNetworkIdExistsOnAllMachines(netid, true)
SetNetworkIdCanMigrate(netid, false)
SetEntityHeading(spike, GetEntityHeading(PlayerPedId()))
PlaceObjectOnGroundProperly(spike)
SpawnedSpikes[#SpawnedSpikes+1] = {
coords = vector3(spawnCoords.x, spawnCoords.y, spawnCoords.z),
netid = netid,
object = spike,
}
TriggerServerEvent('police:server:SyncSpikes', SpawnedSpikes)
end
else
exports['qbr-core']:Notify(9, Lang:t("error.no_spikestripe"), 5000, 0, 'mp_lobby_textures', 'cross', 'COLOR_WHITE')
end
end)

RegisterNetEvent('police:client:SyncSpikes', function(table)
SpawnedSpikes = table
end)

-- Threads
CreateThread(function()
while true do
if LocalPlayer.state.isLoggedIn then
GetClosestSpike()
end
Wait(500)
end
end)

CreateThread(function()
while true do
if LocalPlayer.state.isLoggedIn then
if ClosestSpike then
local tires = {
{bone = "wheel_lf", index = 0},
{bone = "wheel_rf", index = 1},
{bone = "wheel_lm", index = 2},
{bone = "wheel_rm", index = 3},
{bone = "wheel_lr", index = 4},
{bone = "wheel_rr", index = 5}
}

for a = 1, #tires do
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
local tirePos = GetWorldPositionOfEntityBone(vehicle, GetEntityBoneIndexByName(vehicle, tires[a].bone))
local spike = GetClosestObjectOfType(tirePos.x, tirePos.y, tirePos.z, 15.0, spikemodel, 1, 1, 1)
local spikePos = GetEntityCoords(spike, false)
local distance = #(tirePos - spikePos)

if distance < 1.8 then
if not IsVehicleTyreBurst(vehicle, tires[a].index, true) or IsVehicleTyreBurst(vehicle, tires[a].index, false) then
SetVehicleTyreBurst(vehicle, tires[a].index, false, 1000.0)
end
end
end
end
end

Wait(3)
end
end)

CreateThread(function()
while true do
local sleep = 1000
if LocalPlayer.state.isLoggedIn then
if ClosestSpike then
local ped = PlayerPedId()
local pos = GetEntityCoords(ped)
local dist = #(pos - SpawnedSpikes[ClosestSpike].coords)
if dist < 4 then
if not IsPedInAnyVehicle(PlayerPedId()) then
if PlayerJob.name == "police" and PlayerJob.onduty then
sleep = 0
DrawText3D(pos.x, pos.y, pos.z, Lang:t('info.delete_spike'))
if IsControlJustPressed(0, 38) then
NetworkRegisterEntityAsNetworked(SpawnedSpikes[ClosestSpike].object)
NetworkRequestControlOfEntity(SpawnedSpikes[ClosestSpike].object)
SetEntityAsMissionEntity(SpawnedSpikes[ClosestSpike].object)
DeleteEntity(SpawnedSpikes[ClosestSpike].object)
SpawnedSpikes[ClosestSpike] = nil
ClosestSpike = nil
TriggerServerEvent('police:server:SyncSpikes', SpawnedSpikes)
end
end
end
end
end
end
Wait(sleep)
end
end)
24 changes: 14 additions & 10 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@ Config = {}

Config.ShowBlips = true

Config.EvidenceJobs = {police = true}
Config.BlipsJobs = {police = true, ambulance = true}
Config.Law = {police = true, sheriff = true}

Config.EvidenceRange = 2.5

Config.Objects = {
["cone"] = {model = `prop_roadcone02a`, freeze = false},
["barrier"] = {model = `prop_barrier_work06a`, freeze = true},
["roadsign"] = {model = `prop_snow_sign_road_06g`, freeze = true},
["tent"] = {model = `prop_gazebo_03`, freeze = true},
["light"] = {model = `prop_worklight_03b`, freeze = true},
["cone"] = {model = "prop_roadcone02a", freeze = false},
["barrier"] = {model = "prop_barrier_work06a", freeze = true},
["roadsign"] = {model = "prop_snow_sign_road_06g", freeze = true},
["tent"] = {model = "prop_gazebo_03", freeze = true},
["light"] = {model = "prop_worklight_03b", freeze = true},
}

Config.MaxSpikes = 5

Config.HandCuffItem = 'handcuffs'

Config.LicenseRank = 2
Expand All @@ -33,14 +37,14 @@ Config.Locations = {
["armory"] = {
[1] = vector3(1361.16, -1305.7, 77.76),
[2] = vector3(2494.53, -1304.32, 48.95),
[3] = vector3(-764.86, -1272.4, 44.04),
[4] = vector3(-1814.01, -354.93, 164.65),
[3] = vector3(-764.86, -1272.43, 44.04),
[4] = vector3(-1813.93, -354.78, 164.65),
},
["evidence"] = {
[1] = vector3(1361.39, -1303.77, 77.77),
[2] = vector3(2494.44, -1313.39, 48.95),
[3] = vector3(-761.98, -1272.62, 44.05),
[4] = vector3(-1812.43, -355.87, 164.65)
[4] = vector3(-1807.17, -348.29, 164.66)
},
["stations"] = {
[1] = {label = "Sheriff", coords = vector3(1360.88, -1301.53, 77.77)},
Expand Down
30 changes: 15 additions & 15 deletions locales/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,29 +84,29 @@ local Translations = {
evidence_stash = 'Evidence Stash | %{value}',
slot = 'Slot no. (1,2,3)',
current_evidence = '%{value} | Drawer %{value2}',
on_duty = '[~g~E~s~] - Go on duty',
off_duty = '[~r~E~s~] - Go off duty',
onoff_duty = '~g~On~s~/~r~Off~s~ Duty',
on_duty = '[~COLOR_YELLOWSTRONG~E~q~] - Go on duty',
off_duty = '[~COLOR_YELLOWSTRONG~E~q~] - Go off duty',
onoff_duty = '~COLOR_YELLOWSTRONG~On~q~/~COLOR_YELLOWSTRONG~Off~q~ Duty',
stash = 'Stash %{value}',
delete_spike = '[~r~E~s~] Delete Spike Strip',
delete_spike = '[~COLOR_YELLOWSTRONG~E~q~] Delete Spike Strip',
close_camera = 'Close Camera',
bullet_casing = '[~g~G~s~] Bullet Casing %{value}',
bullet_casing = '[~COLOR_YELLOWSTRONG~G~q~] Bullet Casing %{value}',
casing = 'Bullet Casing',
blood = 'Blood',
blood_text = '[~g~G~s~] Blood %{value}',
fingerprint_text = '[~g~G~s~] Fingerprint',
blood_text = '[~COLOR_YELLOWSTRONG~G~q~] ~COLOR_RED~Blood %{value}',
fingerprint_text = '[~COLOR_YELLOWSTRONG~G~q~] Fingerprint',
fingerprint = 'Fingerprint',
store_heli = '[~g~E~s~] Store Helicopter',
take_heli = '[~g~E~s~] Take Helicopter',
impound_veh = '[~g~E~s~] - Impound Vehicle',
store_veh = '[~g~E~s~] - Store Vehicle',
store_heli = '[~COLOR_YELLOWSTRONG~E~q~] Store Helicopter',
take_heli = '[~COLOR_YELLOWSTRONG~E~q~] Take Helicopter',
impound_veh = '[~COLOR_YELLOWSTRONG~E~q~] - Impound Vehicle',
store_veh = '[~COLOR_YELLOWSTRONG~E~q~] - Store Vehicle',
armory = 'Armory',
enter_armory = '[~g~E~s~] Armory',
enter_armory = '[~COLOR_YELLOWSTRONG~E~q~] Armory',
finger_scan = 'Fingerprint Scanning',
scan_fingerprint = '[~g~E~s~] Scan Fingerprint',
scan_fingerprint = '[~COLOR_YELLOWSTRONG~E~q~] Scan Fingerprint',
trash = 'Trash',
trash_enter = '[~g~E~s~] Trash Bin',
stash_enter = '[~g~E~s~] Enter Locker',
trash_enter = '[~COLOR_YELLOWSTRONG~E~q~] Trash Bin',
stash_enter = '[~COLOR_YELLOWSTRONG~E~q~] Enter Locker',
target_location = 'The location of %{firstname} %{lastname} is marked on your map',
anklet_location = 'Anklet location',
new_call = 'New Call',
Expand Down
Loading

0 comments on commit 58c1ec9

Please sign in to comment.