71 lines
1.9 KiB
Lua
71 lines
1.9 KiB
Lua
if Config.HouseScript ~= 'qb-houses' then
|
|
return
|
|
end
|
|
RPC.Register('codem-phone:home:getKeyHolders', function(source, keyholders)
|
|
if not keyholders then
|
|
return {
|
|
success = false,
|
|
message = "home.noKeyholders"
|
|
}
|
|
end
|
|
|
|
local KeyHoldersName = {}
|
|
for key, citizenid in ipairs(keyholders) do
|
|
local PlayerName = Core.Functions.GetName(citizenid)
|
|
if PlayerName then
|
|
KeyHoldersName[#KeyHoldersName + 1] = {
|
|
citizenid = citizenid,
|
|
name = PlayerName,
|
|
phoneNumber = GetPhoneNumberByIdentifier(citizenid)
|
|
}
|
|
end
|
|
end
|
|
|
|
return {
|
|
success = true,
|
|
keyholders = KeyHoldersName
|
|
}
|
|
end)
|
|
|
|
RPC.Register('codem-phone:home:getHouse', function(source)
|
|
local playerId = source
|
|
local identifier = Core.Functions.GetIdentifier(playerId)
|
|
|
|
if not identifier then
|
|
return { success = false }
|
|
end
|
|
|
|
local query = [[
|
|
SELECT
|
|
loc.id,
|
|
loc.coords,
|
|
loc.label,
|
|
loc.name,
|
|
loc.owned,
|
|
loc.tier,
|
|
house.citizenid,
|
|
house.identifier,
|
|
house.keyholders
|
|
FROM player_houses house
|
|
JOIN houselocations loc ON house.house = loc.name
|
|
WHERE house.citizenid = ?
|
|
]]
|
|
|
|
local result = MySQL.query.await(query, { identifier })
|
|
|
|
if result and #result > 0 then
|
|
for i, property in ipairs(result) do
|
|
if property.coords then
|
|
property.coords = json.decode(property.coords)
|
|
end
|
|
if property.keyholders then
|
|
property.keyholders = json.decode(property.keyholders)
|
|
end
|
|
end
|
|
end
|
|
return {
|
|
success = true,
|
|
houses = result
|
|
}
|
|
end)
|