forked from qbcore-framework/qb-spawn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.lua
42 lines (41 loc) · 1.11 KB
/
server.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Citizen.CreateThread(function()
local HouseGarages = {}
local result = exports.ghmattimysql:executeSync('SELECT * FROM houselocations')
if result[1] ~= nil then
for k, v in pairs(result) do
local owned = false
if tonumber(v.owned) == 1 then
owned = true
end
local garage = v.garage ~= nil and json.decode(v.garage) or {}
Config.Houses[v.name] = {
coords = json.decode(v.coords),
owned = v.owned,
price = v.price,
locked = true,
adress = v.label,
tier = v.tier,
garage = garage,
decorations = {},
}
HouseGarages[v.name] = {
label = v.label,
takeVehicle = garage,
}
end
end
TriggerClientEvent("qb-garages:client:houseGarageConfig", -1, HouseGarages)
TriggerClientEvent("qb-houses:client:setHouseConfig", -1, Config.Houses)
end)
QBCore.Functions.CreateCallback('qb-spawn:server:getOwnedHouses', function(source, cb, cid)
if cid ~= nil then
local houses = exports.ghmattimysql:executeSync('SELECT * FROM player_houses WHERE citizenid=@citizenid', {['@citizenid'] = cid})
if houses[1] ~= nil then
cb(houses)
else
cb(nil)
end
else
cb(nil)
end
end)