Accessible code
Config = {
Locale = 'en',
Testing = false, -- will add some values in inputs when creating turf
commands = {
creator = {
name = 'createturf',
help = 'Command that allows you to create turf',
restricted = 'group.admin', -- grop that will have acces to command
},
delete = {
name = 'deleteturf',
help = 'Command that allows you to delete turf',
restricted = 'group.admin',
},
adddays = {
name = 'adddays',
help = 'Command that allows you to add new days for capturing'
},
removeDays = {
name = 'removedays',
help = 'Command that allows you to remove capturable days',
restricted = 'group.admin',
},
editHours = {
name = 'editdays',
help = 'Command that allows you to edit capturable days and hours',
restricted = 'group.admin',
},
points = {
name = 'tpoints',
help = 'Opens scoreboard based on points gainted in turf capturing',
restricted = false -- everyone can access
},
revivePoint = { -- command only works if turf type is Revive Point
name = 'revivepoint',
help = 'Allows you to revive yourself for $x amount if you are near your own turf',
},
editTypes = {
name = 'edittype',
help = 'Command that allows you to edit turf types',
restricted = 'group.admin',
},
editProtection = {
name = 'editprotection',
help = 'Command that allows you to edit turf protection',
restricted = 'group.admin',
}
},
-- this will check for gang that you have on metadata on our gang builder, ESX ONLY, otherwise it will check your default job
-- if set to true, it will check first gang then job, otherwise it will just check job
GangCreatorSupport = true,
DebugZone = true,
-- qb core only
FirstCheck = 'gang', -- or 'job', will check can gang capture turf, otherwise if 'job' it will do same check just for job
-- jobs that cant capture
BlackListedJobs = {
['unemployed'] = true,
['ambulance'] = true,
['none'] = true, -- qb core
},
Target = IsESX() and 'qtarget' or 'qb-target', -- auto detect, if doesnt work, you can chose between 'qtarget', 'qb-target' and 'ox_target'
-- object that can be used as cover if you own turf, while creating turf you can chose price for object
CoverOptions = {
-- [label that shows in menu (every label must be diffent, cant have 2 same)] = { object hash, image }
['Car'] = {`prop_ztype_covered`, 'https://gta-objects.xyz/gallery/objects/prop_ztype_covered.jpg'},
['Cover Stone'] = {`prop_fib_3b_cover3`, 'https://gta-objects.xyz/gallery/objects/prop_fib_3b_cover3.jpg'},
['Table'] = {`xm_prop_x17_desk_cover_01a`, 'https://gta-objects.xyz/gallery/objects/xm_prop_x17_desk_cover_01a.jpg'},
['Long Seat'] = {`xm_prop_x17_seat_cover_01a`, 'https://gta-objects.xyz/gallery/objects/xm_prop_x17_seat_cover_01a.jpg'}
},
}
Discord = {
url = '', -- url here
title = 'Server Name',
/*
https://www.spycolor.com/
['default'] = 14423100,
['blue'] = 255,
['red'] = 16711680,
['green'] = 65280,
['white'] = 16777215,
['black'] = 0,
['orange'] = 16744192,
['yellow'] = 16776960,
['pink'] = 16761035,
['lightgreen'] = 65309,
*/
color = 65309, -- green
imageUrl = 'https://cdn.discordapp.com/attachments/1126197898439295066/1129791542379434004/discord_banner_uniq.png', -- optional, if you dont want it put ''
}
function Notify(msg, type)
lib.notify({
description = msg,
type = type,
position = 'bottom'
})
end
RegisterNetEvent('uniq_territories:Notify', Notify)
/*
'nui://ox_inventory/web/images/%s.png'
'nui://qb-inventory/html/images/%s.png'
'nui://ps-inventory/html/images/%s.png'
'nui://qs-inventory/html/images/%s.png'
'nui://core_inventory/html/img/%s.png'
*/
function GetItemImage()
return 'nui://ox_inventory/web/images/%s.png'
end
function GetItemLabel(item)
local label = lib.callback.await('uniq_territories:GetItemlabel', 100, item)
return label
end
local oxinv = GetResourceState('ox_inventory'):find('start')
local qsinv = GetResourceState('qs-inventory'):find('start')
local qbinv = GetResourceState('qb-inventory'):find('start')
local psinv = GetResourceState('ps-inventory'):find('start')
local codem = GetResourceState('codem-inventory'):find('start')
local lj = GetResourceState('lj-inventory'):find('start')
---@param src number
---@param reward number
function GiveReward(src, reward)
if IsESX() then
ESX.GetPlayerFromId(src)?.addMoney(reward)
elseif IsQBCore() then
QBCore.Functions.GetPlayer(src)?.Functions.AddMoney('cash', reward)
end
end
---@param source number
function ReviveEvent(source)
if IsESX() then
TriggerClientEvent('esx_ambulancejob:revive', source)
elseif IsQBCore() then
TriggerClientEvent('hospital:client:Revive', source)
TriggerClientEvent('hospital:client:HealInjuries', source, 'full')
end
end
---@param source number
---@param item string
---@param count number
function GiveItem(source, item, count)
if IsESX() then
ESX.GetPlayerFromId(source)?.addInventoryItem(item, count)
elseif IsQBCore() then
if item == 'cash' then
QBCore.Functions.GetPlayer(source)?.Functions.AddMoney('cash', count)
else
QBCore.Functions.GetPlayer(source)?.Functions.AddItem(item, count)
end
end
end
---@param source number
---@param item string
---@return integer
function GetItemCount(source, item)
if IsESX() then
-- if this doesn't work fro you, refer to your inventory documentations and check how to get item count
return ESX.GetPlayerFromId(source)?.getInventoryItem(item)?.count or 0
elseif IsQBCore() then
if item == 'cash' then
return QBCore.Functions.GetPlayer(source)?.Functions.GetMoney('cash') or 0
end
local itemAmount = QBCore.Functions.GetPlayer(source)?.Functions.GetItemByName(item)
-- some inventories use amount other count, check for both
if itemAmount then
if type(itemAmount.amount) ~= "nil" then
return itemAmount.amount
else
if type(itemAmount.count) ~= "nil" then
return itemAmount.count
end
end
end
end
return 0
end
---@param source number
---@param money string
---@return integer
function GetMoneyCount(source, money)
if IsESX() then
return ESX.GetPlayerFromId(source)?.getInventoryItem(money)?.count or 0
elseif IsQBCore() then
return QBCore.Functions.GetPlayer(source)?.Functions.GetMoney(money) or 0
end
end
---@param source any
---@param amount any
---@return boolean
-- used when buying stock for turf
function RemoveMoney(source, amount)
if IsESX() then
ESX.GetPlayerFromId(source)?.removeInventoryItem('money', amount)
return true
elseif IsQBCore() then
QBCore.Functions.GetPlayer(source)?.Functions.RemoveMoney('cash', amount)
return true
end
return false
end
-- event triggered when washing money starts
---@param source number
---@param item string
---@param amount number
function StartWashing(source, item, amount)
if IsESX() then
ESX.GetPlayerFromId(source)?.removeInventoryItem(item, amount)
elseif IsQBCore() then
if item == 'cash' then
QBCore.Functions.GetPlayer(source)?.Functions.RemoveMoney('cash', amount)
else
QBCore.Functions.GetPlayer(source)?.Functions.RemoveItem(item, amount)
end
end
end
---@param playerId number
---@return integer
function GetMoney(playerId)
if IsESX() then
return ESX.GetPlayerFromId(playerId)?.getMoney() or 0
elseif IsQBCore() then
return QBCore.Functions.GetPlayer(playerId)?.Functions.GetMoney('cash') or 0
end
return 0
end
---@param src number
---@param item string
---@param count number
function RemoveItem(src, item, count)
if IsESX() then
ESX.GetPlayerFromId(src)?.removeInventoryItem(item, count)
elseif IsQBCore() then
if item == 'cash' then
QBCore.Functions.GetPlayer(source)?.Functions.RemoveMoney('cash', count)
else
QBCore.Functions.GetPlayer(source)?.Functions.RemoveItem(item, count)
end
end
end
---@param source number
---@return table
lib.callback.register('uniq_territories:GetItems', function(source)
local items = {}
if oxinv then
for k,v in pairs(exports.ox_inventory:Items()) do
items[v.name] = { label = v.label, value = v.name }
end
elseif qsinv or qbinv or psinv or lj then
for k,v in pairs(QBCore.Shared.Items) do
items[v.name] = { label = v.label, value = v.name }
end
elseif codem then
for k,v in pairs(exports["codem-inventory"]:GetItemlist()) do
items[v.name] = { label = v.label, value = v.name }
end
end
return items
end)
lib.callback.register('uniq_territories:GetItemlabel', function(source, item)
if item then
if IsESX() then
return ESX.GetItemLabel(item)
elseif IsQBCore() then
if item == 'cash' then return 'Cash' end
if QBCore.Shared.Items[item] then
return QBCore.Shared.Items[item].label
end
end
end
return L('unknown')
end)
Last updated