added CUI function for createuseableitem. will add support for other frameworks in the future

This commit is contained in:
Mustache Dom committed 2024-12-12 17:26:08 -08:00
1 parent 3043ecd924
commit b56e585691
16 files changed
+64 -69

No files matched your search

+13 -12
View File
@@ -5,6 +5,14 @@ local minigametype = Config.minigametype
local notifytype = Config.Notify local notifytype = Config.Notify
local dispatch = Config.Dispatch local dispatch = Config.Dispatch
function getJobType()
return QBCore.Functions.GetPlayerData().job.type
end
function getJobName()
return QBCore.Functions.GetPlayerData().job.name
end
function progressbar(text, time, anim) function progressbar(text, time, anim)
TriggerEvent('animations:client:EmoteCommandStart', {anim}) TriggerEvent('animations:client:EmoteCommandStart', {anim})
if progressbartype == 'oxbar' then if progressbartype == 'oxbar' then
@@ -368,11 +376,11 @@ end
function Freeze(entity, toggle, head) function Freeze(entity, toggle, head)
SetEntityInvincible(entity, toggle) SetEntityInvincible(entity, toggle)
SetEntityAsMissionEntity(entity, toggle, toggle) SetEntityAsMissionEntity(entity, toggle, toggle)
FreezeEntityPosition(entity, toggle) FreezeEntityPosition(entity, toggle)
SetEntityHeading(entity, head) SetEntityHeading(entity, head)
SetBlockingOfNonTemporaryEvents(entity, toggle) SetBlockingOfNonTemporaryEvents(entity, toggle)
end end
function tele(coords) function tele(coords)
@@ -674,10 +682,3 @@ RegisterCommand('DrugRep', function()
lib.showContext('DrugRep') lib.showContext('DrugRep')
end, false) end, false)
function getJobType()
return QBCore.Functions.GetPlayerData().job.type
end
function getJobName()
return QBCore.Functions.GetPlayerData().job.name
end
+2
View File
@@ -9,11 +9,13 @@ client_scripts {
} }
server_scripts { server_scripts {
'server/functions.lua',
'server/**.lua', 'server/**.lua',
'@oxmysql/lib/MySQL.lua', '@oxmysql/lib/MySQL.lua',
} }
shared_scripts { shared_scripts {
'shared/config.lua',
'@ox_lib/init.lua', '@ox_lib/init.lua',
'shared/**.lua', 'shared/**.lua',
} }
+2 -2
View File
@@ -125,14 +125,14 @@ end)
local cokecut = {loosecokestagetwo = 2, loosecokestagethree = 3} local cokecut = {loosecokestagetwo = 2, loosecokestagethree = 3}
for k, v in pairs (cokecut) do for k, v in pairs (cokecut) do
QBCore.Functions.CreateUseableItem(k, function(source, item) CUI(k, function(source, item)
local src = source local src = source
local Player = getPlayer(src) local Player = getPlayer(src)
if Player.Functions.GetItemByName(item.name) then if Player.Functions.GetItemByName(item.name) then
if not Itemcheck(src, 'bakingsoda', 1) then return end if not Itemcheck(src, 'bakingsoda', 1) then return end
local check = lib.callback.await('md-drugs:client:uncuff', src, 'Cutting It Further') local check = lib.callback.await('md-drugs:client:uncuff', src, 'Cutting It Further')
if not check then return end if not check then return end
if RemoveItem(src, k, 1) then if RemoveItem(src, k, 1) and RemoveItem(src, k, 1) then
AddItem(src, 'loosecoke', v) AddItem(src, 'loosecoke', v)
end end
end end
+1 -1
View File
@@ -1,7 +1,7 @@
local QBCore = exports['qb-core']:GetCoreObject() local QBCore = exports['qb-core']:GetCoreObject()
for k, v in pairs(Consumables.Items) do for k, v in pairs(Consumables.Items) do
QBCore.Functions.CreateUseableItem(k, function(source, item) CUI(k, function(source, item)
if not Itemcheck(source, k, 1) then return end if not Itemcheck(source, k, 1) then return end
local time = v.time or Consumables.defaulttime local time = v.time or Consumables.defaulttime
local effect = v.effect or 0 local effect = v.effect or 0
+2 -2
View File
@@ -47,14 +47,14 @@ end)
local cokecut = {crackrockstagetwo = 2, crackrockstagethree = 3} local cokecut = {crackrockstagetwo = 2, crackrockstagethree = 3}
for k, v in pairs (cokecut) do for k, v in pairs (cokecut) do
QBCore.Functions.CreateUseableItem(k, function(source, item) CUI(k, function(source, item)
local src = source local src = source
local Player = getPlayer(src) local Player = getPlayer(src)
if Player.Functions.GetItemByName(item.name) then if Player.Functions.GetItemByName(item.name) then
if not Itemcheck(src, 'bakingsoda', 1) then return end if not Itemcheck(src, 'bakingsoda', 1) then return end
local check = lib.callback.await('md-drugs:client:uncuff', src, 'Cutting Crack Rock Further') local check = lib.callback.await('md-drugs:client:uncuff', src, 'Cutting Crack Rock Further')
if not check then return end if not check then return end
if RemoveItem(src, k, 1) then if RemoveItem(src, k, 1) and RemoveItem(src, 'bakingsoda', 1) then
AddItem(src, 'crackrock', v) AddItem(src, 'crackrock', v)
end end
end end
+12 -18
View File
@@ -1,6 +1,6 @@
local QBCore = exports['qb-core']:GetCoreObject() local QBCore = exports['qb-core']:GetCoreObject()
local notify = Config.Notify -- qb or ox local notify = Config.Notify -- qb or ox
local inventory = Config.Inventory -- qb or ox
------------------------------------------ logging stuff ------------------------------------------ logging stuff
local logs = false local logs = false
local logapi = GetConvar("fivemerrLogs", "") local logapi = GetConvar("fivemerrLogs", "")
@@ -48,23 +48,13 @@ end
---------------------------------------------------- inventory catcher ---------------------------------------------------- inventory catcher
local invname = '' local invname = ''
CreateThread(function() CreateThread(function()
if GetResourceState('ps-inventory') == 'started' then if GetResourceState('ps-inventory') == 'started' then
invname = 'ps-inventory' invname = 'ps-inventory'
elseif GetResourceState('qb-inventory') == 'started' then elseif GetResourceState('qb-inventory') == 'started' then
invname = 'qb-inventory' invname = 'qb-inventory'
else else
invname = 'inventory' invname = 'inventory'
end end
end)
local inventory = ''
CreateThread(function()
if GetResourceState('ox_inventory') == 'started' then
inventory = 'ox'
else
inventory = 'qb'
end
end) end)
------------------------------------ Player Stuff functions ------------------------------------ Player Stuff functions
function getPlayer(source) function getPlayer(source)
@@ -126,6 +116,10 @@ function GetLabels(item)
end end
end end
function CUI(item, useFunction)
QBCore.Functions.CreateUseableItem(item, useFunction)
end
function Itemcheck(source, item, amount) function Itemcheck(source, item, amount)
if inventory == 'qb' then if inventory == 'qb' then
local Player = getPlayer(source) local Player = getPlayer(source)
+1 -1
View File
@@ -136,7 +136,7 @@ RegisterServerEvent('md-drugs:server:getheroinlabkitback', function()
end) end)
QBCore.Functions.CreateUseableItem('heroinlabkit', function(source, item) CUI('heroinlabkit', function(source, item)
local src = source local src = source
local Player = getPlayer(src) local Player = getPlayer(src)
if not Itemcheck(source, 'heroinlabkit', 1) then return end if not Itemcheck(source, 'heroinlabkit', 1) then return end
+1 -1
View File
@@ -16,7 +16,7 @@ RegisterServerEvent('md-drugs:server:givelean', function()
end end
end) end)
QBCore.Functions.CreateUseableItem('leancup', function(source, item) CUI('leancup', function(source, item)
if Itemcheck(source, 'leancup', 1) then if Itemcheck(source, 'leancup', 1) then
TriggerClientEvent('md-drugs:client:leancraft', source) TriggerClientEvent('md-drugs:client:leancraft', source)
end end
+2 -2
View File
@@ -20,7 +20,7 @@ RegisterServerEvent('md-drugs:server:getdiethylamide', function(num)
end) end)
QBCore.Functions.CreateUseableItem('lsdlabkit', function(source, item) CUI('lsdlabkit', function(source, item)
local src = source local src = source
local Player = getPlayer(src) local Player = getPlayer(src)
local placed, loc = lib.callback.await('md-drugs:client:setlsdlabkit', src) local placed, loc = lib.callback.await('md-drugs:client:setlsdlabkit', src)
@@ -195,7 +195,7 @@ local sheets = {
} }
for k, v in pairs (sheets) do for k, v in pairs (sheets) do
QBCore.Functions.CreateUseableItem(v.item, function(source) CUI(v.item, function(source)
local src = source local src = source
local Player = getPlayer(src) local Player = getPlayer(src)
local math = math.random(1,10) local math = math.random(1,10)
+1 -1
View File
@@ -54,7 +54,7 @@ RegisterNetEvent("md-drugs:server:drymescaline", function()
if not GetRecipe(src, 'mescaline', 'dry', 'dried') then return end if not GetRecipe(src, 'mescaline', 'dry', 'dried') then return end
end) end)
QBCore.Functions.CreateUseableItem("driedmescaline", function(source, item) CUI("driedmescaline", function(source, item)
local src = source local src = source
if RemoveItem(src, "driedmescaline", 1) then if RemoveItem(src, "driedmescaline", 1) then
TriggerClientEvent("md-drugs:client:takemescaline", src) TriggerClientEvent("md-drugs:client:takemescaline", src)
+2 -2
View File
@@ -10,7 +10,7 @@ local function GetJob(source)
end end
end end
QBCore.Functions.CreateUseableItem('prescription_pad', function(source, item) CUI('prescription_pad', function(source, item)
local src = source local src = source
local near = {} local near = {}
if GetJob(src) then if GetJob(src) then
@@ -38,7 +38,7 @@ end)
local pharmabottle = {'vicodinbottle', 'adderalbottle','morphinebottle','xanaxbottle'} local pharmabottle = {'vicodinbottle', 'adderalbottle','morphinebottle','xanaxbottle'}
for m, d in pairs (pharmabottle) do for m, d in pairs (pharmabottle) do
QBCore.Functions.CreateUseableItem(d, function(source, item) CUI(d, function(source, item)
local src = source local src = source
local Player = getPlayer(src) local Player = getPlayer(src)
local check = lib.callback.await("md-drugs:client:unbottle", src) local check = lib.callback.await("md-drugs:client:unbottle", src)
+1 -1
View File
@@ -50,7 +50,7 @@ RegisterNetEvent("shrooms:pickupCane", function(loc)
end end
end) end)
QBCore.Functions.CreateUseableItem('shrooms', function(source, item) CUI('shrooms', function(source, item)
local src = source local src = source
if TriggerClientEvent('md-drugs:client:takeshrooms', src, item.name) then if TriggerClientEvent('md-drugs:client:takeshrooms', src, item.name) then
RemoveItem(src, 'shrooms', 1) RemoveItem(src, 'shrooms', 1)
+21 -23
View File
@@ -79,19 +79,13 @@ end)
local bluntwrap = {'mdreddextro','mdlean'} local bluntwrap = {'mdreddextro','mdlean'}
for k, v in pairs (bluntwrap) do for k, v in pairs (bluntwrap) do
QBCore.Functions.CreateUseableItem(v, function(source, item) CUI(v, function(source, item) TriggerClientEvent('md-drugs:client:makeBluntWrap', source) end)
local src = source
TriggerClientEvent('md-drugs:client:makeBluntWrap', src)
end)
end end
local bluntwraps = {'leanbluntwrap', 'dextrobluntwrap', 'bluntwrap'} local bluntwraps = {'leanbluntwrap', 'dextrobluntwrap', 'bluntwrap'}
for k, v in pairs (bluntwraps) do for k, v in pairs (bluntwraps) do
QBCore.Functions.CreateUseableItem(v, function(source, item) CUI(v, function(source, item) TriggerClientEvent('md-drugs:client:rollBlunt', source) end)
local src = source
TriggerClientEvent('md-drugs:client:rollBlunt', source)
end)
end end
@@ -109,29 +103,33 @@ RegisterServerEvent('md-drugs:server:makeoil', function(data)
if not GetRecipe(src, 'weed', 'oil', 'shatter') then return end if not GetRecipe(src, 'weed', 'oil', 'shatter') then return end
end) end)
QBCore.Functions.CreateUseableItem("dabrig", function(source, item)
local src = source
local Player = getPlayer(src)
if Player.Functions.GetItemByName("butanetorch") then CUI("dabrig", function(source, item)
if RemoveItem(src, "shatter", 1) then local src = source
TriggerClientEvent("md-drugs:client:dodabs", src) local Player = getPlayer(src)
if Player.Functions.GetItemByName("butanetorch") then
if RemoveItem(src, "shatter", 1) then
TriggerClientEvent("md-drugs:client:dodabs", src)
end
else
Notifys(src, 'You Need A Butane Torch', 'error')
end end
end
end) end)
QBCore.Functions.CreateUseableItem("weedgrinder", function(source, item) CUI("weedgrinder", function(source, item)
local src = source local src = source
local Player = getPlayer(src)
local has = Player.Functions.GetItemByName("drycannabis")
if not has then Notifys(src, 'You Need Dried Cannabis', 'error') return end
local check = lib.callback.await('md-drugs:client:uncuff', src, 'Grinding Weed') local check = lib.callback.await('md-drugs:client:uncuff', src, 'Grinding Weed')
if not check then return end if not check then return end
if RemoveItem(src, "drycannabis",1 ) then if RemoveItem(src, "drycannabis",1 ) then
AddItem(src, "grindedweed", 1) AddItem(src, "grindedweed", 1)
else end
Notifys(src,'You Need Dried Weed', 'error')
end
end) end)
QBCore.Functions.CreateUseableItem("mdwoods", function(source, item) CUI("mdwoods", function(source, item)
local src = source local src = source
local Player = getPlayer(src) local Player = getPlayer(src)
local check = lib.callback.await('md-drugs:client:uncuff', src, 'Breaking Blunt Open') local check = lib.callback.await('md-drugs:client:uncuff', src, 'Breaking Blunt Open')
+1 -1
View File
@@ -16,7 +16,7 @@ local Price = {
} }
for k, v in pairs (burners) do for k, v in pairs (burners) do
QBCore.Functions.CreateUseableItem(k, function(source, item) CUI(k, function(source, item)
local src = source local src = source
local Player = getPlayer(src) local Player = getPlayer(src)
if getCops() < Config.PoliceCount then return Notifys(src, Lang.Wholesale.na, 'error') end if getCops() < Config.PoliceCount then return Notifys(src, Lang.Wholesale.na, 'error') end
+1 -1
View File
@@ -24,7 +24,7 @@ local presses = {
{item = 'quadpress', data = 'quad'}, {item = 'quadpress', data = 'quad'},
} }
for k, v in pairs (presses) do for k, v in pairs (presses) do
QBCore.Functions.CreateUseableItem(v.item, function(source, item) CUI(v.item, function(source, item)
local src = source local src = source
local Player = getPlayer(src) local Player = getPlayer(src)
local check, loc = lib.callback.await('md-drugs:client:setpress', src, v.data) local check, loc = lib.callback.await('md-drugs:client:setpress', src, v.data)
+1 -1
View File
@@ -6,7 +6,7 @@ Config.TierSystem = true -- allows for three tiers of certain drugs ( coke, hero
Config.StupidassNewQbItemName = true -- true if you have updated your items.lua from base qb after november 2023 because changing item names this far in a framework is 3 IQ points total Config.StupidassNewQbItemName = true -- true if you have updated your items.lua from base qb after november 2023 because changing item names this far in a framework is 3 IQ points total
Config.RequestModelTime = 30000 -- if you need more time than this, uhhhh wow Config.RequestModelTime = 30000 -- if you need more time than this, uhhhh wow
Config.FancyCokeAnims = true -- if you want multi location this needs to be false Config.FancyCokeAnims = true -- if you want multi location this needs to be false
Config.Inventory = 'qb' -- qb or ox, other if you dont use ox just mark as qb
Config.Joblock = false -- if you want weed to be a job Config.Joblock = false -- if you want weed to be a job
Config.weedjob = "" -- what the job name is Config.weedjob = "" -- what the job name is
Config.Badtrip = 20 -- number means % chance to spawn a clone that chases and attacks while on mescaline Config.Badtrip = 20 -- number means % chance to spawn a clone that chases and attacks while on mescaline