- big update to labs
This commit is contained in:
1 parent
eaec5fc40f
commit
0956b1d49c
9 files changed
+547
-33
No files matched your search
+9
-2
@@ -2,6 +2,8 @@
|
||||
local cuttingcoke = nil
|
||||
local baggingcoke = nil
|
||||
local locations = ps.callback('md-drugs:server:GetCokeLocations')
|
||||
|
||||
|
||||
local function CutCoke(coords, offset, rotation)
|
||||
local animDict, animName = "anim@amb@business@coc@coc_unpack_cut_left@", "coke_cut_v5_coccutter"
|
||||
ps.requestAnim(animDict, 500)
|
||||
@@ -125,8 +127,9 @@ for k, v in pairs (locations.MakePowder) do
|
||||
TriggerServerEvent("md-drugs:server:makepowder", k)
|
||||
end,
|
||||
canInteract = function()
|
||||
return handleGang(v.gang)
|
||||
end
|
||||
if cocaineLab then return false end
|
||||
return handleGang(v.gang)
|
||||
end
|
||||
}
|
||||
})
|
||||
end
|
||||
@@ -145,6 +148,7 @@ for k, v in pairs (locations.CuttingCoke) do
|
||||
TriggerServerEvent("md-drugs:server:cutcokeone", k)
|
||||
end,
|
||||
canInteract = function()
|
||||
if cocaineLab then return false end
|
||||
if not handleGang(v.gang) then return false end
|
||||
if cuttingcoke ~= nil or baggingcoke ~= nil then return false end
|
||||
return true
|
||||
@@ -167,6 +171,7 @@ for k, v in pairs (locations.BaggingCoke) do
|
||||
TriggerServerEvent("md-drugs:server:bagcoke", k)
|
||||
end,
|
||||
canInteract = function()
|
||||
if cocaineLab then return false end
|
||||
if not handleGang(v.gang) then return false end
|
||||
if cuttingcoke ~= nil or baggingcoke ~= nil then return false end
|
||||
return true
|
||||
@@ -184,6 +189,7 @@ for k, v in pairs (locations.cokeTele) do
|
||||
SetEntityCoords(PlayerPedId(), v.outside)
|
||||
end,
|
||||
canInteract = function()
|
||||
if cocaineLab then return false end
|
||||
return handleGang(v.gang)
|
||||
end
|
||||
}
|
||||
@@ -196,6 +202,7 @@ for k, v in pairs (locations.cokeTele) do
|
||||
SetEntityCoords(PlayerPedId(), v.inside)
|
||||
end,
|
||||
canInteract = function()
|
||||
if cocaineLab then return false end
|
||||
return handleGang(v.gang)
|
||||
end
|
||||
}
|
||||
|
||||
@@ -0,0 +1,344 @@
|
||||
local inside = false
|
||||
local peds = {}
|
||||
cocaineLab = false
|
||||
local insideLocation = nil
|
||||
|
||||
local function CutCoke(coords, offset, rotation)
|
||||
CreateThread(function()
|
||||
local animDict, animName = "anim@amb@business@coc@coc_unpack_cut_left@", "coke_cut_v5_coccutter"
|
||||
ps.requestAnim(animDict, 500)
|
||||
local animDuration = GetAnimDuration(animDict, animName) * 1000
|
||||
if not peds['CutCoke'] then
|
||||
ps.requestModel('ig_priest', 500)
|
||||
peds['CutCoke'] = CreatePed(4, 'ig_priest', coords.x + 1.0, coords.y + 1.0, coords.z - 1.0, 0.0, true, true)
|
||||
FreezeEntityPosition(peds['CutCoke'], true)
|
||||
SetEntityInvincible(peds['CutCoke'], true)
|
||||
SetBlockingOfNonTemporaryEvents(peds['CutCoke'], true)
|
||||
end
|
||||
local ped = peds['CutCoke']
|
||||
local scenePos, sceneRot = vector3(coords.x + offset.x, coords.y + offset.y,coords.z + offset.z), rotation
|
||||
local scenes = {
|
||||
{
|
||||
{ hash = "bkr_prop_coke_bakingsoda_o", animName = "coke_cut_v5_bakingsoda"},
|
||||
{ hash = "prop_cs_credit_card", animName = "coke_cut_v5_creditcard"},
|
||||
{ hash = "prop_cs_credit_card", animName = "coke_cut_v5_creditcard^1"}
|
||||
},
|
||||
}
|
||||
local scenesList, entitiesList = {}, {}
|
||||
for i=1, #scenes, 1 do
|
||||
local scene = NetworkCreateSynchronisedScene(scenePos, sceneRot, 2, false, false, 1065353216, 0, 1.3)
|
||||
NetworkAddPedToSynchronisedScene(ped, scene, animDict, animName, 1.5, -4.0, 1, 16, 1148846080, 0)
|
||||
for j=1, #scenes[i], 1 do
|
||||
local s = scenes[i][j]
|
||||
RequestModel(s.hash)
|
||||
while not HasModelLoaded(s.hash) do
|
||||
Wait(0)
|
||||
end
|
||||
local obj = CreateObjectNoOffset(s.hash, coords, true, true, true)
|
||||
SetModelAsNoLongerNeeded(s.hash)
|
||||
entitiesList[#entitiesList+1] = obj
|
||||
NetworkAddEntityToSynchronisedScene(obj, scene, animDict, s.animName, 4.0, -8.0, 1)
|
||||
end
|
||||
scenesList[#scenesList+1] = scene
|
||||
end
|
||||
DisableCamCollisionForEntity(ped)
|
||||
FreezeEntityPosition(ped, true)
|
||||
for i=1, #scenesList, 1 do
|
||||
NetworkStartSynchronisedScene(scenesList[i])
|
||||
end
|
||||
|
||||
Wait(animDuration-11000)
|
||||
for i=1, #scenesList, 1 do
|
||||
NetworkStopSynchronisedScene(scenesList[i])
|
||||
end
|
||||
for i=1, #entitiesList, 1 do
|
||||
DeleteEntity(entitiesList[i])
|
||||
end
|
||||
RemoveAnimDict(animDict)
|
||||
FreezeEntityPosition(ped, false)
|
||||
if inside then
|
||||
CutCoke(coords, offset, rotation)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local function BagCoke(coords, offset, rotation)
|
||||
CreateThread(function()
|
||||
local ver = ""
|
||||
local animDict, animName = "anim@amb@business@meth@meth_smash_weight_check@", "break_weigh_"..ver.."char01"
|
||||
ps.requestAnim(animDict, 500)
|
||||
local animDuration = GetAnimDuration(animDict, animName) * 1000
|
||||
if not peds['BagCoke'] then
|
||||
ps.requestModel('ig_priest', 500)
|
||||
peds['BagCoke'] = CreatePed(4, 'ig_priest', coords.x + 1.0, coords.y + 1.0, coords.z - 1.0, 0.0, true, true)
|
||||
FreezeEntityPosition(peds['BagCoke'], true)
|
||||
SetEntityInvincible(peds['BagCoke'], true)
|
||||
SetBlockingOfNonTemporaryEvents(peds['BagCoke'], true)
|
||||
end
|
||||
local scenePos, sceneRot = vector3(coords.x + offset.x, coords.y + offset.y,coords.z + offset.z), rotation
|
||||
local scenes = {
|
||||
{
|
||||
{ hash = "bkr_prop_coke_cutblock_01", animName = "break_weigh_"..ver.."box01"},
|
||||
{ hash = "bkr_prop_coke_fullmetalbowl_02", animName = "break_weigh_"..ver.."box01^1"},
|
||||
{ hash = "bkr_prop_coke_cutblock_01", animName = "break_weigh_"..ver.."methbag01"}
|
||||
},
|
||||
{
|
||||
{ hash = "xm3_prop_xm3_bag_coke_01a", animName = "break_weigh_"..ver.."methbag01^1"},
|
||||
{ hash = "xm3_prop_xm3_bag_coke_01a", animName = "break_weigh_"..ver.."methbag01^2"},
|
||||
{ hash = "xm3_prop_xm3_bag_coke_01a", animName = "break_weigh_"..ver.."methbag01^3"}
|
||||
},
|
||||
{
|
||||
{ hash = "bkr_prop_coke_fullscoop_01a", animName = "break_weigh_"..ver.."scoop"},
|
||||
{ hash = "bkr_prop_coke_scale_01", animName = "break_weigh_"..ver.."scale"},
|
||||
{ hash = "bkr_prop_fakeid_penclipboard", animName = "break_weigh_"..ver.."pen"}
|
||||
},
|
||||
{
|
||||
{ hash = "bkr_prop_fakeid_clipboard_01a", animName = "break_weigh_"..ver.."clipboard"},
|
||||
}
|
||||
}
|
||||
local scenesList, entitiesList = {}, {}
|
||||
for i=1, #scenes, 1 do
|
||||
local scene = NetworkCreateSynchronisedScene(scenePos, sceneRot, 2, false, false, 1065353216, 0, 1.3)
|
||||
NetworkAddPedToSynchronisedScene(peds['BagCoke'], scene, animDict, animName, 1.5, -4.0, 1, 16, 1148846080, 0)
|
||||
for j=1, #scenes[i], 1 do
|
||||
local s = scenes[i][j]
|
||||
RequestModel(s.hash)
|
||||
while not HasModelLoaded(s.hash) do
|
||||
Wait(0)
|
||||
end
|
||||
local obj = CreateObjectNoOffset(s.hash, coords, true, true, true)
|
||||
SetModelAsNoLongerNeeded(s.hash)
|
||||
entitiesList[#entitiesList+1] = obj
|
||||
NetworkAddEntityToSynchronisedScene(obj, scene, animDict, s.animName, 4.0, -8.0, 1)
|
||||
end
|
||||
scenesList[#scenesList+1] = scene
|
||||
end
|
||||
DisableCamCollisionForEntity(peds['BagCoke'])
|
||||
FreezeEntityPosition(peds['BagCoke'], true)
|
||||
for i=1, #scenesList, 1 do
|
||||
NetworkStartSynchronisedScene(scenesList[i])
|
||||
end
|
||||
|
||||
Wait(animDuration-11000)
|
||||
for i=1, #scenesList, 1 do
|
||||
NetworkStopSynchronisedScene(scenesList[i])
|
||||
end
|
||||
for i=1, #entitiesList, 1 do
|
||||
DeleteEntity(entitiesList[i])
|
||||
end
|
||||
RemoveAnimDict(animDict)
|
||||
FreezeEntityPosition(peds['BagCoke'], false)
|
||||
if inside then
|
||||
BagCoke(coords, offset, rotation)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
RegisterCommand('TestMethLab', function()
|
||||
TriggerServerEvent('TestMethLab')
|
||||
Wait(2000)
|
||||
SetEntityCoords(PlayerPedId(), vector3(1004.66, -3199.98, -38.99)) -- Example coordinates
|
||||
end)
|
||||
|
||||
RegisterCommand('RestoreMethLab', function()
|
||||
TriggerServerEvent('RestoreMethLab')
|
||||
end)
|
||||
|
||||
RegisterCommand('cocaineMake', function()
|
||||
inside = true
|
||||
CutCoke(vector3(1095.61, -3195.62, -39.13), vector3(-1.782227, 0.445068, -0.502701), vector3(0,0,0))
|
||||
BagCoke(vector3(1093.16, -3195.78, -39.19), vector3(4.515137, 2.542969, -0.814194), vector3(0,0,180.0))
|
||||
end)
|
||||
|
||||
local locs = ps.callback('md-drugs:server:GetCokeLabLocations')
|
||||
|
||||
for k, v in pairs (locs) do
|
||||
v.coords = json.decode(v.coords)
|
||||
local loc = vector3(v.coords.x, v.coords.y, v.coords.z)
|
||||
ps.boxTarget('drugLabcoke'..k, loc, {},{
|
||||
{
|
||||
label = 'Purchase Lab',
|
||||
action = function()
|
||||
ps.debug(v)
|
||||
end,
|
||||
canInteract = function()
|
||||
if v.owner then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
},
|
||||
{
|
||||
label = 'Enter Lab',
|
||||
action = function()
|
||||
TriggerServerEvent('TestCokeLab', k)
|
||||
insideLocation = k
|
||||
end,
|
||||
canInteract = function()
|
||||
if v.owner == ps.getIdentifier() then return true end
|
||||
if ps.tableContains(json.decode(v.allowedIn) or {}, ps.getIdentifier()) then return true end
|
||||
return false
|
||||
end
|
||||
},
|
||||
{
|
||||
label = 'Raid Lab',
|
||||
action = function()
|
||||
ps.debug(v)
|
||||
end,
|
||||
canInteract = function()
|
||||
if v.owner and ps.getJobType() == 'leo' then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
ps.boxTarget('cokelabLeave', vector3(1088.64, -3187.21, -38.24), {length = 1.0, width = 1.0, height = 1.0, rotation = 180.0}, {
|
||||
{
|
||||
label = 'Leave Lab',
|
||||
action = function()
|
||||
inside = false
|
||||
cocaineLab = false
|
||||
TriggerServerEvent('RestoreCokeLab', insideLocation)
|
||||
for k, v in pairs(peds) do
|
||||
DeleteEntity(v)
|
||||
end
|
||||
end,
|
||||
canInteract = function()
|
||||
return inside and cocaineLab
|
||||
end
|
||||
}
|
||||
})
|
||||
|
||||
local function getInputData()
|
||||
if Config.TierSystem then
|
||||
return {
|
||||
{required = true, min = 0, type = 'number', title = ps.getLabel('coca_leaf'), max = ps.getItemCount('coca_leaf')},
|
||||
{required = true, min = 0, type = 'number', title = ps.getLabel('bakingsoda'), max = ps.getItemCount('bakingsoda')},
|
||||
{required = true, min = 0, type = 'number', title = ps.getLabel('loosecoke'), max = ps.getItemCount('loosecoke')},
|
||||
{required = true, min = 0, type = 'number', title = ps.getLabel('loosecokestagetwo'), max = ps.getItemCount('loosecokestagetwo')},
|
||||
{required = true, min = 0, type = 'number', title = ps.getLabel('loosecokestagethree'), max = ps.getItemCount('loosecokestagethree')},
|
||||
{required = true, min = 0, type = 'number', title = ps.getLabel('empty_weed_bag'), max = ps.getItemCount('empty_weed_bag')},
|
||||
}
|
||||
end
|
||||
return {
|
||||
{required = true, min = 0, type = 'number', title = ps.getLabel('coca_leaf'), max = ps.getItemCount('coca_leaf')},
|
||||
{required = true, min = 0, type = 'number', title = ps.getLabel('bakingsoda'), max = ps.getItemCount('bakingsoda')},
|
||||
{required = true, min = 0, type = 'number', title = ps.getLabel('loosecoke'), max = ps.getItemCount('loosecoke')},
|
||||
{required = true, min = 0, type = 'number', title = ps.getLabel('empty_weed_bag'), max = ps.getItemCount('empty_weed_bag')},
|
||||
}
|
||||
end
|
||||
|
||||
local function returnResults(data)
|
||||
if Config.TierSystem then
|
||||
local Items = {
|
||||
coca_leaf = data[1] or 0,
|
||||
bakingsoda = data[2] or 0,
|
||||
loosecoke = data[3] or 0,
|
||||
loosecokestagetwo = data[4] or 0,
|
||||
loosecokestagethree = data[5] or 0,
|
||||
empty_weed_bag = data[6] or 0,
|
||||
}
|
||||
for k, v in pairs (Items) do
|
||||
if v == 0 then
|
||||
Items[k] = nil
|
||||
end
|
||||
end
|
||||
return Items
|
||||
end
|
||||
local Items = {
|
||||
coca_leaf = data[1] or 0,
|
||||
bakingsoda = data[2] or 0,
|
||||
loosecoke = data[3] or 0,
|
||||
empty_weed_bag = data[4] or 0,
|
||||
}
|
||||
for k, v in pairs (Items) do
|
||||
if v == 0 then
|
||||
Items[k] = nil
|
||||
end
|
||||
end
|
||||
return Items
|
||||
end
|
||||
|
||||
local function getDescript(employee)
|
||||
local strings = ''
|
||||
strings = strings .. 'Hiring Cost: $' .. employee.salary * 10 .. '\n'
|
||||
strings = strings .. 'Salary: $'..employee.salary..'\n'
|
||||
strings = strings .. 'Job: ' .. employee.type..'\n'
|
||||
strings = strings .. 'Skills: \n'
|
||||
for k, v in pairs (json.decode(employee.skills) or {}) do
|
||||
strings = strings .. '- ' .. k .. ': ' .. v .. '\n'
|
||||
end
|
||||
return strings
|
||||
end
|
||||
|
||||
ps.boxTarget('cokeLabManagement', vector3(1099.67, -3193.13, -38.99), {length = 1.0, width = 1.0, height = 1.0, rotation = 0.0}, {
|
||||
{
|
||||
label = 'Hire Employees',
|
||||
action = function()
|
||||
local employees = ps.callback('md-drugs:server:GetAvailableEmployees')
|
||||
local options = {}
|
||||
for k,v in pairs (employees) do
|
||||
options[#options+1] = {
|
||||
title = v.name,
|
||||
description = getDescript(v),
|
||||
action = function()
|
||||
TriggerServerEvent('md-drugs:server:HireEmployee', v.id)
|
||||
end,
|
||||
}
|
||||
end
|
||||
ps.menu('Drug Employees', 'Drug Employees', options)
|
||||
end,
|
||||
--canInteract = function()
|
||||
-- return inside and cocaineLab
|
||||
--end
|
||||
},
|
||||
{
|
||||
label = 'Input Stock',
|
||||
action = function()
|
||||
local input = ps.input('Enter the amount of stock to add:',getInputData())
|
||||
if not input or not input[1] then return end
|
||||
TriggerServerEvent('md-drugs:server:cokeAddStock', returnResults(input))
|
||||
end,
|
||||
},
|
||||
{
|
||||
label = 'Take Drugs',
|
||||
action = function()
|
||||
local itemData = ps.callback('md-drugs:server:getCokeLabItemCount')
|
||||
if not itemData.input or #itemData.input == 0 then
|
||||
ps.notify('No drugs available to take.', 'error')
|
||||
return
|
||||
end
|
||||
local input = ps.input('Enter the amount of drugs to take:', itemData.input)
|
||||
if not input or not input[1] then return end
|
||||
local itemList = {}
|
||||
for i = 1, #input do
|
||||
local itemInfo = itemData.input[i]
|
||||
local value = tonumber(input[i])
|
||||
|
||||
if not value or value < 0 then
|
||||
ps.notify('Invalid amount entered.', 'error')
|
||||
return
|
||||
end
|
||||
|
||||
if value > 0 and itemInfo and itemInfo.item then
|
||||
itemList[itemInfo.item] = value
|
||||
end
|
||||
end
|
||||
ps.debug(itemList)
|
||||
TriggerServerEvent('md-drugs:server:cokeTakeDrugs', itemList)
|
||||
end,
|
||||
--canInteract = function()
|
||||
-- return inside and cocaineLab
|
||||
--end
|
||||
}
|
||||
})
|
||||
|
||||
RegisterNetEvent('md-drugs:client:EnterCokeLab', function()
|
||||
inside = true
|
||||
cocaineLab = true
|
||||
CutCoke( vector3(1095.61, -3195.62, -39.13), vector3(-1.782227, 0.445068, -0.502701), vector3(0,0,0))
|
||||
BagCoke(vector3(1093.16, -3195.78, -39.19), vector3(4.515137, 2.542969, -0.814194), vector3(0,0,180.0))
|
||||
end)
|
||||
+2
-5
@@ -4,6 +4,7 @@ description "drugs by mustache dom"
|
||||
fx_version "cerulean"
|
||||
game "gta5"
|
||||
version '3.9.0'
|
||||
|
||||
client_scripts {
|
||||
'client/functions.lua',
|
||||
'client/animationsandfunctions.lua',
|
||||
@@ -12,10 +13,10 @@ client_scripts {
|
||||
}
|
||||
|
||||
server_scripts {
|
||||
'@oxmysql/lib/MySQL.lua',
|
||||
'server/functions.lua',
|
||||
'server/plantSpawns.lua',
|
||||
'serverRun.lua',
|
||||
'@oxmysql/lib/MySQL.lua',
|
||||
}
|
||||
|
||||
shared_scripts {
|
||||
@@ -25,11 +26,7 @@ shared_scripts {
|
||||
lua54 'yes'
|
||||
|
||||
files {
|
||||
'stream/mushroom.ytyp',
|
||||
'stream/mushroom.ydr',
|
||||
'client/**.lua',
|
||||
'server/**.lua',
|
||||
'locales/**.lua'
|
||||
}
|
||||
|
||||
data_file 'DLC_ITYP_REQUEST' 'stream/mushroom.ytyp'
|
||||
@@ -0,0 +1,156 @@
|
||||
local locations = MySQL.query.await('SELECT * FROM druglabs WHERE type = ?', {'cocaine'})
|
||||
|
||||
ps.registerCallback('md-drugs:server:GetCokeLabLocations', function()
|
||||
return locations
|
||||
end)
|
||||
|
||||
RegisterNetEvent('TestCokeLab', function(num)
|
||||
local src = source
|
||||
saveBucket(src, num)
|
||||
SetEntityCoords(GetPlayerPed(src), vector3(1088.62, -3187.54, -38.99))
|
||||
TriggerClientEvent('md-drugs:client:EnterCokeLab', src)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('RestoreCokeLab', function(num)
|
||||
local src = source
|
||||
restoreBucket(src)
|
||||
local loc = json.decode(locations[num].coords)
|
||||
SetEntityCoords(GetPlayerPed(src), vector3(loc.x, loc.y, loc.z))
|
||||
end)
|
||||
|
||||
ps.registerCallback('md-drugs:server:GetAvailableEmployees',function(source)
|
||||
local src = source
|
||||
local identifier = ps.getIdentifier(src)
|
||||
local hasLab = MySQL.query.await('SELECT * FROM druglabs WHERE owner = ?', {identifier})
|
||||
if hasLab and #hasLab > 0 then
|
||||
return MySQL.query.await('SELECT * FROM drug_employees', {})
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('md-drugs:server:HireEmployee', function(employeeId)
|
||||
local src = source
|
||||
local identifier = ps.getIdentifier(src)
|
||||
|
||||
local hasLab = MySQL.query.await('SELECT * FROM druglabs WHERE owner = ?', {identifier})
|
||||
if not hasLab or #hasLab == 0 then
|
||||
ps.notify(src, 'You do not own a drug lab.', 'error')
|
||||
return
|
||||
end
|
||||
|
||||
local employee = MySQL.query.await('SELECT * FROM drug_employees WHERE id = ?', {employeeId})
|
||||
if not employee or #employee == 0 then
|
||||
ps.notify(src, 'Employee not found.', 'error')
|
||||
return
|
||||
end
|
||||
|
||||
local employeeData = employee[1]
|
||||
local currentEmployees = json.decode(hasLab[1].employees) or {}
|
||||
|
||||
for _, emp in ipairs(currentEmployees) do
|
||||
if emp.type == employeeData.type then
|
||||
ps.notify(src, 'You already have an employee of this type hired.', 'error')
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if ps.removeMoney(src, 'bank', employeeData.salary * 10) then
|
||||
table.insert(currentEmployees, employeeData)
|
||||
MySQL.update.await('UPDATE druglabs SET employees = ? WHERE owner = ?', {json.encode(currentEmployees), identifier})
|
||||
MySQL.query.await('DELETE FROM drug_employees WHERE id = ?', {employeeId})
|
||||
TriggerClientEvent('md-drugs:client:EmployeeHired', src, employeeId)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('md-drugs:server:cokeAddStock',function(stock)
|
||||
local src = source
|
||||
local identifier = ps.getIdentifier(src)
|
||||
|
||||
local hasLab = MySQL.query.await('SELECT * FROM druglabs WHERE owner = ?', {identifier})
|
||||
if not hasLab or #hasLab == 0 then
|
||||
ps.notify(src, 'You do not own a drug lab.', 'error')
|
||||
return
|
||||
end
|
||||
|
||||
local stockCheck = verifyHas(src, stock)
|
||||
if not stockCheck then
|
||||
ps.notify(src, 'You do not have enough items to add to the lab.', 'error')
|
||||
return
|
||||
end
|
||||
|
||||
for item, amount in pairs(stock) do
|
||||
ps.removeItem(src, item, amount)
|
||||
end
|
||||
|
||||
local currentStock = json.decode(hasLab[1].inputItems) or {}
|
||||
for item, amount in pairs(stock) do
|
||||
currentStock[item] = (currentStock[item] or 0) + amount
|
||||
end
|
||||
MySQL.update.await('UPDATE druglabs SET inputItems = ? WHERE owner = ?', {json.encode(currentStock), identifier})
|
||||
ps.notify(src, 'Stock added to your lab successfully.', 'success')
|
||||
end)
|
||||
|
||||
ps.registerCallback('md-drugs:server:getCokeLabItemCount',function(source)
|
||||
local src = source
|
||||
local identifier = ps.getIdentifier(src)
|
||||
|
||||
local hasLab = MySQL.query.await('SELECT * FROM druglabs WHERE owner = ?', {identifier})
|
||||
if not hasLab or #hasLab == 0 then
|
||||
ps.notify(src, 'You do not own a drug lab.', 'error')
|
||||
return
|
||||
end
|
||||
|
||||
local stock = json.decode(hasLab[1].inputItems) or {}
|
||||
local inputData, itemOrder = {}, {}
|
||||
for item, amount in pairs(stock) do
|
||||
table.insert(inputData, {
|
||||
type = 'number',
|
||||
max = amount,
|
||||
title = ps.getItemLabel(item),
|
||||
required = true,
|
||||
min = 0,
|
||||
item = item,
|
||||
})
|
||||
itemOrder[item] = amount
|
||||
end
|
||||
return {input = inputData, order = itemOrder}
|
||||
end)
|
||||
|
||||
RegisterNetEvent('md-drugs:server:cokeTakeDrugs', function(data)
|
||||
local src = source
|
||||
local identifier = ps.getIdentifier(src)
|
||||
ps.debug(data)
|
||||
local hasLab = MySQL.query.await('SELECT * FROM druglabs WHERE owner = ?', {identifier})
|
||||
if not hasLab or #hasLab == 0 then
|
||||
ps.notify(src, 'You do not own a drug lab.', 'error')
|
||||
return
|
||||
end
|
||||
|
||||
local stock = json.decode(hasLab[1].inputItems) or {}
|
||||
if next(stock) == nil then
|
||||
ps.notify(src, 'No drugs available to take.', 'error')
|
||||
return
|
||||
end
|
||||
|
||||
for item, amount in pairs(data) do
|
||||
if not stock[item] then
|
||||
goto skip
|
||||
end
|
||||
if stock[item] < amount then
|
||||
ps.notify(src, 'Insufficient stock for ' .. ps.getItemLabel(item) .. '.', 'error')
|
||||
goto skip
|
||||
end
|
||||
if amount == 0 then
|
||||
goto skip
|
||||
end
|
||||
if ps.addItem(src, item, amount) then
|
||||
stock[item] = stock[item] - amount
|
||||
if stock[item] == 0 then
|
||||
stock[item] = nil
|
||||
end
|
||||
else
|
||||
ps.notify(src, 'Failed to add ' .. ps.getItemLabel(item) .. ' to your inventory.', 'error')
|
||||
end
|
||||
::skip::
|
||||
end
|
||||
MySQL.update.await('UPDATE druglabs SET inputItems = ? WHERE owner = ?', {json.encode(stock), identifier})
|
||||
end)
|
||||
@@ -16,6 +16,39 @@ function timeOut(src, event)
|
||||
timeOutThread(src)
|
||||
return false
|
||||
end
|
||||
-- Drug Labs Functions
|
||||
local Buckets = {}
|
||||
function setBucket(src, bucket)
|
||||
if src and bucket then
|
||||
Player(src).state:set('instance', bucket, true)
|
||||
SetPlayerRoutingBucket(src, bucket)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function saveBucket(src, bucket)
|
||||
Buckets[ps.getIdentifier(src)] = {original = GetEntityRoutingBucket(GetPlayerPed(src)), new = bucket}
|
||||
setBucket(src, bucket)
|
||||
end
|
||||
|
||||
function restoreBucket(src)
|
||||
local id = ps.getIdentifier(src)
|
||||
if Buckets[id] then
|
||||
setBucket(src, Buckets[id].original)
|
||||
Buckets[id] = nil
|
||||
end
|
||||
end
|
||||
|
||||
local firstNames = {'John', 'Jacob', 'Matt', 'Michael', 'Chris', 'David', 'James', 'Robert', 'William', 'Joseph', 'Daniel', 'Lucas', 'Mason', 'Ethan', 'Alexander', 'Liam'}
|
||||
local lastNames = {'Smith', 'Johnson', 'Williams', 'Jones', 'Brown', 'Davis', 'Miller', 'Wilson', 'Moore', 'Taylor', 'Anderson', 'Thomas', 'Jackson', 'White', 'Harris', 'Martin'}
|
||||
|
||||
function generateRandomName()
|
||||
local firstName = firstNames[math.random(#firstNames)]
|
||||
local lastName = lastNames[math.random(#lastNames)]
|
||||
return firstName .. ' ' .. lastName
|
||||
end
|
||||
|
||||
function verifyHas(source, items)
|
||||
local need = 0
|
||||
|
||||
+2
-26
@@ -1,36 +1,12 @@
|
||||
|
||||
local Bags = {}
|
||||
local function setBucket(src, bucket)
|
||||
if src and bucket then
|
||||
Player(src).state:set('instance', bucket, true)
|
||||
SetPlayerRoutingBucket(src, bucket)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
local function saveBags(src)
|
||||
ps.debug('Current', GetEntityRoutingBucket(GetPlayerPed(src)))
|
||||
Bags[ps.getIdentifier(src)] = {original = GetEntityRoutingBucket(GetPlayerPed(src)), new = GetEntityRoutingBucket(GetPlayerPed(src)) + 1}
|
||||
setBucket(src, Bags[ps.getIdentifier(src)].new)
|
||||
ps.debug('New', Bags[ps.getIdentifier(src)].new)
|
||||
end
|
||||
|
||||
local function restoreBags(src)
|
||||
local id = ps.getIdentifier(src)
|
||||
if Bags[id] then
|
||||
setBucket(src, Bags[id].original)
|
||||
Bags[id] = nil
|
||||
end
|
||||
end
|
||||
|
||||
RegisterNetEvent('TestMethLab', function()
|
||||
local src = source
|
||||
saveBags(src)
|
||||
saveBucket(src, 2)
|
||||
TriggerClientEvent('md-methlab:client:EnterMethLab', src)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('RestoreMethLab', function()
|
||||
local src = source
|
||||
restoreBags(src)
|
||||
restoreBucket(src)
|
||||
end)
|
||||
@@ -43,6 +43,7 @@ Config.minigametype = 'ps_circle' -- look above for options or choose none if yo
|
||||
|
||||
Config.Drugs = { -- want a drug turn on? keep it true, want it turned off, mark it false
|
||||
cocaine = true,
|
||||
cocainelab = true,
|
||||
consumables = true,
|
||||
cornerselling = true,
|
||||
crack = true,
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user