Accessible code
---@return boolean
function ExtraCheck()
return true
end
---@param coords vector3|vector3[]
function PoliceNotify(coords)
end
local oxinv = GetResourceState("ox_inventory")
local qbinv = GetResourceState("qb-inventory")
local psinv = GetResourceState("ps-inventory")
local qsinv = GetResourceState("qs-inventory")
local core = GetResourceState("core_inventory")
function ImagePath()
if oxinv then
return 'nui://ox_inventory/web/images/%s.png'
elseif qbinv then
return'nui://qb-inventory/html/images/%s.png'
elseif psinv then
return 'nui://ps-inventory/html/images/%s.png'
elseif qsinv then
return 'nui://qs-inventory/html/images/%s.png'
elseif core then
return 'nui://core_inventory/html/img/%s.png'
end
return ''
end
function Notify(msg, type)
lib.notify({
description = msg,
type = type,
position = Shared.notifyPosition,
duration = 4500
})
end
RegisterNetEvent('uniq-weedplant:Notify', Notify)
RegisterNetEvent('uniq-weedplant:afterHarvest', function ()
if source == '' then return end
-- here you can put code for xp or something if you want after you harvest your plant
end)function AddItem(source, item, amount)
if IsESX() then
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.addInventoryItem(item, amount)
elseif IsQBCore() then
local Player = QBCore.Functions.GetPlayer(source)
Player.Functions.AddItem(item, amount)
end
end
function RemoveItem(source, item, amount)
if IsESX() then
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.removeInventoryItem(item, amount)
elseif IsQBCore() then
local Player = QBCore.Functions.GetPlayer(source)
Player.Functions.RemoveItem(item, amount)
end
end
function GetItemAmount(source, name)
if IsESX() then
local xPlayer = ESX.GetPlayerFromId(source)
local item = xPlayer.getInventoryItem(name)
if item then
for k,v in pairs(item) do
if k == 'amount' then
return v
end
if k == 'count' then
return v
end
end
end
return 0
elseif IsQBCore() then
local Player = QBCore.Functions.GetPlayer(source)
local item = Player.Functions.GetItemByName(name)
if item then
for k,v in pairs(item) do
if k == 'amount' then
return v
end
if k == 'count' then
return v
end
end
end
return 0
end
end
-- if you dont want this, delete then
RegisterCommand('testscript', function (source, args, raw)
if IsESX() then
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.addInventoryItem('p_haze_seed', 2)
xPlayer.addInventoryItem(Shared.items.pot, 2)
xPlayer.addInventoryItem(Shared.items.water, 2)
xPlayer.addInventoryItem(Shared.items.fertilizer, 2)
elseif IsQBCore() then
local Player = QBCore.Functions.GetPlayer(source)
Player.Functions.AddItem('p_haze_seed', 2)
Player.Functions.AddItem(Shared.items.pot, 2)
Player.Functions.AddItem(Shared.items.water, 2)
Player.Functions.AddItem(Shared.items.fertilizer, 2)
end
end, true)if IsESX() then
for k,v in pairs(Shared.strains) do
ESX.RegisterUsableItem(v.seed, function(source)
local src = source
local canPlant = lib.callback.await('uniq-weedplant:plantNewSeed', src)
if canPlant then
PlantSeed(src, k)
end
end)
end
elseif IsQBCore() then
for k,v in pairs(Shared.strains) do
QBCore.Functions.CreateUseableItem(v.seed, function(source)
local src = source
local canPlant = lib.callback.await('uniq-weedplant:plantNewSeed', src)
if canPlant then
PlantSeed(src, k)
end
end)
end
endLast updated