Skip to content

Commit

Permalink
fix(client): compatibility with multi samejob garage
Browse files Browse the repository at this point in the history
  • Loading branch information
renzuzu committed Sep 20, 2021
1 parent dbdff00 commit 442a11c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
24 changes: 14 additions & 10 deletions client/client.lua
Expand Up @@ -23,11 +23,11 @@ Citizen.CreateThread(function()
Wait(1000)
coordcache = garagecoord
for k,v in pairs(garagecoord) do -- create job garage
if v.job ~= nil and jobgarages[v.job] == nil then
jobgarages[v.job] = {}
jobgarages[v.job].coord = vector3(v.garage_x,v.garage_y,v.garage_z)
jobgarages[v.job].id = v.garage
jobgarages[v.job].job = v.job
if v.job ~= nil and jobgarages[v.garage] == nil then
jobgarages[v.garage] = {}
jobgarages[v.garage].coord = vector3(v.garage_x,v.garage_y,v.garage_z)
jobgarages[v.garage].id = v.garage
jobgarages[v.garage].job = v.job
end
end
while ESX == nil do
Expand Down Expand Up @@ -1503,12 +1503,18 @@ AddEventHandler('renzu_garage:receive_vehicles', function(tb, vehdata)
if value.job == '' then
value.job = nil
end
if value.job ~= nil and jobgarages[value.job] == nil then -- fix incompatibility with vehicles with job column as a default from sql eg. civ fck!
local havejob = false
for k,v in pairs(jobgarages) do
if value.job ~= nil and v.job == value.job then
havejob = true
end
end
if value.job ~= nil and not havejob then -- fix incompatibility with vehicles with job column as a default from sql eg. civ fck!
value.job = nil
end
if value.garage_id ~= nil then -- fix blank job column, seperate the car to other non job garages
for k,v in pairs(jobgarages) do
if v.id == value.garage_id then
if v.job ~= nil and value.job ~= nil and v.job == value.job and v.id == value.garage_id and #(v.coord - GetEntityCoords(PlayerPedId())) < 20 then
value.job = v.job
end
end
Expand Down Expand Up @@ -1537,9 +1543,7 @@ AddEventHandler('renzu_garage:receive_vehicles', function(tb, vehdata)
type = value.type,
job = value.job ~= nil,
}
if jobgarages[value.job] ~= nil and #(GetEntityCoords(PlayerPedId()) - jobgarages[value.job].coord) < 50 or jobgarages[value.job] == nil then -- import only if jobgarage is not nil with coordinates checking or if jobgarage is nil
table.insert(OwnedVehicles['garage'], VTable)
end
table.insert(OwnedVehicles['garage'], VTable)
end
fetchdone = true
end)
Expand Down
16 changes: 9 additions & 7 deletions config.lua
Expand Up @@ -204,13 +204,15 @@ garagecoord = {
Dist = 10,
Blip = {color = 38, sprite = 662, scale = 0.6},
--413.64483642578,-1029.7556152344,29.349027633667,108.4100189209
garage_x = 413.20556640625,
garage_y = -1029.4292602539,
garage_z = 29.954322814941,
spawn_x = 432.20071411133,
spawn_y = -1015.4301757813,
spawn_z = 28.840564727783,
heading = 85.93824005127,
-- -32.752487182617,6522.2841796875,31.490859985352,250.73425292969
-- -34.871997833252,6534.1733398438,30.816513061523,133.7181854248
garage_x = -32.752487182617,
garage_y = 6522.28,
garage_z = 31.490,
spawn_x = -34.87,
spawn_y = 6534.17,
spawn_z = 30.8165,
heading = 133.71,
default_vehicle = { -- the vehicle listed here is like a goverment property and can be used for patrol etc. (this can be used in other garage, public or other job garage)
[1] = {model = 'police', name = 'Police', type = 'car', grade = 1}, -- minimum grade
[2] = {model = 'police2', name = 'Police 2', type = 'car', grade = 1}, -- minimum grade
Expand Down

0 comments on commit 442a11c

Please sign in to comment.