- fix up heroin
This commit is contained in:
1 parent
1b29aaa3b0
commit
4fdef3cf30
8 files changed
+795
-476
No files matched your search
+102
-102
@@ -1,4 +1,5 @@
|
||||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
local prices = {
|
||||
heroinlabkitprice = 10000
|
||||
}
|
||||
@@ -38,10 +39,9 @@ function heroinCooldown(loc)
|
||||
end
|
||||
|
||||
ps.registerCallback('removeCleaningkit', function(source)
|
||||
local Player = getPlayer(source)
|
||||
for k, v in pairs(heroinLabKits) do
|
||||
if v.ownerid == Player.PlayerData.citizenid then
|
||||
RemoveItem(source, 'cleaningkit', 1)
|
||||
if v.ownerid == ps.getIdentifier(source) then
|
||||
ps.removeItem(source, 'cleaningkit', 1)
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -49,20 +49,21 @@ ps.registerCallback('removeCleaningkit', function(source)
|
||||
end)
|
||||
|
||||
RegisterServerEvent("heroin:pickupCane", function(loc)
|
||||
if CheckDist(source, h[loc].location) then return end
|
||||
local src = source
|
||||
if ps.checkDistance(src, h[loc].location, 3.0) then return end
|
||||
if not h[loc].taken then
|
||||
h[loc].taken = true
|
||||
GlobalState.PoppyPlants = h
|
||||
TriggerClientEvent("heroin:removeCane", -1, loc)
|
||||
heroinCooldown(loc)
|
||||
AddItem(source, 'poppyresin', 1)
|
||||
ps.addItem(src, 'poppyresin', 1)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:dryplant', function(num)
|
||||
local src = source
|
||||
if not checkLoc(source, 'dryplant', num) then return end
|
||||
if not Itemcheck(source, 'poppyresin', 1) then return end
|
||||
if not ps.checkDistance(src, GlobalState.MDDrugsLocs.dryplant[num].loc, 3.0) then return end
|
||||
if not ps.hasItem(src, 'poppyresin', 1) then return end
|
||||
if Config.TierSystem then
|
||||
local heroin = getRep(src, 'heroin')
|
||||
if heroin <= Config.Tier1 then
|
||||
@@ -72,28 +73,28 @@ RegisterServerEvent('md-drugs:server:dryplant', function(num)
|
||||
else
|
||||
if not GetRecipe(src, 'heroin', 'dryheroin', 'tier3') then return end
|
||||
end
|
||||
else
|
||||
if not GetRecipe(src, 'heroin', 'dryheroin', 'tier1') then return end
|
||||
return
|
||||
end
|
||||
if not GetRecipe(src, 'heroin', 'dryheroin', 'tier1') then return end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:cutheroin', function(num)
|
||||
local src = source
|
||||
local Player = getPlayer(src)
|
||||
if not checkLoc(source, 'cutheroinone', num) then return end
|
||||
if not Itemcheck(src, 'bakingsoda', 1) then return end
|
||||
if not ps.checkDistance(src, GlobalState.MDDrugsLocs.cutheroinone[num].loc, 3.0) then return end
|
||||
if not ps.hasItem(src, 'bakingsoda', 1) then return end
|
||||
if Config.TierSystem then
|
||||
local rawh = Player.Functions.GetItemByName('heroin')
|
||||
local rawh2 = Player.Functions.GetItemByName('heroinstagetwo')
|
||||
local rawh3 = Player.Functions.GetItemByName('heroinstagethree')
|
||||
if rawh then
|
||||
if not GetRecipe(src, 'heroin', 'cutheroin', 'tier1') then return end
|
||||
elseif rawh2 then
|
||||
if not GetRecipe(src, 'heroin', 'cutheroin', 'tier2') then return end
|
||||
elseif rawh3 then
|
||||
if not GetRecipe(src, 'heroin', 'cutheroin', 'tier3') then return end
|
||||
else
|
||||
Notifys(src, Lang.Heroin.noheroin, "error")
|
||||
local itemList = {
|
||||
heroin = 'tier1',
|
||||
heroinstagetwo = 'tier2',
|
||||
heroinstagethree = 'tier3'
|
||||
}
|
||||
for k, v in pairs(itemList) do
|
||||
local cuth = ps.hasItem(src, k)
|
||||
if cuth then
|
||||
if not GetRecipe(src, 'heroin', 'cutheroin', v) then return end
|
||||
AddRep(src, 'heroin')
|
||||
return
|
||||
end
|
||||
end
|
||||
else
|
||||
if not GetRecipe(src, 'heroin', 'cutheroin', 'tier1') then return end
|
||||
@@ -102,22 +103,19 @@ end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:getheroinlabkit', function()
|
||||
local src = source
|
||||
local Player = getPlayer(src)
|
||||
if not checkLoc(source, 'singleSpot', 'buyheroinlabkit') then return end
|
||||
local has = Player.Functions.GetItemByName('heroinlabkit')
|
||||
if has then Notifys(src, Lang.Heroin.haskit, 'error') return end
|
||||
if Player.Functions.RemoveMoney('cash', prices.heroinlabkitprice) then
|
||||
AddItem(src, 'heroinlabkit', 1)
|
||||
if not ps.checkDistance(src, GlobalState.MDDrugsLocs.singleSpot.buyheroinlabkit, 3.0) then return end
|
||||
local has = ps.hasItem(src, 'heroinlabkit')
|
||||
if has then ps.notify(src, Lang.Heroin.haskit, 'error') return end
|
||||
if ps.removeMoney(src, 'cash', prices.heroinlabkitprice) then
|
||||
ps.addItem(src, 'heroinlabkit', 1)
|
||||
else
|
||||
Notifys(src, 'You Need '.. prices.heroinlabkitprice .. ' In Cash For This', 'error')
|
||||
ps.notify(src, 'You Need '.. prices.heroinlabkitprice .. ' In Cash For This', 'error')
|
||||
end
|
||||
end)
|
||||
|
||||
local function hasHKit(src)
|
||||
local src = source
|
||||
local Player = getPlayer(src)
|
||||
for k, v in pairs(heroinLabKits) do
|
||||
if v.ownerid == Player.PlayerData.citizenid then
|
||||
if v.ownerid == ps.getIdentifier(src) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -126,51 +124,49 @@ end
|
||||
|
||||
RegisterServerEvent('md-drugs:server:getheroinlabkitback', function()
|
||||
local src = source
|
||||
local Player = getPlayer(src)
|
||||
if not hasHKit(src) then return end
|
||||
for k, v in pairs (heroinLabKits) do
|
||||
if v.ownerid == Player.PlayerData.citizenid then
|
||||
if v.ownerid == ps.getIdentifier(src) then
|
||||
table.remove(heroinLabKits, k)
|
||||
AddItem(src, 'heroinlabkit', 1)
|
||||
ps.addItem(src, 'heroinlabkit', 1)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
CUI('heroinlabkit', function(source, item)
|
||||
ps.createUseable('heroinlabkit', function(source, item)
|
||||
local src = source
|
||||
local Player = getPlayer(src)
|
||||
if not Itemcheck(source, 'heroinlabkit', 1) then return end
|
||||
if not ps.hasItem(src, 'heroinlabkit', 1) then return end
|
||||
local placed, loc = ps.callback('md-drugs:client:setheroinlabkit', src)
|
||||
if placed then
|
||||
RemoveItem(src, 'heroinlabkit', 1)
|
||||
ps.removeItem(src, 'heroinlabkit', 1)
|
||||
table.insert(heroinLabKits, {
|
||||
src = src,
|
||||
ownerid = Player.PlayerData.citizenid,
|
||||
src = src,
|
||||
ownerid = ps.getIdentifier(src),
|
||||
coords = loc,
|
||||
name = GetName(src)
|
||||
name = ps.getPlayerName(src)
|
||||
})
|
||||
Notifys(src, Lang.Heroin.placed, "success")
|
||||
ps.notify(src, Lang.Heroin.placed, "success")
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:heatliquidheroin', function()
|
||||
local src = source
|
||||
local Player = getPlayer(src)
|
||||
local src = source
|
||||
if not hasHKit(src) then return end
|
||||
if not Itemcheck(source, 'emptyvial', 1) then return end
|
||||
if not ps.itemCheck(src, 'emptyvial', 1) then return end
|
||||
if Config.TierSystem then
|
||||
local cuth = Player.Functions.GetItemByName('heroincut')
|
||||
local cuth2 = Player.Functions.GetItemByName('heroincutstagetwo')
|
||||
local cuth3 = Player.Functions.GetItemByName('heroincutstagethree')
|
||||
if cuth then
|
||||
if not GetRecipe(src, 'heroin', 'fillvial', 'tier1') then return end
|
||||
elseif cuth2 then
|
||||
if not GetRecipe(src, 'heroin', 'fillvial', 'tier2') then return end
|
||||
elseif cuth3 then
|
||||
if not GetRecipe(src, 'heroin', 'fillvial', 'tier3') then return end
|
||||
else
|
||||
Notifys(src, 'no cut heroin', "error")
|
||||
local itemList = {
|
||||
heroincut = 'tier1',
|
||||
heroincutstagetwo = 'tier2',
|
||||
heroincutstagethree = 'tier3'
|
||||
}
|
||||
for k, v in pairs(itemList) do
|
||||
local cuth = ps.hasItem(src, k)
|
||||
if cuth then
|
||||
if not GetRecipe(src, 'heroin', 'fillvial', v) then return end
|
||||
AddRep(src, 'heroin')
|
||||
return
|
||||
end
|
||||
end
|
||||
else
|
||||
if not GetRecipe(src, 'heroin', 'fillvial', 'tier1') then return end
|
||||
@@ -178,46 +174,46 @@ local Player = getPlayer(src)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:failheatingheroin', function()
|
||||
local src = source
|
||||
local Player = getPlayer(src)
|
||||
if not hasHKit(src) then return end
|
||||
local cuth = Player.Functions.GetItemByName('heroincut')
|
||||
local cuth2 = Player.Functions.GetItemByName('heroincutstagetwo')
|
||||
local cuth3 = Player.Functions.GetItemByName('heroincutstagethree')
|
||||
if cuth then
|
||||
RemoveItem(src, 'heroincut', 1)
|
||||
Notifys(src,Lang.Heroin.fail, "error")
|
||||
elseif cuth2 then
|
||||
RemoveItem(src, 'heroincutstagetwo', 1)
|
||||
Notifys(src,Lang.Heroin.fail, "error")
|
||||
elseif cuth3 then
|
||||
RemoveItem(src, 'heroincutstagethree', 1)
|
||||
Notifys(src,Lang.Heroin.fail, "error")
|
||||
local src = source
|
||||
if not hasHKit(src) then return end
|
||||
local itemList = {
|
||||
heroincut = 1,
|
||||
heroincutstagetwo = 1,
|
||||
heroincutstagethree = 1
|
||||
}
|
||||
for k, v in pairs(itemList) do
|
||||
local cuth = ps.hasItem(src, k)
|
||||
if cuth then
|
||||
ps.removeItem(src, k, v)
|
||||
ps.notify(src, Lang.Heroin.fail, "error")
|
||||
return
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:fillneedle', function(num)
|
||||
local src = source
|
||||
local Player = getPlayer(src)
|
||||
if not checkLoc(source, 'fillneedle', num) then return end
|
||||
if not Itemcheck(src, 'needle', 1) then return end
|
||||
if not ps.checkDistance(src, GlobalState.MDDrugsLocs.fillneedle[num].loc, 3.0) then
|
||||
ps.notify(src, Lang.Heroin.noloc, 'error')
|
||||
return
|
||||
end
|
||||
if not ps.hasItem(src, 'needle', 1) then return end
|
||||
if Config.TierSystem then
|
||||
local heroin = getRep(src, 'heroin')
|
||||
local vh = Player.Functions.GetItemByName('heroinvial')
|
||||
local vh2 = Player.Functions.GetItemByName('heroinvialstagetwo')
|
||||
local vh3 = Player.Functions.GetItemByName('heroinvialstagethree')
|
||||
if vh then
|
||||
if not GetRecipe(src, 'heroin', 'fillneedle', 'tier1') then return end
|
||||
AddRep(src, 'heroin')
|
||||
elseif vh2 then
|
||||
if not GetRecipe(src, 'heroin', 'fillneedle', 'tier2') then return end
|
||||
AddRep(src, 'heroin')
|
||||
elseif vh3 then
|
||||
if not GetRecipe(src, 'heroin', 'fillneedle', 'tier3') then return end
|
||||
AddRep(src, 'heroin')
|
||||
else
|
||||
Notifys(src,Lang.Heroin.nofill, "error")
|
||||
local itemList = {
|
||||
{item = 'heroinvial', tier = 'tier1', log = ' Filled Heroin Needle'},
|
||||
{item = 'heroinvialstagetwo', tier = 'tier2', log = ' Filled Heroin Needle tier 2'},
|
||||
{item = 'heroinvialstagethree', tier = 'tier3', log = ' Filled Heroin Needle tier 3'}
|
||||
}
|
||||
for k, v in pairs(itemList) do
|
||||
local vh = ps.hasItem(src, v.item)
|
||||
if vh then
|
||||
if not GetRecipe(src, 'heroin', 'fillneedle', v.tier) then return end
|
||||
AddRep(src, 'heroin')
|
||||
Log(ps.getPlayerName(src) .. v.log, 'heroin')
|
||||
return
|
||||
end
|
||||
end
|
||||
ps.notify(src,Lang.Heroin.nofill, "error")
|
||||
else
|
||||
if not GetRecipe(src, 'heroin', 'fillneedle', 'tier1') then return end
|
||||
end
|
||||
@@ -225,28 +221,32 @@ end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:failheroin', function()
|
||||
local src = source
|
||||
local Player = getPlayer(src)
|
||||
Log(GetName(src) ..' Sucks And Burned Their Heroin', 'heroin')
|
||||
Log(ps.getPlayerName(src) ..' Sucks And Burned Their Heroin', 'heroin')
|
||||
if Config.TierSystem then
|
||||
local vh = Player.Functions.GetItemByName('heroinvial')
|
||||
local vh2 = Player.Functions.GetItemByName('heroinvialstagetwo')
|
||||
local vh3 = Player.Functions.GetItemByName('heroinvialstagethree')
|
||||
if vh then RemoveItem(src, 'heroinvialstagethree', 1 )
|
||||
elseif vh2 then RemoveItem(src, 'heroinvialstagetwo', 1)
|
||||
elseif vh3 then RemoveItem(src, 'heroinvial', 1)
|
||||
local itemList = {
|
||||
heroinvial = 1,
|
||||
heroinvialstagetwo = 1,
|
||||
heroinvialstagethree = 1
|
||||
}
|
||||
for k, v in pairs (itemList) do
|
||||
local cuth = ps.hasItem(src, k)
|
||||
if cuth then
|
||||
ps.removeItem(src, k, v)
|
||||
ps.notify(src, Lang.Heroin.failneedle, "error")
|
||||
return
|
||||
end
|
||||
end
|
||||
else
|
||||
RemoveItem(src, 'heroinvial', 1)
|
||||
ps.removeItem(src, 'heroinvial', 1)
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('playerDropped', function()
|
||||
local src = source
|
||||
local Player = getPlayer(src)
|
||||
for k, v in pairs(heroinLabKits) do
|
||||
if v.src == src then
|
||||
table.remove(heroinLabKits, k)
|
||||
AddItem(src, 'heroinlabkit', 1)
|
||||
ps.addItem(src, 'heroinlabkit', 1)
|
||||
end
|
||||
end
|
||||
end)
|
||||
Reference in new issue
Block a user