removed OnPlayerLoad and Resource Start from prop drugs to functions file to condense repeatable code

This commit is contained in:
Mustache Dom committed 2024-10-25 11:41:59 -07:00
1 parent 24877e6447
commit 99d0ae58be
6 files changed
+39 -110

No files matched your search

-13
View File
@@ -36,19 +36,6 @@ RegisterNetEvent("coke:init", function()
end
end)
AddEventHandler('onResourceStart', function(resource)
if resource == GetCurrentResourceName() then
LoadModel('prop_plant_01a')
TriggerEvent('coke:init')
end
end)
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
Wait(3000)
LoadModel('prop_plant_01a')
TriggerEvent('coke:init')
end)
AddEventHandler('onResourceStop', function(resourceName)
if GetCurrentResourceName() == resourceName then
SetModelAsNoLongerNeeded(GetHashKey('prop_plant_01a'))
+36 -19
View File
@@ -63,6 +63,10 @@ function loadParticle(dict)
SetPtfxAssetNextCall(dict)
end
function LoadModel(hash)
lib.requestModel(hash, Config.RequestModelTime)
end
function minigame()
local time = 0
local game = Config.Minigames
@@ -175,27 +179,25 @@ function minigame()
function GetImage(img)
if GetResourceState('ox_inventory') == 'started' then
local Items = exports['ox_inventory']:Items()
if Items[img]['client'] then
if Items[img]['client']['image'] then
return Items[img]['client']['image']
local itemClient = Items[img] and Items[img]['client']
if itemClient and itemClient['image'] then
return itemClient['image']
else
return "nui://ox_inventory/web/images/".. img.. '.png'
return "nui://ox_inventory/web/images/" .. img .. '.png'
end
else
return "nui://ox_inventory/web/images/".. img.. '.png'
end
elseif GetResourceState('ps-inventory') == 'started' then
return "nui://ps-inventory/html/images/".. QBCore.Shared.Items[img].image
elseif GetResourceState('lj-inventory') == 'started' then
return "nui://lj-inventory/html/images/".. QBCore.Shared.Items[img].image
elseif GetResourceState('qb-inventory') == 'started' then
return "nui://qb-inventory/html/images/".. QBCore.Shared.Items[img].image
elseif GetResourceState('qs-inventory') == 'started' then
return "nui://qs-inventory/html/img/".. QBCore.Shared.Items[img].image
elseif GetResourceState('origen_inventory') == 'started' then
return "nui://origen_inventory/html/img/".. QBCore.Shared.Items[img].image
elseif GetResourceState('core_inventory') == 'started' then
return "nui://core_inventory/html/img/".. QBCore.Shared.Items[img].image
local invs = {
['ps-inventory'] = "nui://ps-inventory/html/images/",
['lj-inventory'] = "nui://lj-inventory/html/images/",
['qb-inventory'] = "nui://qb-inventory/html/images/",
['qs-inventory'] = "nui://qs-inventory/html/img/",
['origen_inventory'] = "nui://origen_inventory/html/img/",
['core_inventory'] = "nui://core_inventory/html/img/"
}
for k, v in pairs(invs) do
if GetResourceState(k) == 'started' then
return v .. QBCore.Shared.Items[img].image
end
end
end
@@ -464,7 +466,7 @@ function AddMultiModel(model, data, num)
for k, v in pairs (data) do
table.insert(data,{
{ icon = v.icon, label = v.label, event = v.event or nil, action = v.action or nil,
onSelect = v.action,data = num,canInteract = v.canInteract or nil,
onSelect = v.action,data = num,canInteract = v.canInteract or nil, distance = 2.0
}
})
end
@@ -566,10 +568,25 @@ end
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
Wait(3000)
LoadModel('prop_plant_01b') TriggerEvent('heroin:init')
LoadModel('prop_plant_01a') TriggerEvent('coke:init')
LoadModel('prop_cactus_03') TriggerEvent('Mescaline:init')
LoadModel('mushroom') TriggerEvent('shrooms:init')
LoadModel('bkr_prop_weed_lrg_01b') TriggerEvent('weed:init')
local check = lib.callback.await('md-drugs:server:GetRep', false)
return
end)
AddEventHandler('onResourceStart', function(resource)
if resource == GetCurrentResourceName() then
LoadModel('prop_plant_01b') TriggerEvent('heroin:init')
LoadModel('prop_plant_01a') TriggerEvent('coke:init')
LoadModel('prop_cactus_03') TriggerEvent('Mescaline:init')
LoadModel('mushroom') TriggerEvent('shrooms:init')
LoadModel('bkr_prop_weed_lrg_01b') TriggerEvent('weed:init')
end
end)
local active = false
RegisterNetEvent('md-drugs:client:minusTier', function(data)
if active then return end
+1 -14
View File
@@ -3,7 +3,7 @@ local PoppyPlants = {}
local herointable = false
local function createLabKit(coord, head)
local heroinlabkit = CreateObject("v_ret_ml_tablea", coord.x, coord.y, coord.z - 1, true, false)
local heroinlabkit = CreateObject("v_ret_ml_tablea", coord.x, coord.y, coord.z - 1, true, false,false)
SetEntityHeading(heroinlabkit, head)
PlaceObjectOnGroundProperly(heroinlabkit)
local options = {
@@ -54,19 +54,6 @@ RegisterNetEvent("heroin:init", function()
end
end)
AddEventHandler('onResourceStart', function(resource)
if resource == GetCurrentResourceName() then
LoadModel('prop_plant_01b')
TriggerEvent('heroin:init')
end
end)
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
Wait(3000)
LoadModel('prop_plant_01b')
TriggerEvent('heroin:init')
end)
AddEventHandler('onResourceStop', function(resourceName)
if GetCurrentResourceName() == resourceName then
SetModelAsNoLongerNeeded(GetHashKey('prop_plant_01b'))
+1 -22
View File
@@ -1,14 +1,6 @@
local QBCore = exports['qb-core']:GetCoreObject()
local Mescaline = {}
function LoadModel(hash)
hash = GetHashKey(hash)
RequestModel(hash)
while not HasModelLoaded(hash) do
Wait(3000)
end
end
local function pick(loc)
if not progressbar(Lang.mescaline.pick, 4000, 'uncuff') then return end
TriggerServerEvent("Mescaline:pickupCane", loc)
@@ -41,20 +33,7 @@ RegisterNetEvent("Mescaline:init", function()
end
end)
AddEventHandler('onResourceStart', function(resource)
if resource == GetCurrentResourceName() then
LoadModel('prop_cactus_03')
TriggerEvent('Mescaline:init')
end
end)
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
Wait(3000)
LoadModel('prop_cactus_03')
TriggerEvent('Mescaline:init')
end)
AddEventHandler('onResourceStop', function(resourceName)
AddEventHandler('onResourceStop', function(resourceName)
if GetCurrentResourceName() == resourceName then
SetModelAsNoLongerNeeded(GetHashKey('prop_cactus_03'))
for k, v in pairs(Mescaline) do
+1 -23
View File
@@ -1,14 +1,6 @@
local QBCore = exports['qb-core']:GetCoreObject()
local shrooms = {}
function LoadModel(hash)
hash = GetHashKey(hash)
RequestModel(hash)
while not HasModelLoaded(hash) do
Wait(3000)
end
end
local function pick(loc)
if not progressbar(Lang.Shrooms.pick, 4000, 'uncuff') then return end
TriggerServerEvent("shrooms:pickupCane", loc)
@@ -24,14 +16,6 @@ RegisterNetEvent('shrooms:respawnCane', function(loc)
end
end)
AddEventHandler('onResourceStart', function(resource)
if resource == GetCurrentResourceName() then
Wait(3000)
LoadModel('mushroom')
TriggerEvent('shrooms:init')
end
end)
AddEventHandler('onResourceStop', function(resourceName)
if GetCurrentResourceName() == resourceName then
SetModelAsNoLongerNeeded(GetHashKey('mushroom'))
@@ -48,13 +32,7 @@ RegisterNetEvent('shrooms:removeCane', function(loc)
shrooms[loc] = nil
end)
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
Wait(3000)
LoadModel('mushroom')
TriggerEvent('shrooms:init')
end)
RegisterNetEvent("shrooms:init", function()
RegisterNetEvent("shrooms:init", function()
for k, v in pairs (GlobalState.shrooms) do
local hash = GetHashKey(v.model)
if not HasModelLoaded(hash) then LoadModel(hash) end
-19
View File
@@ -3,13 +3,6 @@ local WeedPlant = {}
local exploded = nil
local drying = false
function LoadModel(hash)
hash = GetHashKey(hash)
RequestModel(hash)
while not HasModelLoaded(hash) do
Wait(3000)
end
end
local function hasJob()
if Config.Joblock then
@@ -53,18 +46,6 @@ RegisterNetEvent("weed:init", function()
end
end)
AddEventHandler('onResourceStart', function(resource)
if resource == GetCurrentResourceName() then
LoadModel('bkr_prop_weed_lrg_01b')
TriggerEvent('weed:init')
end
end)
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
Wait(3000)
LoadModel('bkr_prop_weed_lrg_01b')
TriggerEvent('weed:init')
end)
AddEventHandler('onResourceStop', function(resourceName)
if GetCurrentResourceName() == resourceName then
SetModelAsNoLongerNeeded(GetHashKey('bkr_prop_weed_lrg_01b'))