kibra-housesv2

Current Version: 1.1.0

Setup

Step 1

First, you must set up the default homes.

Step 2

In your server's server.cfg file, issue a command to start kibra-housesv2 below your infrastructure's current mainfile (qbcore or es_extended).
start kibra-housesv2
start kibra-houses-map

Step 3

Open your server's database management panel (phpmyadmin or HeidiSQL). Insert the following sql code into your database.
CREATE TABLE `kibra_houses` (
`id` int(11) NOT NULL,
`owner` text DEFAULT NULL,
`keydata` text DEFAULT NULL,
`date` text DEFAULT NULL,
`status` int(11) DEFAULT 0,
`paymentinfo` int(11) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
ALTER TABLE `kibra_houses`
ADD PRIMARY KEY (`id`);
COMMIT;

Step 5

Open the app.js file of the inventory you use based on qb-inventory or qb-inventory. And then find the FormatItemInfo function. And inside this Function we will add a new condition to the if condition. As follows;
} else if (itemData.name == "housekeys") {
$(".item-info-title").html('<p>'+itemData.label+'</p>')
$(".item-info-description").html('<p><strong></strong><span>Daire No: ' + itemData.info.HouseId + '</span></p>');

Step 6

And add items named housekeys and doorlock to your item table.
['housekeys'] = {['name'] = 'housekeys', ['label'] = 'House Key', ['weight'] = 200, ['type'] = 'item', ['image'] = 'housekeys.png', ['unique'] = true, ['useable'] = true, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Ammo for Pistols'},
['doorlock'] = {['name'] = 'doorlock', ['label'] = 'Doorlock', ['weight'] = 200, ['type'] = 'item', ['image'] = 'doorlock.png', ['unique'] = true, ['useable'] = true, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Ammo for Pistols'},

Step 7

Open qb-phone/fxmanifest.lua and replace server_scripts with the following code block.
server_scripts {
'@oxmysql/lib/MySQL.lua',
'server/main.lua',
'@kibra-housesv2/shared.lua'
}

Step 8

And finally, open qb-phone/server/main.lua. And find the qb-phone:server:PayInvoice callback. And replace with the following lines of code.
QBCore.Functions.CreateCallback('qb-phone:server:PayInvoice', function(source, cb, society, amount, invoiceId, sendercitizenid)
local Invoices = {}
local Ply = QBCore.Functions.GetPlayer(source)
local SenderPly = QBCore.Functions.GetPlayerByCitizenId(sendercitizenid)
local invoiceMailData = {}
if SenderPly and Config.BillingCommissions[society] then
local commission = round(amount * Config.BillingCommissions[society])
SenderPly.Functions.AddMoney('bank', commission)
invoiceMailData = {
sender = 'Billing Department',
subject = 'Commission Received',
message = string.format('You received a commission check of $%s when %s %s paid a bill of $%s.', commission, Ply.PlayerData.charinfo.firstname, Ply.PlayerData.charinfo.lastname, amount)
}
elseif not SenderPly then
invoiceMailData = {
sender = 'Billing Department',
subject = 'Bill Paid',
message = string.format('%s %s paid a bill of $%s', Ply.PlayerData.charinfo.firstname, Ply.PlayerData.charinfo.lastname, amount)
}
end
if society == Cfg.HouseBillLabel then MySQL.Async.fetchAll('UPDATE kibra_houses SET date = @date WHERE id = @id', {["@date"] = os.time(), ["@id"] = sendercitizenid}) end
Ply.Functions.RemoveMoney('bank', amount, "paid-invoice")
TriggerEvent('qb-phone:server:sendNewMailToOffline', sendercitizenid, invoiceMailData)
TriggerEvent("qb-bossmenu:server:addAccountMoney", society, amount)
MySQL.Async.execute('DELETE FROM phone_invoices WHERE id = ?', {invoiceId})
local invoices = MySQL.Sync.fetchAll('SELECT * FROM phone_invoices WHERE citizenid = ?', {Ply.PlayerData.citizenid})
if invoices[1] ~= nil then
Invoices = invoices
end
cb(true, Invoices)
end)

Step 9

Don't forget to restart your server. Good Roles :)

How are houses duplicate ?

To duplicate houses, you must have a house map. This house map needs to be entered normally, not teleported. After adding the house map, we must add a new table like this inside the Config.Houses table. This painting actually means a new home.
{
Owner = nil,
KeyData = nil,
Rentable = false, -- Sets whether the house is rentable
Purchasable = true, -- Sets whether the house is Purchasable.
AutoLock = true, -- Puts Automatic Lock On The Door.
HouseCenterCoord = vector3(1301.5, -574.45, 71.73),
HouseManagementMenuCoord = vector3(1296.62, -577.8, 71.74),
RentPrice = 100, -- Rental Price of the House
HousePrice = 100000, -- Sale Price of the House
Features = { -- House Features
SwimmingPool = 0, -- Number of Swimming Pools
Garage = 1, -- If the garage system is open, the number of garages
Floor = 1, -- How Many Storey House
NumberRoom = 2 -- Number of Rooms in the House
},
ClotheWardrobe = vector3(1296.63, -577.38, 75.06),
HouseDoors = {
{DoorHash = 520341586, DoorCoord = vector3(1301.01, -574.51, 71.73)},
{DoorHash = 964838196, DoorCoord = vector3(1296.03, -590.19, 71.73)}
},
HouseStash = {
{StashCoord = vector3(1300.12, -586.04, 75.11), StashLock = true}
},
Garages = {
MaxSlotCar = 2,
GarageCoord = vector4(1290.96, -581.99, 71.74, 5.7),
GarageCarSpawnCoord = vector4(1295.04, -568.5, 70.84, 344.97),
GarageDist = 10.0
}
},
Add this line of code to the bottom row of the table. But, into the table :) No misunderstanding. Anyway, then change the coordinates of the new house in the table we added. And restart the script. And ready!