4・Advanced configuration / Custom Framework
SKIP THIS TOPIC IF YOU ARE ON ESX OR QBUS

This topic concern people who have a custom Framework and know what they do.

Here, we will explain how to adapt our script for a custom Framework server. Do not touch any part of it if you don't know what you do.
First, go to
marketShop/config
and open theconfig.lua
file. At the top of the file, define your framework by "other"
FrameWork = "other" -- qb or esx or other
Don't forget to config our config with the previous step.
Now, go to
marketShop/unencryptedServer
and go to the folder namedotherFramework
You have 3 files inside. Start withenterprise.lua
, all functions are explained in this file.
if string.lower(FrameWork) ~= "other" then
return
end
affError("FRAMEWORK DEFINE : OTHER")
local QBCore = nil
--QBCore = exports['qb-core']:GetCoreObject()
----------------------------------------------------------------
-- Function To remove money from the supermarket bank account --
----------------------------------------------------------------
function RemoveMoneyFromEntreprise(price)
local moneyRemoved = false
if exports['qb-management']:RemoveMoney("supermarket", price) then
moneyRemoved = true
end
return moneyRemoved
end
----------------------------------------------------------------------
-- Event triggered when a player clean the splat in the supermarket --
----------------------------------------------------------------------
RegisterServerEvent('marketShop:CleaningPay')
AddEventHandler('marketShop:CleaningPay', function(player)
local Player = QBCore.Functions.GetPlayer(player)
if RemoveMoneyFromEntreprise(CleaningPrice) then
Player.Functions.AddMoney("bank", CleaningPrice)
else
TriggerClientEvent("marketShop:notif",player,TRAD["Trad-NoEnterpriseMoneyTitle"],TRAD["Trad-NoEnterpriseMoney"],"box","#FF0000")
end
end)
inventory.lua
, all functions are explained in this file.
if string.lower(FrameWork) ~= "other" then
return
end
-- local QBCore = exports['qb-core']:GetCoreObject()
------------------------------------------------------------------------------
-- Function used to add item to the player (used when you bought something) --
------------------------------------------------------------------------------
function GiveToPlayerItem(player,item,qte)
aff("Give to: "..tostring(player).." "..tostring(item).." "..tostring(qte))
local Player = QBCore.Functions.GetPlayer(player)
Player.Functions.AddItem(item, qte)
end
----------------------------------------------------------------------------------------------
-- Function used to remove item from the player (used when you put back in stock something) --
----------------------------------------------------------------------------------------------
function RemovePlayerItem(player,item,qte)
local itemRemoved = false
local Player = QBCore.Functions.GetPlayer(player)
local invItem = Player.Functions.GetItemByName(item)
if invItem and invItem.amount >= qte then
Player.Functions.RemoveItem(item, qte)
itemRemoved = true
end
return itemRemoved
end
payment.lua
, all functions are explained in this file.
if string.lower(FrameWork) ~= "other" then
return
end
-- local QBCore = exports['qb-core']:GetCoreObject()
---------------------------------------------------------------------------------------------------------------------------------
-- The two event bellow are triggered when you pay at a cahsregister/automatic cash register --
-- This is here where player have to pay for their stuff so we remove player money and transfer it to the supermarket account --
-- This is here where the audio of the cash reg payment is triggered --
-- This is here where we set the payment status of the casreg (setPaidForCashReg) --
---------------------------------------------------------------------------------------------------------------------------------
RegisterServerEvent('marketShop:PaidCashReg')
AddEventHandler('marketShop:PaidCashReg', function(data)
local player = source
local handle = tonumber(data.handle)
Citizen.CreateThread(function()
local locplayer = player
local cashRegHandle = handle
aff("^1PaidCashReg^7 "..tostring(cashRegHandle))
local Player = QBCore.Functions.GetPlayer(player)
local cashBalance = Player.PlayerData.money["cash"]
local bankBalance = Player.PlayerData.money["bank"]
local value = getPriceToPaidForCashReg(cashRegHandle)
aff("getPaidStatusForCashReg : "..tostring(getPaidStatusForCashReg(cashRegHandle)).." getPaidStatusForCashReg2 : "..tostring(getPaidStatusForCashReg2(cashRegHandle)).." value: "..tostring(getPriceToPaidForCashReg(cashRegHandle)))
if value > -1 then
if getPaidStatusForCashReg(cashRegHandle) == false and getPaidStatusForCashReg2(cashRegHandle) == true then
aff("a")
if cashBalance >= value then
aff("b")
Player.Functions.RemoveMoney("cash", value)
exports['qb-management']:AddMoney("supermarket", tonumber(value))
TriggerClientEvent("marketShop:CLIBipPaid", -1, cashRegHandle)
setPaidForCashReg(cashRegHandle)
elseif bankBalance >= value then
aff("c")
Player.Functions.RemoveMoney("bank", value)
exports['qb-management']:AddMoney("supermarket", tonumber(value))
TriggerClientEvent("marketShop:CLIBipPaid", -1, cashRegHandle)
setPaidForCashReg(cashRegHandle)
-- TriggerEvent("marketShop:takeOutGarage", cashRegHandle)
else
aff("d")
TriggerClientEvent("marketShop:notif",player,TRAD["Trad-PasThuneTitle"],TRAD["Trad-PasThune"],"box","#FF0000")
-- TriggerClientEvent('QBCore:Notify', src, Lang:t("error.not_enough"), 'error')
end
else
aff("e")
if getPaidStatusForCashReg(cashRegHandle) == true then
aff("f")
TriggerClientEvent("marketShop:notif",player,TRAD["Trad-DejaPayerTitle"],TRAD["Trad-DejaPayer"],"box","#FF0000")
end
if getPaidStatusForCashReg2(cashRegHandle) == false then
aff("g")
TriggerClientEvent("marketShop:notif",player,TRAD["Trad-RienPayerTitle"],TRAD["Trad-RienPayer"],"box","#FF0000")
end
end
end
end)
end)
RegisterServerEvent('marketShop:PaidAutoCashReg')
AddEventHandler('marketShop:PaidAutoCashReg', function(data)
local player = source
local handle = tonumber(data.handle)
Citizen.CreateThread(function()
local locplayer = player
local cashRegHandle = handle
aff("^1PaidAutoCashReg^7 "..tostring(cashRegHandle))
local Player = QBCore.Functions.GetPlayer(locplayer)
local cashBalance = Player.PlayerData.money["cash"]
local bankBalance = Player.PlayerData.money["bank"]
local value = getPriceToPaidForAutoCashReg(cashRegHandle)
aff("getPaidStatusForAutoCashReg : "..tostring(getPaidStatusForAutoCashReg(cashRegHandle)).." getPaidStatusForAutoCashReg2 : "..tostring(getPaidStatusForAutoCashReg2(cashRegHandle)).." value: "..tostring(getPriceToPaidForAutoCashReg(cashRegHandle)))
if value > -1 then
aff("value: "..tostring(value))
if getPaidStatusForAutoCashReg(cashRegHandle) == false and getPaidStatusForAutoCashReg2(cashRegHandle) == true then
aff("a")
if cashBalance >= value then
aff("b")
Player.Functions.RemoveMoney("cash", value)
exports['qb-management']:AddMoney("supermarket", tonumber(value))
TriggerClientEvent("marketShop:CLIBipAutoPaid", -1, cashRegHandle)
setPaidForAutoCashReg(cashRegHandle)
elseif bankBalance >= value then
aff("c")
Player.Functions.RemoveMoney("bank", value)
exports['qb-management']:AddMoney("supermarket", tonumber(value))
TriggerClientEvent("marketShop:CLIBipAutoPaid", -1, cashRegHandle)
setPaidForAutoCashReg(cashRegHandle)
-- TriggerEvent("marketShop:takeOutGarage", cashRegHandle)
else
aff("d")
TriggerClientEvent("marketShop:notif",locplayer,TRAD["Trad-PasThuneTitle"],TRAD["Trad-PasThune"],"box","#FF0000")
-- TriggerClientEvent('QBCore:Notify', src, Lang:t("error.not_enough"), 'error')
end
else
aff("e")
if getPaidStatusForAutoCashReg(cashRegHandle) == true then
aff("f")
TriggerClientEvent("marketShop:notif",locplayer,TRAD["Trad-DejaPayerTitle"],TRAD["Trad-DejaPayer"],"box","#FF0000")
end
if getPaidStatusForAutoCashReg2(cashRegHandle) == false then
aff("g")
TriggerClientEvent("marketShop:notif",locplayer,TRAD["Trad-RienPayerTitle"],TRAD["Trad-RienPayer"],"box","#FF0000")
end
end
end
end)
end)
Now you go to
marketShop/unencryptedClient
and go to the folder namedotherFramework
You have oneenterprise.lua
file. Like the others, all functions are explained in this file.
if string.lower(FrameWork) ~= "other" then
return
end
local PlayerJob = {}
local onDuty = false
--local QBCore = exports['qb-core']:GetCoreObject()
---------------------------------------------------------
-- Function To check if the player work at supermarket --
---------------------------------------------------------
function IsMarketEmployee()
local isMarketEmployee = false
if PlayerJob.name == 'supermarket' then
isMarketEmployee = true
end
return isMarketEmployee, onDuty
end
--------------------------------------------------------------------
-- Function To check if the player is the boss of the supermarket --
--------------------------------------------------------------------
function IsPatron()
aff("IsPatron : "..tostring(PlayerJob.isboss))
return PlayerJob.isboss
end
----------------------------------------
-- Client side on/off duty management --
----------------------------------------
RegisterNetEvent("marketShop:SetDutyStatus")
AddEventHandler('marketShop:SetDutyStatus', function()
onDuty = not onDuty
TriggerServerEvent("QBCore:ToggleDuty")
end)
---------------------------------------------------------------------------------
-- All event below are QB relative, but i let it their to remind you to manage --
-- disconnection / connection and job changing --
---------------------------------------------------------------------------------
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo)
aff("^4-----------OnJobUpdate-----------^7 "..tostring(JobInfo.name))
PlayerJob = JobInfo
if PlayerJob.name == 'supermarket' then
onDuty = PlayerJob.onduty
if PlayerJob.onduty then
TriggerServerEvent("marketShop:AddActifEmployee")
else
TriggerServerEvent("marketShop:RemoveActifEmployee")
end
end
end)
RegisterNetEvent('QBCore:Client:SetDuty', function(duty)
if PlayerJob.name == 'supermarket' and duty ~= onDuty then
if duty then
TriggerServerEvent("marketShop:AddActifEmployee")
else
TriggerServerEvent("marketShop:RemoveActifEmployee")
end
end
onDuty = duty
end)
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
CreateThread(function()
Wait(1000)
QBCore.Functions.GetPlayerData(function(PlayerData)
PlayerJob = PlayerData.job
onDuty = PlayerData.job.onduty
if PlayerJob.name == 'supermarket' and onDuty then
TriggerServerEvent("marketShop:AddActifEmployee", PlayerJob.name)
end
end)
TriggerServerEvent("marketShop:getAllLockStatus")
TriggerServerEvent("marketShop:getAllAutoLockStatus")
end)
end)
AddEventHandler('onResourceStart', function(resource)
if GetCurrentResourceName() == resource then
PlayerJob = QBCore.Functions.GetPlayerData().job
onDuty = PlayerJob.onduty
for k,v in pairs(PlayerJob) do
aff("k : "..tostring(k).." v: "..tostring(v))
end
end
end)
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
if PlayerJob.name == 'supermarket' and onDuty then
TriggerServerEvent("marketShop:RemoveActifEmployee", PlayerJob.name)
end
end)
Now you can start our script and all should works perfectly !
Please, contact us by opening a ticket on our discord's server.
Last updated