๐ Stash Houses
Introduction
This script will add the ability for players to rent and manage their very own stash houses, giving your players the ability to hide their supplies without having to buy another house.
This script is written to work with QBCore and Zap Hosting ESX Pack
Features of Stash Houses:
Unlimited Stash Houses
Stash Houses can be created by either staff only or by set jobs (editable in config)
Stash House Interiors are created automatically using objects
Storable Cash (max amount editable within config)
Cash Objects depending on amount stored for added immersion.
Separate Storage Inventories for each object with a storage inventory.
Ability to furnish the stash house with a list of furniture (editable within config)
Ability for Police to Raid Stash Houses (Jobs editable within config)
Stash Management UI to manage rent and keys
Editable functions file which means this can be converted to any framework.
Installation
Download the power_stashhouses from Keymaster
Run the .sql file in your database.
Add the files to your resources folder
Ensure that the resource file will start (either ensure your resource in the server.cfg or inside a folder which is started on server start)
Edit the config file to your needs
Restart your server
Configuration
Select the tab below for your framework to see the configuration options available.
--========================--
--== Framework Settings ==--
--========================--
-- Enable Support for QBCore
enableQBCore = true
QBCoreResourceName = 'qb-core'
-- QBCore will use qb-inventory or lj-inventory by default.
-- This system also supports ox_inventory
QBInventory = 'qb-inventory'
-- Enable QB-Target Support - (False = Using OX_Target, True = Using QB-Target)
enableQBTarget = true
-- Enable Support for ESX
enableESX = false
-- ESX Inventory
-- Compatible with 'ox_inventory' and 'chezza-inventory' and 'mf_inventory'
esxInventory = 'ox_inventory'
-- config to toggleProps for Renewed-Weaponscarry on enter and exit.
renewedWeapons = false
--======================--
--== Command Settings ==--
--======================--
-- The command that is used to create a new stash house.
addStashCommand = 'createstash'
-- This will allow only staff to create a new stash house, if this is disabled then it will use the job whitleist below.
addStashStaffOnly = true
-- The jobs required to use the addStashCommand, if the staff only setting is disabled.
addStashJobs = {
['realestate'] = {2, 3, 4}, -- This will only allow rel estate agents with grade 2, 3 or 4.
['realestateagent'] = {1, 2, 3},
}
-- Max cash that can be stored in a stash house.
maxStoredCash = 500000
Editable files
functions.lua
Inventory Compatibility
If you would like to edit the inventory functions, you can edit them in the functions.lua file. Default functions are as follows:
function openStorage(stashId, storageAmount)
if enableQBCore then
if QBInventory == 'ox_inventory' then
exports.ox_inventory:openInventory('stash', {id = stashId, owner = false})
else
TriggerServerEvent("inventory:server:OpenInventory", "stash", stashId, {maxweight = storageAmount})
TriggerEvent("inventory:client:SetCurrentStash", stashId)
end
end
if enableESX then
if esxInventory == 'mf-inventory' then
exports["mf-inventory"]:openOtherInventory(stashId)
end
if esxInventory == 'ox_inventory' then
exports.ox_inventory:openInventory('stash', {id = stashId, owner = false})
end
if esxInventory == 'chezza-inventory' then
TriggerEvent('inventory:openStorage', "Stash", stashId, storageAmount, 1000)
end
if esxInventory == 'quasar-inventory' then
local other = {}
other.maxweight = storageAmount
other.slots = 50
TriggerServerEvent("inventory:server:OpenInventory", "stash", stashId, other)
TriggerEvent("inventory:client:SetCurrentStash", stashId)
end
end
-- This is an example for if you would like to use your own framework
TriggerServerEvent('inventory:getStorageInventory', stashId, storageAmount)
end
Pulling character information
If you would like to edit how character information is pulled, you can edit them in the functions.lua file. Default functions are as follows:
function getCharacterId()
if enableQBCore then
local QBCore = exports['qb-core']:GetCoreObject()
return QBCore.Functions.GetPlayerData().citizenid
end
if enableESX then
local ESX = exports['es_extended']:getSharedObject()
local player = ESX.GetPlayerData()
return player.identifier
end
-- This is an example for if you would like to use your own framework
return LocalPlayer.state.characterId
end
Checking Police Job
If you would like to edit the check for police jobs functions, you can edit them in the functions.lua file. Default functions are as follows:
function isPolice()
if enableQBCore then
local QBCore = exports['qb-core']:GetCoreObject()
return QBCore.Functions.GetPlayerData().job.name == 'police'
end
if enableESX then
local ESX = exports['es_extended']:getSharedObject()
return ESX.PlayerData.job.name == 'police'
end
-- This is an example for if you would like to use your own framework
return LocalPlayer.state.jobId == 1
end
Custom Notifications
If you would like to edit the notifications to add your own custom notifications or to match them to your other server notifications, you can edit them in the functions.lua file. Default notifications are as follows:
RegisterNetEvent('stashhouses:notification')
AddEventHandler('stashhouses:notification', function(msg)
TriggerEvent('ox_lib:notify', {description = msg})
end)
server_functions.lua
Handling player data
If you need to change how player data is called, you can change this in the server_functions.lua. Default functions are as follows:
function getCharacterId(source)
if enableQBCore then
local QBCore = exports['qb-core']:GetCoreObject()
local Player = QBCore.Functions.GetPlayer(source)
return Player.PlayerData.citizenid
end
if enableESX then
local ESX = exports['es_extended']:getSharedObject()
local player = ESX.GetPlayerData(source)
return player.identifier
end
-- This is an example for if you would like to use your own framework
return Player(source).state.characterId
end
Money Functions
If you need to change how money functions are handled, you can change this in the server_functions.lua. Default functions are as follows:
function getMoney(source)
if enableQBCore then
local QBCore = exports['qb-core']:GetCoreObject()
local Player = QBCore.Functions.GetPlayer(source)
return Player.PlayerData.money['cash']
end
if enableESX then
local ESX = exports['es_extended']:getSharedObject()
local player = ESX.GetPlayerData(source)
return player.getMoney()
end
-- This is an example for if you would like to use your own framework
local source = tonumber(source)
local user = exports['dsrp_core']:getCharacterFromId(source)
return user.getMoney()
end
function removeMoney(source, amount)
if enableQBCore then
local QBCore = exports['qb-core']:GetCoreObject()
local Player = QBCore.Functions.GetPlayer(source)
Player.Functions.RemoveMoney('cash', amount)
return true
end
if enableESX then
local ESX = exports['es_extended']:getSharedObject()
local player = ESX.GetPlayerData(source)
player.removeMoney(amount)
return true
end
-- This is an example for if you would like to use your own framework
local source = tonumber(source)
local user = exports['dsrp_core']:getCharacterFromId(source)
user.removeMoney(amount)
return true
end
function addMoney(source, amount)
if enableQBCore then
local QBCore = exports['qb-core']:GetCoreObject()
local Player = QBCore.Functions.GetPlayer(source)
Player.Functions.AddMoney('cash', amount)
return true
end
if enableESX then
local ESX = exports['es_extended']:getSharedObject()
local player = ESX.GetPlayerData(source)
player.addMoney(amount)
return true
end
-- This is an example for if you would like to use your own framework
local source = tonumber(source)
local user = exports['dsrp_core']:getCharacterFromId(source)
user.addMoney(amount)
return true
end
Staff Checks
If you need to change how player staff permissions are handled, you can change this in the server_functions.lua. Default functions are as follows:
function isStaff(source)
if enableQBCore then
local QBCore = exports['qb-core']:GetCoreObject()
local Player = QBCore.Functions.GetPlayer(source)
if QBCore.Functions.HasPermission(source, 'admin') or IsPlayerAceAllowed(source, 'command') then
return true
end
end
if enableESX then
local ESX = exports['es_extended']:getSharedObject()
local player = ESX.GetPlayerData(source)
if player.getGroup() == 'admin' or player.getGroup() == 'superadmin' then
return true
end
end
-- This is an example for if you would like to use your own framework
return false
end
Job Checks
If you need to change how character job permissions are handled, you can change this in the server_functions.lua. Default functions are as follows:
function hasJob(source, jobs)
if enableQBCore then
local QBCore = exports['qb-core']:GetCoreObject()
local Player = QBCore.Functions.GetPlayer(source)
local job = Player.PlayerData.job.name
if jobs[job] then
return true
end
return false
end
if enableESX then
local ESX = exports['es_extended']:getSharedObject()
local player = ESX.GetPlayerData(source)
local job = player.job.name
if jobs[job] then
return true
end
return false
end
-- This is an example for if you would like to use your own framework
return false
end
HTML
HTML files can be edited as needed for additional language support or styling edits.
Last updated
Was this helpful?