Open Functions
The script has files open for configure garages/inventory/wardrobes
Open Client (client/open_functions.lua)
--Add your inventory statsh here
function OpenStorage(entity, houseId, furniId, isExterior, hasKey)
if Config.ox_inventory then
if isExterior then
if hasKey then
Config.FrameworkFunctions.TriggerCallback("artz_housing:registerStash", function()
exports.ox_inventory:openInventory('stash', "ExtHouse_" .. houseId .. "_" .. furniId)
end, "ExtHouse_" .. houseId .. "_" .. furniId)
end
else
Config.FrameworkFunctions.TriggerCallback("artz_housing:registerStash", function()
exports.ox_inventory:openInventory('stash', "House_" .. houseId .. "_" .. furniId)
end, "House_" .. houseId .. "_" .. furniId)
end
else
if isExterior then
if hasKey then
TriggerServerEvent("inventory:server:OpenInventory", "stash", "ExtHouse_" .. houseId .. "_" .. furniId, {
maxweight = 20000,
slots = 30,
})
TriggerEvent("inventory:client:SetCurrentStash", "ExtHouse_" .. houseId .. "_" .. furniId)
end
else
TriggerServerEvent("inventory:server:OpenInventory", "stash", "House_" .. houseId .. "_" .. furniId, {
maxweight = 20000,
slots = 30,
})
TriggerEvent("inventory:client:SetCurrentStash", "House_" .. houseId .. "_" .. furniId)
end
end
end
--Add your outfit menu script here
function OpenWardrobe(entity, houseId, furniId, isExterior, hasKey)
if isExterior then
if hasKey then
TriggerEvent('qb-clothing:client:openOutfitMenu')
end
else
TriggerEvent('qb-clothing:client:openOutfitMenu')
end
end
-- Core init Functions IMPORTANT: ADD THIS IF YOU HAVE ANY CUSTOM LOAD CHARACTER EVENT
-- QBCORE
RegisterNetEvent("QBCore:Client:OnPlayerLoaded",function()
LoadInitFunctions()
end)
-- ESX
RegisterNetEvent('esx:playerLoaded',function(xPlayer, isNew, skin)
LoadInitFunctions()
end)
-- Citizen.CreateThread(function () -- ONLY IF YOU NEED RESTART SCRIPT EVENLY
-- Wait(10000)
-- LoadInitFunctions()
-- end)
Garage Client (client/garage.lua)
local CD = false
function SaveInGarage(hid)
if not CD then
--Cooldown
CD = true
Citizen.SetTimeout(500, function ()
CD = false
end)
--Cooldown END
local veh = GetVehiclePedIsIn(PlayerPedId())
local props = Config.FrameworkFunctions.GetVehicleProperties(veh)
Config.FrameworkFunctions.TriggerCallback('artz_housing:SaveCarInHouse', function(data)
if data then
end
end, hid, props, NetworkGetNetworkIdFromEntity(veh))
end
end
function SpawnOutGarage(hid, props, pos)
if not IsModelInCdimage(props.model) then return end
RequestModel(props.model)
while not HasModelLoaded(props.model) do
Wait(0)
end
local _vehicle = CreateVehicle(props.model, pos.xyz, pos.w, true, false)
SetModelAsNoLongerNeeded(props.model)
Config.FrameworkFunctions.SetVehicleProperties(_vehicle, props)
TaskWarpPedIntoVehicle(PlayerPedId(), _vehicle, -1)
TriggerServerEvent("artz_housing:removeFromGarage", hid, props.plate)
end
function OpenGarage(hid, cars, pos)
local _options = {}
for k, v in pairs(cars) do
table.insert(_options, {
title = GetDisplayNameFromVehicleModel(v.model) .. " - " .. v.plate,
description = 'Press to spawn | The bar is the fuel level',
icon = 'car',
onSelect = function()
SpawnOutGarage(hid, v, pos)
end,
progress = Round(v.fuelLevel)
})
end
lib.registerContext({
id = 'property_menu_garage_spawn',
title = 'House Garage ' .. hid,
options = _options
})
lib.showContext("property_menu_garage_spawn")
end
Open Server (server/open_functions.lua)
-- Example for open creation menu
RegisterCommand("createproperty", function (src, args, raw)
if Config.FrameworkFunctions.GetJob(src).job == Config.JobProperty or Config.FrameworkFunctions.HasPermissions(src) then
TriggerClientEvent("artz_housing:createProperty", src)
end
end, false)
-- Used if ox_inventory active
if Config.ox_inventory then
Config.FrameworkFunctions.CreateCallback("artz_housing:registerStash", function(source, cb, name)
exports.ox_inventory:RegisterStash(name, name, 200, 500000)
cb(true)
end)
end
-- You can use for logs or another actions
function OnBuyHouse(source, houseId)
--Executed when a player buy a house
end
function OnCreateHouse(source, houseId)
--Executed when a player buy a house
end
Garage Server (server/garage.lua)
If you need check is owner vehicle un-comment the lines commented and remove if true then
Config.FrameworkFunctions.CreateCallback('artz_housing:SaveCarInHouse', function(source, cb, hid, props, netid)
local PlayerIdentifier = Config.FrameworkFunctions.GetIdentifier(source)
local Plate = props.plate
local Ent = NetworkGetEntityFromNetworkId(netid)
--local Db = MySQL.Sync.fetchAll('SELECT owner FROM player_vehicles WHERE plate = @plate', {["@plate"] = Plate })
--if Db[1] and Db[1].citizenid == PlayerIdentifier then
if true then
HouseSaveCar(hid, Plate, props) -- Save in DB and Sync with others players
DeleteVeh(Ent)
cb(true)
else
Config.FrameworkFunctions.Notify(Lang["not_vehicle_owner"], source)
cb(false)
end
end)
function DeleteVeh(ent)
Citizen.CreateThread(function ()
Citizen.Wait(400)
if DoesEntityExist(ent) then
DeleteEntity(ent)
end
end)
end
Last updated