Skip to content

Commit

Permalink
Modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
quasar-scripts committed Jul 30, 2023
1 parent 8ce7cab commit 86f92bf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
14 changes: 10 additions & 4 deletions client/main.lua
Expand Up @@ -529,7 +529,7 @@ local function SetClosestHouse()
end, ClosestHouse)
end
end
TriggerEvent('qb-garages:client:setHouseGarage', ClosestHouse, HasHouseKey)
TriggerEvent('advancedgarages:SetShellGarageData', ClosestHouse, HasHouseKey)
end

local function setHouseLocations()
Expand Down Expand Up @@ -1091,7 +1091,8 @@ AddEventHandler('QBCore:Client:OnPlayerLoaded', function()
TriggerEvent('qb-houses:client:setupHouseBlips')
if Config.UnownedBlips then TriggerEvent('qb-houses:client:setupHouseBlips2') end
Wait(100)
TriggerEvent('qb-garages:client:setHouseGarage', ClosestHouse, HasHouseKey)
TriggerEvent('advancedgarages:SetShellGarageData', ClosestHouse, HasHouseKey)
-- TriggerEvent('qb-garages:client:setHouseGarage', ClosestHouse, HasHouseKey)
TriggerServerEvent("qb-houses:server:setHouses")
end)

Expand Down Expand Up @@ -1139,7 +1140,11 @@ RegisterNetEvent('qb-houses:client:addGarage', function()
z = pos.z,
w = heading,
}
TriggerServerEvent('qb-houses:server:addGarage', ClosestHouse, coords)
local shellId = exports['qs-advancedgarages']:ShowCaseOfGarageShell(nil, 'vehicle')
local shellData = {
shell = shellId,
}
TriggerServerEvent('qb-houses:server:addGarage', ClosestHouse, coords, shellData)
else
QBCore.Functions.Notify(Lang:t("error.no_house"), "error")
end
Expand Down Expand Up @@ -1218,6 +1223,7 @@ end)
RegisterNetEvent('qb-houses:client:refreshHouse', function()
Wait(100)
SetClosestHouse()
TriggerEvent('advancedgarages:SetShellGarageData', ClosestHouse, HasHouseKey)
end)

RegisterNetEvent('qb-houses:client:SpawnInApartment', function(house)
Expand Down Expand Up @@ -1547,7 +1553,7 @@ CreateThread(function ()
TriggerEvent('qb-houses:client:setupHouseBlips2')
end
Wait(wait)
TriggerEvent('qb-garages:client:setHouseGarage', ClosestHouse, HasHouseKey)
TriggerEvent('advancedgarages:SetShellGarageData', ClosestHouse, HasHouseKey)
TriggerServerEvent("qb-houses:server:setHouses")

while true do
Expand Down
1 change: 1 addition & 0 deletions qb-houses.sql
Expand Up @@ -7,6 +7,7 @@ CREATE TABLE IF NOT EXISTS `houselocations` (
`price` int(11) DEFAULT NULL,
`tier` tinyint(4) DEFAULT NULL,
`garage` text NOT NULL DEFAULT '{"y":0,"x":0,"h":0,"z":0}',
`garageShell` text DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
Expand Down
20 changes: 14 additions & 6 deletions server/main.lua
Expand Up @@ -6,7 +6,7 @@ local housesLoaded = false

-- Threads

CreateThread(function()
local function UpdateHouse()
local HouseGarages = {}
local result = MySQL.query.await('SELECT * FROM houselocations', {})
if result[1] then
Expand All @@ -28,14 +28,22 @@ CreateThread(function()
}
HouseGarages[v.name] = {
label = v.label,
takeVehicle = garage
takeVehicle = garage,
shell = v.garageShell and json.decode(v.garageShell) or {}
}
end
end
TriggerClientEvent("qb-garages:client:houseGarageConfig", -1, HouseGarages)
TriggerClientEvent("qb-houses:client:setHouseConfig", -1, Config.Houses)
TriggerClientEvent('advancedgarages:GetShellGarageData', -1, HouseGarages)
TriggerClientEvent('qb-houses:client:setHouseConfig', -1, Config.Houses)
end

RegisterNetEvent('QBCore:Server:PlayerLoaded')
AddEventHandler('QBCore:Server:PlayerLoaded', function(playerData)
UpdateHouse()
end)

CreateThread(UpdateHouse)

CreateThread(function()
while true do
if not housesLoaded then
Expand Down Expand Up @@ -196,14 +204,14 @@ RegisterNetEvent('qb-houses:server:addNewHouse', function(street, coords, price,
TriggerEvent('qb-log:server:CreateLog', 'house', Lang:t("log.house_created"), 'green', Lang:t("log.house_address", {label = label, price = price, tier = tier, agent = GetPlayerName(src)}))
end)

RegisterNetEvent('qb-houses:server:addGarage', function(house, coords)
RegisterNetEvent('qb-houses:server:addGarage', function(house, coords, shellData)
local src = source
MySQL.update('UPDATE houselocations SET garage = ? WHERE name = ?', {json.encode(coords), house})
local garageInfo = {
label = Config.Houses[house].adress,
takeVehicle = coords
}
TriggerClientEvent("qb-garages:client:addHouseGarage", -1, house, garageInfo)
TriggerClientEvent('advancedgarages:AddShellGarage', -1, house, garageInfo)
TriggerClientEvent('QBCore:Notify', src, Lang:t("info.added_garage", {value = garageInfo.label}))
end)

Expand Down

0 comments on commit 86f92bf

Please sign in to comment.