removed OnPlayerLoad and Resource Start from prop drugs to functions file to condense repeatable code
This commit is contained in:
1 parent
24877e6447
commit
99d0ae58be
6 files changed
+46
-117
No files matched your search
@@ -36,19 +36,6 @@ RegisterNetEvent("coke:init", function()
|
|||||||
end
|
end
|
||||||
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)
|
AddEventHandler('onResourceStop', function(resourceName)
|
||||||
if GetCurrentResourceName() == resourceName then
|
if GetCurrentResourceName() == resourceName then
|
||||||
SetModelAsNoLongerNeeded(GetHashKey('prop_plant_01a'))
|
SetModelAsNoLongerNeeded(GetHashKey('prop_plant_01a'))
|
||||||
|
|||||||
+43
-26
@@ -63,6 +63,10 @@ function loadParticle(dict)
|
|||||||
SetPtfxAssetNextCall(dict)
|
SetPtfxAssetNextCall(dict)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function LoadModel(hash)
|
||||||
|
lib.requestModel(hash, Config.RequestModelTime)
|
||||||
|
end
|
||||||
|
|
||||||
function minigame()
|
function minigame()
|
||||||
local time = 0
|
local time = 0
|
||||||
local game = Config.Minigames
|
local game = Config.Minigames
|
||||||
@@ -173,30 +177,28 @@ function minigame()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function GetImage(img)
|
function GetImage(img)
|
||||||
if GetResourceState('ox_inventory') == 'started' then
|
if GetResourceState('ox_inventory') == 'started' then
|
||||||
local Items = exports['ox_inventory']:Items()
|
local Items = exports['ox_inventory']:Items()
|
||||||
if Items[img]['client'] then
|
local itemClient = Items[img] and Items[img]['client']
|
||||||
if Items[img]['client']['image'] then
|
if itemClient and itemClient['image'] then
|
||||||
return Items[img]['client']['image']
|
return itemClient['image']
|
||||||
else
|
else
|
||||||
return "nui://ox_inventory/web/images/".. img.. '.png'
|
return "nui://ox_inventory/web/images/" .. img .. '.png'
|
||||||
end
|
end
|
||||||
else
|
end
|
||||||
return "nui://ox_inventory/web/images/".. img.. '.png'
|
local invs = {
|
||||||
end
|
['ps-inventory'] = "nui://ps-inventory/html/images/",
|
||||||
elseif GetResourceState('ps-inventory') == 'started' then
|
['lj-inventory'] = "nui://lj-inventory/html/images/",
|
||||||
return "nui://ps-inventory/html/images/".. QBCore.Shared.Items[img].image
|
['qb-inventory'] = "nui://qb-inventory/html/images/",
|
||||||
elseif GetResourceState('lj-inventory') == 'started' then
|
['qs-inventory'] = "nui://qs-inventory/html/img/",
|
||||||
return "nui://lj-inventory/html/images/".. QBCore.Shared.Items[img].image
|
['origen_inventory'] = "nui://origen_inventory/html/img/",
|
||||||
elseif GetResourceState('qb-inventory') == 'started' then
|
['core_inventory'] = "nui://core_inventory/html/img/"
|
||||||
return "nui://qb-inventory/html/images/".. QBCore.Shared.Items[img].image
|
}
|
||||||
elseif GetResourceState('qs-inventory') == 'started' then
|
for k, v in pairs(invs) do
|
||||||
return "nui://qs-inventory/html/img/".. QBCore.Shared.Items[img].image
|
if GetResourceState(k) == 'started' then
|
||||||
elseif GetResourceState('origen_inventory') == 'started' then
|
return v .. QBCore.Shared.Items[img].image
|
||||||
return "nui://origen_inventory/html/img/".. QBCore.Shared.Items[img].image
|
end
|
||||||
elseif GetResourceState('core_inventory') == 'started' then
|
end
|
||||||
return "nui://core_inventory/html/img/".. QBCore.Shared.Items[img].image
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function GetLabel(label)
|
function GetLabel(label)
|
||||||
@@ -464,7 +466,7 @@ function AddMultiModel(model, data, num)
|
|||||||
for k, v in pairs (data) do
|
for k, v in pairs (data) do
|
||||||
table.insert(data,{
|
table.insert(data,{
|
||||||
{ icon = v.icon, label = v.label, event = v.event or nil, action = v.action or nil,
|
{ 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
|
end
|
||||||
@@ -566,9 +568,24 @@ end
|
|||||||
|
|
||||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
|
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
|
||||||
Wait(3000)
|
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)
|
local check = lib.callback.await('md-drugs:server:GetRep', false)
|
||||||
|
|
||||||
return
|
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)
|
end)
|
||||||
local active = false
|
local active = false
|
||||||
RegisterNetEvent('md-drugs:client:minusTier', function(data)
|
RegisterNetEvent('md-drugs:client:minusTier', function(data)
|
||||||
|
|||||||
+1
-14
@@ -3,7 +3,7 @@ local PoppyPlants = {}
|
|||||||
local herointable = false
|
local herointable = false
|
||||||
|
|
||||||
local function createLabKit(coord, head)
|
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)
|
SetEntityHeading(heroinlabkit, head)
|
||||||
PlaceObjectOnGroundProperly(heroinlabkit)
|
PlaceObjectOnGroundProperly(heroinlabkit)
|
||||||
local options = {
|
local options = {
|
||||||
@@ -54,19 +54,6 @@ RegisterNetEvent("heroin:init", function()
|
|||||||
end
|
end
|
||||||
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)
|
AddEventHandler('onResourceStop', function(resourceName)
|
||||||
if GetCurrentResourceName() == resourceName then
|
if GetCurrentResourceName() == resourceName then
|
||||||
SetModelAsNoLongerNeeded(GetHashKey('prop_plant_01b'))
|
SetModelAsNoLongerNeeded(GetHashKey('prop_plant_01b'))
|
||||||
|
|||||||
+1
-22
@@ -1,14 +1,6 @@
|
|||||||
local QBCore = exports['qb-core']:GetCoreObject()
|
local QBCore = exports['qb-core']:GetCoreObject()
|
||||||
local Mescaline = {}
|
local Mescaline = {}
|
||||||
|
|
||||||
function LoadModel(hash)
|
|
||||||
hash = GetHashKey(hash)
|
|
||||||
RequestModel(hash)
|
|
||||||
while not HasModelLoaded(hash) do
|
|
||||||
Wait(3000)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function pick(loc)
|
local function pick(loc)
|
||||||
if not progressbar(Lang.mescaline.pick, 4000, 'uncuff') then return end
|
if not progressbar(Lang.mescaline.pick, 4000, 'uncuff') then return end
|
||||||
TriggerServerEvent("Mescaline:pickupCane", loc)
|
TriggerServerEvent("Mescaline:pickupCane", loc)
|
||||||
@@ -41,20 +33,7 @@ RegisterNetEvent("Mescaline:init", function()
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
AddEventHandler('onResourceStart', function(resource)
|
AddEventHandler('onResourceStop', function(resourceName)
|
||||||
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)
|
|
||||||
if GetCurrentResourceName() == resourceName then
|
if GetCurrentResourceName() == resourceName then
|
||||||
SetModelAsNoLongerNeeded(GetHashKey('prop_cactus_03'))
|
SetModelAsNoLongerNeeded(GetHashKey('prop_cactus_03'))
|
||||||
for k, v in pairs(Mescaline) do
|
for k, v in pairs(Mescaline) do
|
||||||
|
|||||||
+1
-23
@@ -1,14 +1,6 @@
|
|||||||
local QBCore = exports['qb-core']:GetCoreObject()
|
local QBCore = exports['qb-core']:GetCoreObject()
|
||||||
local shrooms = {}
|
local shrooms = {}
|
||||||
|
|
||||||
function LoadModel(hash)
|
|
||||||
hash = GetHashKey(hash)
|
|
||||||
RequestModel(hash)
|
|
||||||
while not HasModelLoaded(hash) do
|
|
||||||
Wait(3000)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function pick(loc)
|
local function pick(loc)
|
||||||
if not progressbar(Lang.Shrooms.pick, 4000, 'uncuff') then return end
|
if not progressbar(Lang.Shrooms.pick, 4000, 'uncuff') then return end
|
||||||
TriggerServerEvent("shrooms:pickupCane", loc)
|
TriggerServerEvent("shrooms:pickupCane", loc)
|
||||||
@@ -24,14 +16,6 @@ RegisterNetEvent('shrooms:respawnCane', function(loc)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
AddEventHandler('onResourceStart', function(resource)
|
|
||||||
if resource == GetCurrentResourceName() then
|
|
||||||
Wait(3000)
|
|
||||||
LoadModel('mushroom')
|
|
||||||
TriggerEvent('shrooms:init')
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
AddEventHandler('onResourceStop', function(resourceName)
|
AddEventHandler('onResourceStop', function(resourceName)
|
||||||
if GetCurrentResourceName() == resourceName then
|
if GetCurrentResourceName() == resourceName then
|
||||||
SetModelAsNoLongerNeeded(GetHashKey('mushroom'))
|
SetModelAsNoLongerNeeded(GetHashKey('mushroom'))
|
||||||
@@ -48,13 +32,7 @@ RegisterNetEvent('shrooms:removeCane', function(loc)
|
|||||||
shrooms[loc] = nil
|
shrooms[loc] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
|
RegisterNetEvent("shrooms:init", function()
|
||||||
Wait(3000)
|
|
||||||
LoadModel('mushroom')
|
|
||||||
TriggerEvent('shrooms:init')
|
|
||||||
end)
|
|
||||||
|
|
||||||
RegisterNetEvent("shrooms:init", function()
|
|
||||||
for k, v in pairs (GlobalState.shrooms) do
|
for k, v in pairs (GlobalState.shrooms) do
|
||||||
local hash = GetHashKey(v.model)
|
local hash = GetHashKey(v.model)
|
||||||
if not HasModelLoaded(hash) then LoadModel(hash) end
|
if not HasModelLoaded(hash) then LoadModel(hash) end
|
||||||
|
|||||||
@@ -3,13 +3,6 @@ local WeedPlant = {}
|
|||||||
local exploded = nil
|
local exploded = nil
|
||||||
local drying = false
|
local drying = false
|
||||||
|
|
||||||
function LoadModel(hash)
|
|
||||||
hash = GetHashKey(hash)
|
|
||||||
RequestModel(hash)
|
|
||||||
while not HasModelLoaded(hash) do
|
|
||||||
Wait(3000)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function hasJob()
|
local function hasJob()
|
||||||
if Config.Joblock then
|
if Config.Joblock then
|
||||||
@@ -53,18 +46,6 @@ RegisterNetEvent("weed:init", function()
|
|||||||
end
|
end
|
||||||
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)
|
AddEventHandler('onResourceStop', function(resourceName)
|
||||||
if GetCurrentResourceName() == resourceName then
|
if GetCurrentResourceName() == resourceName then
|
||||||
SetModelAsNoLongerNeeded(GetHashKey('bkr_prop_weed_lrg_01b'))
|
SetModelAsNoLongerNeeded(GetHashKey('bkr_prop_weed_lrg_01b'))
|
||||||
|
|||||||
Reference in new issue
Block a user