- fix up heroin
This commit is contained in:
1 parent
1b29aaa3b0
commit
4fdef3cf30
8 files changed
+795
-476
No files matched your search
+85
-58
@@ -1,4 +1,4 @@
|
||||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
local DrugDeals = {}
|
||||
local Drugs = {
|
||||
["weed_white-widow"] = {rep = 1,min = 15, max = 24 },
|
||||
@@ -121,75 +121,108 @@ local Drugs = {
|
||||
["cupofdextro"] = {rep = 1,min = 18, max = 40},
|
||||
}
|
||||
|
||||
ps.registerCallback('md-drugs:server:cornerselling:getAvailableDrugs', function(source, ped)
|
||||
local Player = getPlayer(source)
|
||||
local rep = getRep(source, 'cornerselling')
|
||||
if not Player then return nil end
|
||||
local type = 0
|
||||
for k, v in pairs(Drugs) do
|
||||
local item = Player.Functions.GetItemByName(k)
|
||||
if item and type == 0 then
|
||||
type = type + 1
|
||||
Log(GetName(source) .. ' Allowed To Sell ' .. item.name .. '!' , 'cornerselling')
|
||||
local amount = math.random(1,item.amount)
|
||||
if amount >= 15 then amount = 15 end
|
||||
local price = math.random(Drugs[k]['min'], Drugs[k]['max']) * amount
|
||||
local result = math.floor(price * rep.price)
|
||||
table.insert(DrugDeals, {item = item.name, amount = amount, price = result, cid = Player.PlayerData.citizenid, ped = ped})
|
||||
return {item = item.name, amount = amount, price = result, ped = ped}
|
||||
local drugsNames = {}
|
||||
for k, v in pairs(Drugs) do
|
||||
table.insert(drugsNames, k)
|
||||
end
|
||||
GlobalState.DrugNames = drugsNames
|
||||
local robChance = 1 -- Chance To Be Robbed
|
||||
local RobbedDrugs = {}
|
||||
|
||||
local function beingRobbed(source, item, amount, ped)
|
||||
local src = source
|
||||
local math = math.random(1,100)
|
||||
if math <= robChance then
|
||||
ps.removeItem(src, item, amount)
|
||||
ps.notify(src, 'You Got Robbed Nerd', 'error')
|
||||
RobbedDrugs[ps.getIdentifier(source)] = {item = item, amount = amount, ped = ped}
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local function getDrugBack(source, item, amount)
|
||||
local src = source
|
||||
if RobbedDrugs[ps.getIdentifier(source)] then
|
||||
if RobbedDrugs[ps.getIdentifier(source)].item == item and RobbedDrugs[ps.getIdentifier(source)].amount == amount then
|
||||
ps.addItem(src, item, amount)
|
||||
ps.notify(src, 'You Got Your Drugs Back', 'success')
|
||||
RobbedDrugs[ps.getIdentifier(source)] = nil
|
||||
return true
|
||||
end
|
||||
end
|
||||
if type == 0 then
|
||||
return {item = 'nothing', amount = 0, price = 0, ped = ped}
|
||||
end
|
||||
|
||||
ps.registerCallback('md-drugs:server:cornerselling:getAvailableDrugs', function(source, ped)
|
||||
local Player = ps.getPlayer(source)
|
||||
local rep = getRep(source, 'cornerselling')
|
||||
if not Player then return nil end
|
||||
for k, v in pairs(Drugs) do
|
||||
local item = ps.getItemCount(source, k) or 0
|
||||
if item >= 1 then
|
||||
local maths = math.random(1,100)
|
||||
if maths <= robChance then
|
||||
beingRobbed(source, k, item, ped)
|
||||
return 'robbed'
|
||||
else
|
||||
if item > 15 then item = 15 end
|
||||
local amount = math.random(1, item)
|
||||
local price = (math.random(Drugs[k]['min'], Drugs[k]['max']) * amount) * rep.price
|
||||
DrugDeals[ps.getIdentifier(source)] = {item = k, amount = amount, price = math.floor(price), ped = ped}
|
||||
return DrugDeals[ps.getIdentifier(source)]
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end)
|
||||
|
||||
ps.registerCallback('md-drugs:server:hasDrugs', function(source)
|
||||
local Player = getPlayer(source)
|
||||
for k, v in pairs(Drugs) do
|
||||
local item = Player.Functions.GetItemByName(k)
|
||||
if item then
|
||||
if hasItem(source, k, 1) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end)
|
||||
|
||||
RegisterNetEvent('md-drugs:server:sellCornerDrugs', function(item, amount, price)
|
||||
local src = source
|
||||
local Player = getPlayer(src)
|
||||
local function csCheck(src, item, amount, price)
|
||||
local isIn = false
|
||||
for k, v in pairs (Drugs) do
|
||||
if item == k then
|
||||
if item == k then
|
||||
isIn = true
|
||||
end
|
||||
end
|
||||
if not isIn then return end
|
||||
for k, v in pairs (DrugDeals) do
|
||||
if v.cid == Player.PlayerData.citizenid then
|
||||
if v.item == item then
|
||||
if v.amount == amount then
|
||||
if v.price == price then
|
||||
if RemoveItem(src, item, amount) then
|
||||
if QBConfig.MarkedBills then
|
||||
local info = {
|
||||
worth = price
|
||||
}
|
||||
Player.Functions.AddItem('markedbills', 1, false, info )
|
||||
elseif QBConfig.CustomDirtyMoney == true then
|
||||
AddItem(src, QBConfig.CustomDirtyMoneyitem, price)
|
||||
else
|
||||
Player.Functions.AddMoney('cash', price)
|
||||
end
|
||||
AddRep(src, 'cornerselling', Drugs[item].rep * amount)
|
||||
Log(GetName(src) .. ' Sold ' .. amount .. ' Of ' .. item .. ' For A Price Of ' .. price .. '!' , 'cornerselling')
|
||||
table.remove(DrugDeals, k)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if not isIn then return false end
|
||||
|
||||
if DrugDeals[ps.getIdentifier(src)] then
|
||||
if DrugDeals[ps.getIdentifier(src)].item == item and DrugDeals[ps.getIdentifier(src)].amount == amount and DrugDeals[ps.getIdentifier(src)].price == price then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
RegisterNetEvent('md-drugs:server:sellCornerDrugs', function(item, amount, price)
|
||||
local src = source
|
||||
if not csCheck(src, item, amount, price) then return end
|
||||
if not ps.removeItem(src, item, amount) then
|
||||
ps.notify(src, 'You Do Not Have Enough Of This Item', 'error')
|
||||
DrugDeals[ps.getIdentifier(src)] = nil
|
||||
return
|
||||
end
|
||||
--AddRep(src, 'cornerselling', Drugs[item].rep * amount)
|
||||
Log(string.format('%s Sold %s Of %s For A Price Of $%s !', GetName(src),amount, item, price), 'cornerselling')
|
||||
DrugDeals[ps.getIdentifier(src)] = nil
|
||||
ps.addMoney(src, 'cash', price)
|
||||
|
||||
end)
|
||||
|
||||
RegisterNetEvent('md-drugs:server:getBackRobbed', function()
|
||||
local tabl = RobbedDrugs[ps.getIdentifier(source)]
|
||||
if tabl == nil then return end
|
||||
getDrugBack(source, tabl.item, tabl.amount)
|
||||
RobbedDrugs[ps.getIdentifier(source)] = nil
|
||||
end)
|
||||
|
||||
lib.addCommand('cornersell', {
|
||||
@@ -198,18 +231,12 @@ lib.addCommand('cornersell', {
|
||||
},
|
||||
}, function(source, args, raw)
|
||||
local src = source
|
||||
local Player = getPlayer(src)
|
||||
Log(GetName(source) .. ' Used Command cornersell!' , 'cornerselling')
|
||||
TriggerClientEvent('md-drugs:client:cornerselling', src)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:cornerselling:stop', function()
|
||||
local src = source
|
||||
local Player = getPlayer(src)
|
||||
for k, v in pairs (DrugDeals) do
|
||||
if v.cid == Player.PlayerData.citizenid then
|
||||
TriggerClientEvent('md-drugs:client:cornerselling:remove', src, DrugDeals[k].ped)
|
||||
table.remove(DrugDeals, k)
|
||||
end
|
||||
if DrugDeals[ps.getIdentifier(src)] then
|
||||
DrugDeals[ps.getIdentifier(src)] = nil
|
||||
end
|
||||
end)
|
||||
+314
-140
@@ -1,14 +1,25 @@
|
||||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
local QBCore, ESX, qbx = {}, {}, nil
|
||||
local notify = Config.Notify -- qb or ox
|
||||
local inventory = Config.Inventory -- qb or ox
|
||||
local invname = ''
|
||||
|
||||
------------------------------------------ logging stuff
|
||||
local logs = false
|
||||
local logapi = GetConvar("fivemerrLogs", "")
|
||||
local endpoint = 'https://api.fivemerr.com/v1/logs'
|
||||
local headers = {
|
||||
['Authorization'] = logapi,
|
||||
['Content-Type'] = 'application/json',
|
||||
}
|
||||
['Authorization'] = logapi,
|
||||
['Content-Type'] = 'application/json',
|
||||
}
|
||||
|
||||
if Config.Framework == 'qb' then
|
||||
QBCore = exports['qb-core']:GetCoreObject()
|
||||
elseif Config.Framework == 'esx' then
|
||||
ESX = exports['es_extended']:getSharedObject()
|
||||
elseif Config.Framework == 'qbx' then
|
||||
qbx = exports.qbx_core
|
||||
end
|
||||
|
||||
|
||||
CreateThread(function()
|
||||
if logs then
|
||||
@@ -24,17 +35,11 @@ end
|
||||
end)
|
||||
|
||||
function Log(message, type)
|
||||
if logs == false then return end
|
||||
local buffer = {
|
||||
level = "info",
|
||||
message = message,
|
||||
resource = GetCurrentResourceName(),
|
||||
metadata = {
|
||||
drugs = type,
|
||||
playerid = source
|
||||
}
|
||||
if logs == false then return end
|
||||
local buffer = { level = "info", message = message, resource = GetCurrentResourceName(),
|
||||
metadata = { drugs = type, playerid = source}
|
||||
}
|
||||
SetTimeout(500, function()
|
||||
SetTimeout(500, function()
|
||||
PerformHttpRequest(endpoint, function(status, _, _, response)
|
||||
if status ~= 200 then
|
||||
if type(response) == 'string' then
|
||||
@@ -43,29 +48,62 @@ if logs == false then return end
|
||||
end
|
||||
end, 'POST', json.encode(buffer), headers)
|
||||
buffer = nil
|
||||
end)
|
||||
end)
|
||||
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)
|
||||
------------------------------------ Player Stuff functions
|
||||
function getPlayer(source)
|
||||
function getPlayer(source)
|
||||
local src = source
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
return Player
|
||||
if Config.Framework == 'qb' then
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
return Player
|
||||
elseif Config.Framework == 'esx' then
|
||||
local Player = ESX.GetPlayerFromId(src)
|
||||
return Player
|
||||
elseif Config.Framework == 'qbx' then
|
||||
local Player = qbx:GetPlayer(source)
|
||||
return Player
|
||||
end
|
||||
end
|
||||
|
||||
function GetName(source)
|
||||
local Player = getPlayer(source)
|
||||
return Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname
|
||||
function getPlayerByCid(cid)
|
||||
if Config.Framework == 'qb' then
|
||||
local Player = QBCore.Functions.GetPlayerByCitizenId(cid)
|
||||
return Player
|
||||
elseif Config.Framework == 'esx' then
|
||||
local Player = ESX.GetPlayerFromIdentifier(cid)
|
||||
return Player
|
||||
elseif Config.Framework == 'qbx' then
|
||||
local Player = qbx:GetPlayerByCitizenId(cid)
|
||||
return Player
|
||||
end
|
||||
end
|
||||
|
||||
function GetName(source)
|
||||
local src = source
|
||||
if Config.Framework == 'qb' then
|
||||
local Player = getPlayer(src)
|
||||
return Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname
|
||||
elseif Config.Framework == 'esx' then
|
||||
local Player = getPlayer(src)
|
||||
return Player.getName()
|
||||
elseif Config.Framework == 'qbx' then
|
||||
local Player = getPlayer(src)
|
||||
return Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname
|
||||
end
|
||||
end
|
||||
|
||||
function getCid(source)
|
||||
local src = source
|
||||
if Config.Framework == 'qb' then
|
||||
local Player = getPlayer(src)
|
||||
return Player.PlayerData.citizenid
|
||||
elseif Config.Framework == 'esx' then
|
||||
local Player = getPlayer(src)
|
||||
return Player.getIdentifier()
|
||||
elseif Config.Framework == 'qbx' then
|
||||
local Player = getPlayer(src)
|
||||
return Player.PlayerData.citizenid
|
||||
end
|
||||
end
|
||||
|
||||
function GetCoords(source)
|
||||
@@ -78,7 +116,8 @@ function dist(source, coords)
|
||||
local playerPed = GetPlayerPed(source)
|
||||
local pcoords = GetEntityCoords(playerPed)
|
||||
local dist = #(pcoords - coords)
|
||||
return dist
|
||||
|
||||
return dist
|
||||
end
|
||||
|
||||
function CheckDist(source, coords)
|
||||
@@ -87,7 +126,7 @@ function CheckDist(source, coords)
|
||||
local ok
|
||||
if #(pcoords - coords) < 4.0 then
|
||||
return ok
|
||||
else
|
||||
else
|
||||
DropPlayer(source, 'md-drugs: You Were A Total Of ' .. #(pcoords - coords) .. ' Too Far Away To Trigger This Event')
|
||||
return false
|
||||
end
|
||||
@@ -107,7 +146,7 @@ function Notifys(source, text, type)
|
||||
end
|
||||
end
|
||||
|
||||
function GetLabels(item)
|
||||
function GetLabels(item)
|
||||
if inventory == 'qb' then
|
||||
return QBCore.Shared.Items[item].label
|
||||
elseif inventory == 'ox' then
|
||||
@@ -117,7 +156,13 @@ function GetLabels(item)
|
||||
end
|
||||
|
||||
function CUI(item, useFunction)
|
||||
QBCore.Functions.CreateUseableItem(item, useFunction)
|
||||
if Config.Framework == 'qb' then
|
||||
QBCore.Functions.CreateUseableItem(item, useFunction)
|
||||
elseif Config.Framework == 'esx' then
|
||||
ESX.RegisterUsableItem(item, useFunction)
|
||||
elseif Config.Framework == 'qbx' then
|
||||
qbx:CreateUseableItem(item, useFunction)
|
||||
end
|
||||
end
|
||||
|
||||
function Itemcheck(source, item, amount)
|
||||
@@ -131,9 +176,9 @@ function Itemcheck(source, item, amount)
|
||||
return false
|
||||
end
|
||||
elseif inventory == 'ox' then
|
||||
local items = exports.ox_inventory:GetItem(source, item, nil, false)
|
||||
local items = exports.ox_inventory:GetItem(source, item, nil, false)
|
||||
if items.count >= amount then
|
||||
return true
|
||||
return true
|
||||
else
|
||||
Notifys(source, 'You Need ' .. amount .. ' Of ' .. GetLabels(item) .. ' To Do This', 'error')
|
||||
return false
|
||||
@@ -141,13 +186,55 @@ function Itemcheck(source, item, amount)
|
||||
end
|
||||
end
|
||||
|
||||
function hasItem(source, item, amount)
|
||||
if inventory == 'qb' then
|
||||
local Player = getPlayer(source)
|
||||
local itemchecks = Player.Functions.GetItemByName(item)
|
||||
if itemchecks and itemchecks.amount >= amount then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
elseif inventory == 'ox' then
|
||||
local items = exports.ox_inventory:GetItem(source, item, nil, false)
|
||||
if items == nil then return false end
|
||||
if items.count >= amount then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function getItemCount(source, item)
|
||||
if inventory == 'qb' then
|
||||
local Player = getPlayer(source)
|
||||
local itemchecks = Player.Functions.GetItemByName(item)
|
||||
if itemchecks then
|
||||
return itemchecks.amount
|
||||
else
|
||||
return false
|
||||
end
|
||||
elseif inventory == 'ox' then
|
||||
local items = exports.ox_inventory:GetItem(source, item, nil, false)
|
||||
if items == nil then
|
||||
print('You are missing ' .. item)
|
||||
return 0
|
||||
end
|
||||
if items.count >= 1 then
|
||||
return items.count
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end
|
||||
end
|
||||
function RemoveItem(source, item, amount)
|
||||
if inventory == 'qb' then
|
||||
local Player = getPlayer(source)
|
||||
if Player.Functions.RemoveItem(item, amount) then
|
||||
TriggerClientEvent(invname ..":client:ItemBox", source, QBCore.Shared.Items[item], "remove", amount)
|
||||
return true
|
||||
else
|
||||
else
|
||||
Notifys(source, 'You Need ' .. amount .. ' Of ' .. GetLabels(item) .. ' To Do This', 'error')
|
||||
end
|
||||
elseif inventory == 'ox' then
|
||||
@@ -162,16 +249,14 @@ end
|
||||
function AddItem(source, item, amount)
|
||||
if inventory == 'qb' then
|
||||
local Player = getPlayer(source)
|
||||
if Player.Functions.AddItem(item, amount) then
|
||||
if Player.Functions.AddItem(item, amount) then
|
||||
TriggerClientEvent(invname ..":client:ItemBox", source, QBCore.Shared.Items[item], "add", amount)
|
||||
return true
|
||||
else
|
||||
else
|
||||
print('Failed To Give Item: ' .. item .. ' Check Your qb-core/shared/items.lua')
|
||||
return false
|
||||
end
|
||||
else
|
||||
local carry = exports.ox_inventory:CanCarryItem(source, item, amount)
|
||||
if not carry then Notifys(source, 'You Cant Carry that Much Weight!', 'error') return false end
|
||||
if exports.ox_inventory:AddItem(source, item, amount) then
|
||||
return true
|
||||
else
|
||||
@@ -181,66 +266,85 @@ function AddItem(source, item, amount)
|
||||
end
|
||||
end
|
||||
|
||||
function addMoney(source, type, amount)
|
||||
if Config.Framework == 'qb' then
|
||||
local Player = getPlayer(source)
|
||||
if Player.Functions.AddMoney(type, amount) then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
elseif Config.Framework == 'esx' then
|
||||
local Player = getPlayer(source)
|
||||
if Player.addMoney(amount) then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
elseif Config.Framework == 'qbx' then
|
||||
if qbx:AddMoney(source, type, amount) then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function getRep(source, type)
|
||||
local Player = getPlayer(source)
|
||||
local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {Player.PlayerData.citizenid})
|
||||
function removeMoney(source, type, amount)
|
||||
if Config.Framework == 'qb' then
|
||||
local Player = getPlayer(source)
|
||||
if Player.Functions.RemoveMoney(type, amount) then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
elseif Config.Framework == 'esx' then
|
||||
if type == 'bank' then
|
||||
print('Does Not Support Bank Funds Removing From ESX Defaulted To Cash')
|
||||
end
|
||||
local Player = getPlayer(source)
|
||||
if Player.getMoney() >= amount then
|
||||
Player.removeMoney(amount)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
elseif Config.Framework == 'qbx' then
|
||||
if qbx:RemoveMoney(source, type, amount) then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
local function handleFresh(source)
|
||||
local table = json.encode({
|
||||
coke = 0,lsd = 0,heroin = 0,dealerrep = 0,
|
||||
cornerselling = { price = QBConfig.SellLevel[1].price,rep = 0,label = QBConfig.SellLevel[1].label,level = 1}
|
||||
})
|
||||
MySQL.insert('INSERT INTO drugrep SET cid = ?, drugrep = ?, name = ?', {getCid(source), table, GetName(source)})
|
||||
Wait(1000)
|
||||
return json.decode(table)
|
||||
end
|
||||
|
||||
function getRep(source, type)
|
||||
local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {getCid(source)})
|
||||
if not sql[1] then
|
||||
local table = json.encode({
|
||||
coke = Player.PlayerData.metadata.coke or 0,
|
||||
lsd = Player.PlayerData.metadata.lsd or 0,
|
||||
heroin = Player.PlayerData.metadata.heroin or 0,
|
||||
dealerrep = Player.PlayerData.metadata.dealerrep or 0,
|
||||
cornerselling = {
|
||||
price = QBConfig.SellLevel[1].price,
|
||||
rep = 0,
|
||||
label = QBConfig.SellLevel[1].label,
|
||||
level = 1
|
||||
}
|
||||
})
|
||||
MySQL.insert('INSERT INTO drugrep SET cid = ?, drugrep = ?, name = ?', {Player.PlayerData.citizenid, table, GetName(source)})
|
||||
Wait(1000)
|
||||
return json.decode(table)
|
||||
local new = handleFresh(source)
|
||||
return new[type]
|
||||
else
|
||||
local reps = json.decode(sql[1].drugrep)
|
||||
local rep = ''
|
||||
if reps.coke == nil then rep = reps[1] else rep = reps end
|
||||
if type == 'coke' then
|
||||
return rep.coke
|
||||
elseif type == 'heroin' then
|
||||
return rep.heroin
|
||||
elseif type == 'lsd' then
|
||||
return rep.lsd
|
||||
elseif type == 'dealerrep' then
|
||||
return rep.dealerrep
|
||||
elseif type == 'cornerselling' then
|
||||
return rep.cornerselling
|
||||
else
|
||||
print('^1 Error: No Valid Drug Rep Option Chosen')
|
||||
end
|
||||
return false
|
||||
return rep[type]
|
||||
end
|
||||
end
|
||||
|
||||
function GetAllRep(source)
|
||||
local Player = getPlayer(source)
|
||||
local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {Player.PlayerData.citizenid})
|
||||
function GetAllRep(source)
|
||||
local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {getCid(source)})
|
||||
if not sql[1] then
|
||||
local table = json.encode({
|
||||
coke = Player.PlayerData.metadata.coke or 0,
|
||||
lsd = Player.PlayerData.metadata.lsd or 0,
|
||||
heroin = Player.PlayerData.metadata.heroin or 0,
|
||||
dealerrep = Player.PlayerData.metadata.dealerrep or 0,
|
||||
cornerselling = {
|
||||
price = QBConfig.SellLevel[1].price,
|
||||
rep = 0,
|
||||
label = QBConfig.SellLevel[1].label,
|
||||
level = 1
|
||||
}
|
||||
})
|
||||
MySQL.insert('INSERT INTO drugrep SET cid = ?, drugrep = ?, name = ?', {Player.PlayerData.citizenid, table, GetName(source)})
|
||||
Wait(1000)
|
||||
return json.decode(table)
|
||||
local new = handleFresh(source)
|
||||
return new
|
||||
else
|
||||
local rep = json.decode(sql[1].drugrep)
|
||||
if rep.coke == nil then return rep[1] end
|
||||
@@ -248,10 +352,10 @@ function GetAllRep(source)
|
||||
end
|
||||
end
|
||||
|
||||
function AddRep(source, type, amount)
|
||||
function AddRep(source, type, amount)
|
||||
if not Config.TierSystem then return false end
|
||||
if not amount then amount = 1 end
|
||||
local Player = getPlayer(source)
|
||||
local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {Player.PlayerData.citizenid})
|
||||
local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {getCid(source)})
|
||||
local reps = json.decode(sql[1].drugrep)
|
||||
local update
|
||||
local rep = ''
|
||||
@@ -265,19 +369,15 @@ function AddRep(source, type, amount)
|
||||
update = json.encode({coke = rep.coke, heroin = rep.heroin, lsd = rep.lsd, dealerrep = rep.dealerrep, cornerselling = {label = v.label, price = v.price, rep = rep.cornerselling.rep + amount, level = k}})
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif type == 'coke' then
|
||||
update = json.encode({coke = rep.coke + amount, heroin = rep.heroin, lsd = rep.lsd, dealerrep = rep.dealerrep, cornerselling = rep.cornerselling})
|
||||
elseif type == 'heroin' then
|
||||
update = json.encode({coke = rep.coke, heroin = rep.heroin + amount, lsd = rep.lsd, dealerrep = rep.dealerrep, cornerselling = rep.cornerselling})
|
||||
elseif type == 'lsd' then
|
||||
update = json.encode({coke = rep.coke, heroin = rep.heroin, lsd = rep.lsd +amount , dealerrep = rep.dealerrep, cornerselling = rep.cornerselling})
|
||||
elseif type == 'dealerrep' then
|
||||
update = json.encode({coke = rep.coke, heroin = rep.heroin, lsd = rep.lsd, dealerrep = rep.dealerrep + amount, cornerselling = rep.cornerselling})
|
||||
end
|
||||
if update == '' then return false end
|
||||
MySQL.update('UPDATE drugrep SET drugrep = ? WHERE cid = ?', {update, getCid(source)})
|
||||
return true
|
||||
else
|
||||
rep[type] = rep[type] + amount
|
||||
MySQL.update('UPDATE drugrep SET drugrep = ? WHERE cid = ?', {json.encode(rep), getCid(source)})
|
||||
return true
|
||||
end
|
||||
if update == '' then return false end
|
||||
MySQL.update('UPDATE drugrep SET drugrep = ? WHERE cid = ?', {update, Player.PlayerData.citizenid})
|
||||
return true
|
||||
end
|
||||
|
||||
lib.addCommand('addCornerSellingTOREP', {
|
||||
@@ -290,17 +390,17 @@ lib.addCommand('addCornerSellingTOREP', {
|
||||
local old = json.decode(v.drugrep)
|
||||
local get = old[1] or old
|
||||
table.insert(new, {
|
||||
coke = get.coke,
|
||||
lsd = get.lsd,
|
||||
heroin = get.heroin,
|
||||
dealerrep = get.dealerrep,
|
||||
cornerselling = {
|
||||
price = QBConfig.SellLevel[1].price,
|
||||
rep = 0,
|
||||
label = QBConfig.SellLevel[1].label,
|
||||
level = 1
|
||||
}
|
||||
})
|
||||
coke = get.coke,
|
||||
lsd = get.lsd,
|
||||
heroin = get.heroin,
|
||||
dealerrep = get.dealerrep,
|
||||
cornerselling = {
|
||||
price = QBConfig.SellLevel[1].price,
|
||||
rep = 0,
|
||||
label = QBConfig.SellLevel[1].label,
|
||||
level = 1
|
||||
}
|
||||
})
|
||||
local news = json.encode(new)
|
||||
MySQL.query.await('UPDATE drugrep SET drugrep = ? WHERE cid = ?', {news, v.cid})
|
||||
end
|
||||
@@ -314,39 +414,110 @@ end
|
||||
|
||||
function getCops()
|
||||
local amount = 0
|
||||
local players = QBCore.Functions.GetQBPlayers()
|
||||
for k, v in pairs(players) do
|
||||
if v.PlayerData.job.type == 'leo' and v.PlayerData.job.onduty then
|
||||
amount = amount + 1
|
||||
end
|
||||
if Config.Framework == 'qb' then
|
||||
local players = QBCore.Functions.GetQBPlayers()
|
||||
for k, v in pairs(players) do
|
||||
if v.PlayerData.job.type == 'leo' and v.PlayerData.job.onduty then
|
||||
amount = amount + 1
|
||||
end
|
||||
end
|
||||
return amount
|
||||
elseif Config.Framework == 'esx' then
|
||||
local players = ESX.GetPlayers()
|
||||
for k, v in pairs(players) do
|
||||
local xPlayer = ESX.GetPlayerFromId(v)
|
||||
if xPlayer.job.name == 'police' and xPlayer.job.onduty then
|
||||
amount = amount + 1
|
||||
end
|
||||
end
|
||||
return amount
|
||||
elseif Config.Framework == 'qbx' then
|
||||
return qbx:GetDutyCountType('leo')
|
||||
end
|
||||
return amount
|
||||
end
|
||||
|
||||
ps.registerCallback('md-drugs:server:GetCoppers', function(source, cb, args)
|
||||
local amount = 0
|
||||
local players = QBCore.Functions.GetQBPlayers()
|
||||
for k, v in pairs(players) do
|
||||
if v.PlayerData.job.type == 'leo' and v.PlayerData.job.onduty then
|
||||
amount = amount + 1
|
||||
end
|
||||
function getNear(src)
|
||||
if Config.Framework == 'qb' then
|
||||
local near = {}
|
||||
local players = QBCore.Functions.GetPlayers()
|
||||
for k, v in pairs (players) do
|
||||
local targ = QBCore.Functions.GetPlayerByCitizenId(v.PlayerData.citizenid)
|
||||
local tname = GetName(v.PlayerData.source)
|
||||
local ped, tped = GetPlayerPed(src), GetPlayerPed(v.PlayerData.source)
|
||||
local dist = #(GetEntityCoords(ped) - GetEntityCoords(tped))
|
||||
if dist < 5.0 then
|
||||
table.insert(near, {label = tname, value = targ.PlayerData.citizenid})
|
||||
end
|
||||
end
|
||||
return near
|
||||
elseif Config.Framework == 'esx' then
|
||||
local near = {}
|
||||
local players = ESX.GetPlayers()
|
||||
for k, v in pairs (players) do
|
||||
local targ = ESX.GetPlayerFromId(v)
|
||||
local tname = GetName(v)
|
||||
local ped, tped = GetPlayerPed(src), GetPlayerPed(v)
|
||||
local dist = #(GetEntityCoords(ped) - GetEntityCoords(tped))
|
||||
if dist < 5.0 then
|
||||
table.insert(near, {label = tname, value = getCid(v)})
|
||||
end
|
||||
end
|
||||
return near
|
||||
elseif Config.Framework == 'qbx' then
|
||||
local near = {}
|
||||
local players = qbx:GetPlayers()
|
||||
for k, v in pairs (players) do
|
||||
local targ = qbx:GetPlayer(v)
|
||||
local tname = GetName(v)
|
||||
local ped, tped = GetPlayerPed(src), GetPlayerPed(v)
|
||||
local dist = #(GetEntityCoords(ped) - GetEntityCoords(tped))
|
||||
if dist < 5.0 then
|
||||
table.insert(near, {label = tname, value = getCid(v)})
|
||||
end
|
||||
end
|
||||
return near
|
||||
end
|
||||
return amount
|
||||
end
|
||||
|
||||
function handleCornersell(source, item, amount, price)
|
||||
if RemoveItem(source, item, amount) then
|
||||
if inventory == 'qb' then
|
||||
local Player = getPlayer(source)
|
||||
if QBConfig.MarkedBills == true then
|
||||
Player.Functions.AddItem('markedbills',1,false, {worth = price})
|
||||
return true
|
||||
end
|
||||
if QBConfig.CustomDirtyMoney == true then
|
||||
AddItem(source, QBConfig.CustomDirtyMoneyitem,price)
|
||||
return true
|
||||
end
|
||||
Player.Functions.AddMoney('cash', price)
|
||||
elseif inventory == 'ox' then
|
||||
AddItem(source, 'black_money', price)
|
||||
return true
|
||||
end
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
lib.callback.register('md-drugs:server:GetCoppers', function(source, cb, args)
|
||||
return getCops()
|
||||
end)
|
||||
|
||||
ps.registerCallback('md-drugs:server:GetRep', function(source, cb, args)
|
||||
local src = source
|
||||
lib.callback.register('md-drugs:server:GetRep', function(source, cb, args)
|
||||
local rep = GetAllRep(source)
|
||||
return rep
|
||||
end)
|
||||
|
||||
CreateThread(function()
|
||||
if not GetResourceState('ox_lib'):find("start") then
|
||||
print('^1 ox_lib Is A Depndancy, Not An Optional ')
|
||||
if GetResourceState('ps-inventory') == 'started' then
|
||||
invname = 'ps-inventory'
|
||||
elseif GetResourceState('qb-inventory') == 'started' then
|
||||
invname = 'qb-inventory'
|
||||
else
|
||||
invname = 'inventory'
|
||||
end
|
||||
end)
|
||||
|
||||
CreateThread(function()
|
||||
local url = "https://raw.githubusercontent.com/Mustachedom/md-drugs/main/version.txt"
|
||||
local version = GetResourceMetadata('md-drugs', "version" )
|
||||
PerformHttpRequest(url, function(err, text, headers)
|
||||
@@ -354,4 +525,7 @@ CreateThread(function()
|
||||
print('^2 Your Version:' .. version .. ' | Current Version:' .. text .. '' )
|
||||
end
|
||||
end, "GET", "", "")
|
||||
if GetResourceState('ox_lib') ~= 'started' then
|
||||
print('^1 ox_lib Is A Depndancy, Not An Optional ')
|
||||
end
|
||||
end)
|
||||
+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