Skip to content

Commit

Permalink
dedupe of charges
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeSzymkowicz committed Apr 20, 2022
1 parent 358c65d commit f98af9c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,27 @@ QBCore.Functions.CreateCallback('mdt:server:GetProfileData', function(source, cb

if Config.PoliceJobs[JobName] then
local convictions = GetConvictions({person.cid})
person.convictions = {}
person.convictions2 = {}
local convCount = 1
if next(convictions) then
for _, conv in pairs(convictions) do
if conv.warrant then person.warrant = true end
local charges = json.decode(conv.charges)
for _, charge in pairs(charges) do
person.convictions[convCount] = charge
person.convictions2[convCount] = charge
convCount = convCount + 1
end
end
end
local hash = {}
person.convictions = {}

for _,v in ipairs(person.convictions2) do
if (not hash[v]) then
person.convictions[#person.convictions+1] = v -- found this dedupe method on sourceforge somewhere, copy+pasta dev, needs to be refined later
hash[v] = true
end
end
local vehicles = GetPlayerVehicles(person.cid)

if vehicles then
Expand Down

0 comments on commit f98af9c

Please sign in to comment.