jpr-phonesystem
bcs_housing/server/editable.lua
CreateThread(function()
RegisterServerCallback('jpr-phonesystem:server:GetPlayerHouses', function(source, cb, serie)
local src = source
local MyHouses = {}
local CitizenId = MySQL.query.await('SELECT * FROM jpr_phonesystem_base WHERE idtelemovel = ?', { serie })
if (CitizenId[1]) then
local result = exports.bcs_housing:GetOwnedHomeKeys(CitizenId[1].citizenid)
if result and result[1] then
for k, v in pairs(result) do
MyHouses[#MyHouses + 1] = {
name = v.identifier,
keyholders = {},
owner = CitizenId[1].citizenid,
price = v.price,
label = v.name,
tier = v.type,
garage = v.garage
}
if v.keys then
for identifier, data in pairs(v.keys) do
if identifier ~= 'amount' then
local userKeyHolderData = {
charinfo = {
firstname = data.name:match "(%a+)",
lastname = data.name:match " (%a+)"
},
citizenid = identifier,
name = data.name
}
MyHouses[k].keyholders[#MyHouses[k].keyholders + 1] = userKeyHolderData
end
end
end
end
SetTimeout(100, function()
cb(MyHouses)
end)
else
cb({})
end
else
cb({})
end
end)
RegisterServerCallback('jpr-phonesystem:server:GetHouseKeys', function(source, cb, serie)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local MyKeys = {}
local CitizenId = MySQL.query.await('SELECT * FROM jpr_phonesystem_base WHERE idtelemovel = ?', { serie })
if (CitizenId[1]) then
local result = exports.bcs_housing:GetHouseKeys(CitizenId[1])
for _, v in pairs(result) do
v.tier = v.type
MyKeys[#MyKeys + 1] = {
HouseData = v
}
end
end
cb(MyKeys)
end)
RegisterServerCallback('jpr-phonesystem:server:TransferCid', function(source, cb, NewCid, house)
local result = MySQL.query.await('SELECT * FROM players WHERE citizenid = ?', { NewCid })
if result[1] then
TriggerClientEvent('Housing:client:TransferHome', house.name)
cb(true)
else
cb(false)
end
end)
end)