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
+66 -71

No files matched your search

+13 -12
View File
@@ -5,6 +5,14 @@ local minigametype = Config.minigametype
local notifytype = Config.Notify
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)
TriggerEvent('animations:client:EmoteCommandStart', {anim})
if progressbartype == 'oxbar' then
@@ -368,11 +376,11 @@ end
function Freeze(entity, toggle, head)
SetEntityInvincible(entity, toggle)
SetEntityAsMissionEntity(entity, toggle, toggle)
FreezeEntityPosition(entity, toggle)
SetEntityHeading(entity, head)
SetBlockingOfNonTemporaryEvents(entity, toggle)
SetEntityInvincible(entity, toggle)
SetEntityAsMissionEntity(entity, toggle, toggle)
FreezeEntityPosition(entity, toggle)
SetEntityHeading(entity, head)
SetBlockingOfNonTemporaryEvents(entity, toggle)
end
function tele(coords)
@@ -674,10 +682,3 @@ RegisterCommand('DrugRep', function()
lib.showContext('DrugRep')
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/functions.lua',
'server/**.lua',
'@oxmysql/lib/MySQL.lua',
}
shared_scripts {
'shared/config.lua',
'@ox_lib/init.lua',
'shared/**.lua',
}
+2 -2
View File
@@ -125,14 +125,14 @@ end)
local cokecut = {loosecokestagetwo = 2, loosecokestagethree = 3}
for k, v in pairs (cokecut) do
QBCore.Functions.CreateUseableItem(k, function(source, item)
CUI(k, function(source, item)
local src = source
local Player = getPlayer(src)
if Player.Functions.GetItemByName(item.name) then
if not Itemcheck(src, 'bakingsoda', 1) then return end
local check = lib.callback.await('md-drugs:client:uncuff', src, 'Cutting It Further')
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)
end
end
+1 -1
View File
@@ -1,7 +1,7 @@
local QBCore = exports['qb-core']:GetCoreObject()
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
local time = v.time or Consumables.defaulttime
local effect = v.effect or 0
+2 -2
View File
@@ -47,14 +47,14 @@ end)
local cokecut = {crackrockstagetwo = 2, crackrockstagethree = 3}
for k, v in pairs (cokecut) do
QBCore.Functions.CreateUseableItem(k, function(source, item)
CUI(k, function(source, item)
local src = source
local Player = getPlayer(src)
if Player.Functions.GetItemByName(item.name) then
if not Itemcheck(src, 'bakingsoda', 1) then return end
local check = lib.callback.await('md-drugs:client:uncuff', src, 'Cutting Crack Rock Further')
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)
end
end
+13 -19
View File
@@ -1,6 +1,6 @@
local QBCore = exports['qb-core']:GetCoreObject()
local notify = Config.Notify -- qb or ox
local inventory = Config.Inventory -- qb or ox
------------------------------------------ logging stuff
local logs = false
local logapi = GetConvar("fivemerrLogs", "")
@@ -48,23 +48,13 @@ end
---------------------------------------------------- inventory catcher
local invname = ''
CreateThread(function()
if GetResourceState('ps-inventory') == 'started' then
invname = 'ps-inventory'
elseif GetResourceState('qb-inventory') == 'started' then
invname = 'qb-inventory'
else
invname = 'inventory'
end
end)
local inventory = ''
CreateThread(function()
if GetResourceState('ox_inventory') == 'started' then
inventory = 'ox'
else
inventory = 'qb'
end
if GetResourceState('ps-inventory') == 'started' then
invname = 'ps-inventory'
elseif GetResourceState('qb-inventory') == 'started' then
invname = 'qb-inventory'
else
invname = 'inventory'
end
end)
------------------------------------ Player Stuff functions
function getPlayer(source)
@@ -114,7 +104,7 @@ function Notifys(source, text, type)
TriggerClientEvent('okokNotify:Alert', src, '', text, 4000, type, false)
else
print"^1 Look At The Config For Proper Alert Options"
end
end
end
function GetLabels(item)
@@ -126,6 +116,10 @@ function GetLabels(item)
end
end
function CUI(item, useFunction)
QBCore.Functions.CreateUseableItem(item, useFunction)
end
function Itemcheck(source, item, amount)
if inventory == 'qb' then
local Player = getPlayer(source)
+1 -1
View File
@@ -136,7 +136,7 @@ RegisterServerEvent('md-drugs:server:getheroinlabkitback', function()
end)
QBCore.Functions.CreateUseableItem('heroinlabkit', function(source, item)
CUI('heroinlabkit', function(source, item)
local src = source
local Player = getPlayer(src)
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)
QBCore.Functions.CreateUseableItem('leancup', function(source, item)
CUI('leancup', function(source, item)
if Itemcheck(source, 'leancup', 1) then
TriggerClientEvent('md-drugs:client:leancraft', source)
end
+2 -2
View File
@@ -20,7 +20,7 @@ RegisterServerEvent('md-drugs:server:getdiethylamide', function(num)
end)
QBCore.Functions.CreateUseableItem('lsdlabkit', function(source, item)
CUI('lsdlabkit', function(source, item)
local src = source
local Player = getPlayer(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
QBCore.Functions.CreateUseableItem(v.item, function(source)
CUI(v.item, function(source)
local src = source
local Player = getPlayer(src)
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
end)
QBCore.Functions.CreateUseableItem("driedmescaline", function(source, item)
CUI("driedmescaline", function(source, item)
local src = source
if RemoveItem(src, "driedmescaline", 1) then
TriggerClientEvent("md-drugs:client:takemescaline", src)
+2 -2
View File
@@ -10,7 +10,7 @@ local function GetJob(source)
end
end
QBCore.Functions.CreateUseableItem('prescription_pad', function(source, item)
CUI('prescription_pad', function(source, item)
local src = source
local near = {}
if GetJob(src) then
@@ -38,7 +38,7 @@ end)
local pharmabottle = {'vicodinbottle', 'adderalbottle','morphinebottle','xanaxbottle'}
for m, d in pairs (pharmabottle) do
QBCore.Functions.CreateUseableItem(d, function(source, item)
CUI(d, function(source, item)
local src = source
local Player = getPlayer(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)
QBCore.Functions.CreateUseableItem('shrooms', function(source, item)
CUI('shrooms', function(source, item)
local src = source
if TriggerClientEvent('md-drugs:client:takeshrooms', src, item.name) then
RemoveItem(src, 'shrooms', 1)
+22 -24
View File
@@ -79,19 +79,13 @@ end)
local bluntwrap = {'mdreddextro','mdlean'}
for k, v in pairs (bluntwrap) do
QBCore.Functions.CreateUseableItem(v, function(source, item)
local src = source
TriggerClientEvent('md-drugs:client:makeBluntWrap', src)
end)
CUI(v, function(source, item) TriggerClientEvent('md-drugs:client:makeBluntWrap', source) end)
end
local bluntwraps = {'leanbluntwrap', 'dextrobluntwrap', 'bluntwrap'}
for k, v in pairs (bluntwraps) do
QBCore.Functions.CreateUseableItem(v, function(source, item)
local src = source
TriggerClientEvent('md-drugs:client:rollBlunt', source)
end)
CUI(v, function(source, item) TriggerClientEvent('md-drugs:client:rollBlunt', source) end)
end
@@ -109,29 +103,33 @@ RegisterServerEvent('md-drugs:server:makeoil', function(data)
if not GetRecipe(src, 'weed', 'oil', 'shatter') then return end
end)
QBCore.Functions.CreateUseableItem("dabrig", function(source, item)
local src = source
local Player = getPlayer(src)
if Player.Functions.GetItemByName("butanetorch") then
if RemoveItem(src, "shatter", 1) then
TriggerClientEvent("md-drugs:client:dodabs", src)
CUI("dabrig", function(source, item)
local src = source
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)
QBCore.Functions.CreateUseableItem("weedgrinder", function(source, item)
local src = source
CUI("weedgrinder", function(source, item)
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')
if not check then return end
if RemoveItem(src, "drycannabis",1 ) then
AddItem(src, "grindedweed", 1)
else
Notifys(src,'You Need Dried Weed', 'error')
end
if RemoveItem(src, "drycannabis",1 ) then
AddItem(src, "grindedweed", 1)
end
end)
QBCore.Functions.CreateUseableItem("mdwoods", function(source, item)
CUI("mdwoods", function(source, item)
local src = source
local Player = getPlayer(src)
local check = lib.callback.await('md-drugs:client:uncuff', src, 'Breaking Blunt Open')
@@ -140,4 +138,4 @@ QBCore.Functions.CreateUseableItem("mdwoods", function(source, item)
AddItem(src, "bluntwrap", 5)
AddItem(src, "tobacco", 5)
end
end)
end)
+1 -1
View File
@@ -16,7 +16,7 @@ local Price = {
}
for k, v in pairs (burners) do
QBCore.Functions.CreateUseableItem(k, function(source, item)
CUI(k, function(source, item)
local src = source
local Player = getPlayer(src)
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'},
}
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 Player = getPlayer(src)
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.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.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.weedjob = "" -- what the job name is
Config.Badtrip = 20 -- number means % chance to spawn a clone that chases and attacks while on mescaline