added qbx

This commit is contained in:
Mustache Dom committed 2025-01-29 20:26:39 -08:00
1 parent b4234abaf3
commit e0eb843d4e
9 files changed
+155 -131

No files matched your search

+2 -1
View File
@@ -1,7 +1,8 @@
{ {
"Lua.diagnostics.disable": [ "Lua.diagnostics.disable": [
"missing-parameter", "missing-parameter",
"param-type-mismatch" "param-type-mismatch",
"lowercase-global"
], ],
"Lua.diagnostics.globals": [ "Lua.diagnostics.globals": [
"lib", "lib",
+27 -14
View File
@@ -9,6 +9,8 @@ function getJobType()
return QBCore.Functions.GetPlayerData().job.type return QBCore.Functions.GetPlayerData().job.type
elseif Config.Framework == 'esx' then elseif Config.Framework == 'esx' then
return ESX.PlayerData.job.type return ESX.PlayerData.job.type
elseif Config.Framework == 'qbx' then
return QBX.PlayerData.job.type
end end
end end
@@ -17,6 +19,18 @@ function getJobName()
return QBCore.Functions.GetPlayerData().job.name return QBCore.Functions.GetPlayerData().job.name
elseif Config.Framework == 'esx' then elseif Config.Framework == 'esx' then
return ESX.PlayerData.job.name return ESX.PlayerData.job.name
elseif Config.Framework == 'qbx' then
return QBX.PlayerData.job.name
end
end
function getGang()
if Config.Framework == 'qb' then
return QBCore.Functions.GetPlayerData().gang.name
elseif Config.Framework == 'esx' then
return ESX.GetPlayerData().job.name
elseif Config.Framework == 'qbx' then
return QBX.PlayerData.gang.name
end end
end end
@@ -186,15 +200,15 @@ function minigame()
function Notify(text, type) function Notify(text, type)
if notifytype =='ox' then if notifytype =='ox' then
lib.notify({title = text, type = type}) lib.notify({title = text, type = type})
elseif notifytype == 'qb' then elseif notifytype == 'qb' then
QBCore.Functions.Notify(text, type) QBCore.Functions.Notify(text, type)
elseif notifytype == 'okok' then elseif notifytype == 'okok' then
exports['okokNotify']:Alert('', text, 4000, type, false) exports['okokNotify']:Alert('', text, 4000, type, false)
else else
print"^1 SCRIPT ERROR: Md-DRUGS set your notification with one of the options!" print"^1 SCRIPT ERROR: Md-DRUGS set your notification with one of the options!"
end end
end end
function GetImage(img) function GetImage(img)
if GetResourceState('ox_inventory') == 'started' then if GetResourceState('ox_inventory') == 'started' then
@@ -247,7 +261,6 @@ end
function makeMenu(name, rep) function makeMenu(name, rep)
local menu = {} local menu = {}
local data = lib.callback.await('md-drugs:server:menu', false, name) local data = lib.callback.await('md-drugs:server:menu', false, name)
print(data)
for k, v in pairs (data.table) do for k, v in pairs (data.table) do
local allow = false local allow = false
if rep == nil then if rep == nil then
@@ -403,7 +416,6 @@ function tele(coords)
DoScreenFadeIn(500) DoScreenFadeIn(500)
end end
function AddBoxZoneSingle(name, loc, data) function AddBoxZoneSingle(name, loc, data)
if Config.Target == 'qb' then if Config.Target == 'qb' then
exports['qb-target']:AddBoxZone(name, loc, 1.5, 1.75, {name = name, minZ = loc.z-1,maxZ = loc.z +1}, exports['qb-target']:AddBoxZone(name, loc, 1.5, 1.75, {name = name, minZ = loc.z-1,maxZ = loc.z +1},
@@ -453,13 +465,7 @@ function AddBoxZoneSingle(name, loc, data)
}) })
end end
end end
local function getGang()
if Config.Framework == 'qb' then
return QBCore.Functions.GetPlayerData().gang.name
elseif Config.Framework == 'esx' then
return ESX.GetPlayerData().job.name
end
end
function AddBoxZoneMulti(name, table, data) function AddBoxZoneMulti(name, table, data)
for k, v in pairs (table) do for k, v in pairs (table) do
if v.gang == nil or v.gang == '' or v.gang == "" then v.gang = 1 end if v.gang == nil or v.gang == '' or v.gang == "" then v.gang = 1 end
@@ -670,6 +676,13 @@ function getAmbo()
else else
return false return false
end end
elseif Config.Framework == 'qbx' then
local Player = QBX.PlayerData
if Player.job.name == 'ambulance' then
return true
else
return false
end
end end
end end
+2
View File
@@ -4,7 +4,9 @@ description "drugs by mustache dom"
fx_version "cerulean" fx_version "cerulean"
game "gta5" game "gta5"
version '3.9.0' version '3.9.0'
client_scripts { client_scripts {
--'@qbx_core/modules/playerdata.lua',
'client/**.lua', 'client/**.lua',
} }
+9 -12
View File
@@ -70,6 +70,7 @@ RegisterServerEvent('md-drugs:server:cutcokeone', function(num)
else else
if not checkLoc(src, 'CuttingCoke', num) then return end if not checkLoc(src, 'CuttingCoke', num) then return end
end end
local tier = 'tier1'
if Config.TierSystem then if Config.TierSystem then
local cokeTiers = { local cokeTiers = {
{item = 'coke', tier = 'tier1', log = ' Cut Coke'}, {item = 'coke', tier = 'tier1', log = ' Cut Coke'},
@@ -78,14 +79,12 @@ RegisterServerEvent('md-drugs:server:cutcokeone', function(num)
} }
for _, v in ipairs(cokeTiers) do for _, v in ipairs(cokeTiers) do
if hasItem(src, v.item, 1) then if hasItem(src, v.item, 1) then
if not GetRecipe(src, 'cocaine', 'cutcoke', v.tier) then return end tier = v.tier
return break
end end
end end
if not GetRecipe(src, 'cocaine', 'cutcoke', 'tier1') then return end
else
if not GetRecipe(src, 'cocaine', 'cutcoke', 'tier1') then return end
end end
if not GetRecipe(src, 'cocaine', 'cutcoke', tier) then return end
end) end)
RegisterServerEvent('md-drugs:server:bagcoke', function(num) RegisterServerEvent('md-drugs:server:bagcoke', function(num)
@@ -95,6 +94,7 @@ RegisterServerEvent('md-drugs:server:bagcoke', function(num)
else else
if not checkLoc(src, 'BaggingCoke', num) then return end if not checkLoc(src, 'BaggingCoke', num) then return end
end end
local tier = 'tier1'
if Config.TierSystem then if Config.TierSystem then
local cokeTiers = { local cokeTiers = {
{item = 'loosecoke', tier = 'tier1', log = ' Bagged Coke'}, {item = 'loosecoke', tier = 'tier1', log = ' Bagged Coke'},
@@ -103,22 +103,19 @@ RegisterServerEvent('md-drugs:server:bagcoke', function(num)
} }
for _, v in ipairs(cokeTiers) do for _, v in ipairs(cokeTiers) do
if hasItem(src, v.item, 1) then if hasItem(src, v.item, 1) then
if not GetRecipe(src, 'cocaine', 'bagcoke', v.tier) then return end tier = v.tier
AddRep(src, 'coke') break
return
end end
end end
if not GetRecipe(src, 'cocaine', 'bagcoke', 'tier1') then return end
else
if not GetRecipe(src, 'cocaine', 'bagcoke', 'tier1') then return end
end end
if not GetRecipe(src, 'cocaine', 'bagcoke', tier) then return end
AddRep(src, 'coke', 1)
end) end)
local cokecut = {loosecokestagetwo = 2, loosecokestagethree = 3} local cokecut = {loosecokestagetwo = 2, loosecokestagethree = 3}
for k, v in pairs (cokecut) do for k, v in pairs (cokecut) do
CUI(k, function(source, item) CUI(k, function(source, item)
local src = source local src = source
if not hasItem(src, 'bakingsoda', 1) then Notifys(src, 'You Need Baking Soda For this', 'error') return end
if hasItem(src, k, 1) then if hasItem(src, k, 1) then
if not Itemcheck(src, 'bakingsoda', 1) then return end if not Itemcheck(src, 'bakingsoda', 1) then return end
local check = lib.callback.await('md-drugs:client:uncuff', src, 'Cutting It Further') local check = lib.callback.await('md-drugs:client:uncuff', src, 'Cutting It Further')
+24 -27
View File
@@ -129,48 +129,50 @@ lib.callback.register('md-drugs:server:cornerselling:getAvailableDrugs', functio
local item = getItemCount(source, k) local item = getItemCount(source, k)
if item >= 1 then if item >= 1 then
if item > 15 then item = 15 end if item > 15 then item = 15 end
Log(GetName(source) .. ' Allowed To Sell ' .. k .. '!' , 'cornerselling')
local amount = math.random(1, item) local amount = math.random(1, item)
if amount >= 15 then amount = 15 end local price = (math.random(Drugs[k]['min'], Drugs[k]['max']) * amount) * rep.price
local price = math.random(Drugs[k]['min'], Drugs[k]['max']) * amount DrugDeals[getCid(source)] = {item = k, amount = amount, price = price, ped = ped}
local result = math.floor(price * rep.price) Log(GetName(source) .. ' Allowed To Sell ' .. k .. '!' , 'cornerselling')
table.insert(DrugDeals, {item = k, amount = amount, price = result, cid = getCid(source), ped = ped}) return DrugDeals[getCid(source)]
return {item = k, amount = amount, price = result, ped = ped}
end end
end end
return {item = 'nothing', amount = 0, price = 0, ped = ped} return {item = 'nothing', amount = 0, price = 0, ped = ped}
end) end)
lib.callback.register('md-drugs:server:hasDrugs', function(source) lib.callback.register('md-drugs:server:hasDrugs', function(source)
local Player = getPlayer(source)
for k, v in pairs(Drugs) do for k, v in pairs(Drugs) do
local item = hasItem(source, k, 1) if hasItem(source, k, 1) then
if item then
return true return true
end end
end end
return false return false
end) end)
RegisterNetEvent('md-drugs:server:sellCornerDrugs', function(item, amount, price) local function csCheck(src, item, amount, price)
local src = source
local Player = getPlayer(src)
local isIn = false local isIn = false
for k, v in pairs (Drugs) do for k, v in pairs (Drugs) do
if item == k then if item == k then
isIn = true isIn = true
end end
end end
if not isIn then return end if not isIn then return false end
for k, v in pairs (DrugDeals) do
if v.cid == getCid(source) and v.item == item and v.amount == amount and v.price == price then if DrugDeals[getCid(src)] then
if handleCornersell(src, item, amount, price) then if DrugDeals[getCid(src)].item == item and DrugDeals[getCid(src)].amount == amount and DrugDeals[getCid(src)].price == price then
AddRep(src, 'cornerselling', Drugs[item].rep * amount) return true
Log(GetName(src) .. ' Sold ' .. amount .. ' Of ' .. item .. ' For A Price Of ' .. price .. '!' , 'cornerselling')
table.remove(DrugDeals, k)
end
end end
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 handleCornersell(src, item, amount, price) then
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[getCid(src)] = nil
end
end) end)
lib.addCommand('cornersell', { lib.addCommand('cornersell', {
@@ -179,18 +181,13 @@ lib.addCommand('cornersell', {
}, },
}, function(source, args, raw) }, function(source, args, raw)
local src = source local src = source
local Player = getPlayer(src)
Log(GetName(source) .. ' Used Command cornersell!' , 'cornerselling') Log(GetName(source) .. ' Used Command cornersell!' , 'cornerselling')
TriggerClientEvent('md-drugs:client:cornerselling', src) TriggerClientEvent('md-drugs:client:cornerselling', src)
end) end)
RegisterServerEvent('md-drugs:server:cornerselling:stop', function() RegisterServerEvent('md-drugs:server:cornerselling:stop', function()
local src = source local src = source
local Player = getPlayer(src) if DrugDeals[getCid(src)] then
for k, v in pairs (DrugDeals) do DrugDeals[getCid(src)] = nil
if v.cid == getCid(source) then
TriggerClientEvent('md-drugs:client:cornerselling:remove', src, DrugDeals[k].ped)
table.remove(DrugDeals, k)
end
end end
end) end)
+4 -9
View File
@@ -1,8 +1,7 @@
RegisterServerEvent('md-drugs:server:makecrackone', function(num) RegisterServerEvent('md-drugs:server:makecrackone', function(num)
local src = source local src = source
local Player = getPlayer(src) local type, tier ='cookcrack', 'tier1'
local count,type, tier = 0, 'cookcrack', 'tier1'
if not checkLoc(src, 'makecrack', num) then return end if not checkLoc(src, 'makecrack', num) then return end
if Config.TierSystem then if Config.TierSystem then
local crackTiers = { local crackTiers = {
@@ -11,10 +10,9 @@ RegisterServerEvent('md-drugs:server:makecrackone', function(num)
{item = 'loosecokestagethree', tier = 'tier3', log = ' Cut Crack tier 3'} {item = 'loosecokestagethree', tier = 'tier3', log = ' Cut Crack tier 3'}
} }
for _, v in ipairs(crackTiers) do for _, v in ipairs(crackTiers) do
if count >= 1 then break end
if hasItem(src, v.item, 1) then if hasItem(src, v.item, 1) then
tier = v.tier tier = v.tier
count = count + 1 break
end end
end end
end end
@@ -24,8 +22,7 @@ end)
RegisterServerEvent('md-drugs:server:bagcrack', function(num) RegisterServerEvent('md-drugs:server:bagcrack', function(num)
local src = source local src = source
local Player = getPlayer(src) local type, tier = 'bagcrack', 'tier1'
local count,type, tier = 0, 'bagcrack', 'tier1'
if not checkLoc(src, 'bagcrack', num) then return end if not checkLoc(src, 'bagcrack', num) then return end
if Config.TierSystem then if Config.TierSystem then
local crackTiers = { local crackTiers = {
@@ -34,10 +31,9 @@ RegisterServerEvent('md-drugs:server:bagcrack', function(num)
{item = 'crackrockstagethree', tier = 'tier3', log = ' Bagged Crack tier 3'} {item = 'crackrockstagethree', tier = 'tier3', log = ' Bagged Crack tier 3'}
} }
for _, v in ipairs(crackTiers) do for _, v in ipairs(crackTiers) do
if count >= 1 then break end
if hasItem(src, v.item, 1) then if hasItem(src, v.item, 1) then
tier = v.tier tier = v.tier
count = count + 1 break
end end
end end
end end
@@ -48,7 +44,6 @@ local cokecut = {crackrockstagetwo = 2, crackrockstagethree = 3}
for k, v in pairs (cokecut) do for k, v in pairs (cokecut) do
CUI(k, function(source, item) CUI(k, function(source, item)
local src = source local src = source
local Player = getPlayer(src)
if hasItem(src, k, 1) then if hasItem(src, k, 1) then
if not Itemcheck(src, 'bakingsoda', 1) then return end if not Itemcheck(src, 'bakingsoda', 1) then return end
local check = lib.callback.await('md-drugs:client:uncuff', src, 'Cutting Crack Rock Further') local check = lib.callback.await('md-drugs:client:uncuff', src, 'Cutting Crack Rock Further')
+6 -16
View File
@@ -84,7 +84,7 @@ lib.callback.register('md-drugs:server:getDealers', function(data)
local loc = json.encode({x = 899.98, y = -2603.24, z = 6.11, h = 176.12 }) local loc = json.encode({x = 899.98, y = -2603.24, z = 6.11, h = 176.12 })
if not check[1] then if not check[1] then
MySQL.insert('INSERT INTO dealers SET name = ?, coords = ?, time = ?, createdby = ?', {'MD', loc, 'any', 'code Newb'}) MySQL.insert('INSERT INTO dealers SET name = ?, coords = ?, time = ?, createdby = ?', {'MD', loc, 'any', 'code Newb'})
Wait(2000) Wait(2000)
local check2 = MySQL.query.await('SELECT * FROM dealers', {}) local check2 = MySQL.query.await('SELECT * FROM dealers', {})
return check2 return check2
else else
@@ -94,24 +94,19 @@ end)
local DeliveryItems = { local DeliveryItems = {
{ item = "weed_brick", minrep = 0, payout = {min = 10, max = 50}}, {item = "weed_brick", minrep = 0, payout = {min = 10, max = 50}},
{ item = "coke_brick", minrep = 0, payout = {min = 10, max = 50}}, {item = "coke_brick", minrep = 0, payout = {min = 10, max = 50}},
} }
lib.callback.register('md-drugs:server:GetDeliveryItem', function(data) lib.callback.register('md-drugs:server:GetDeliveryItem', function(data)
local src = source local src = source
local Player = getPlayer(src)
local itemnum = math.random(1, #DeliveryItems) local itemnum = math.random(1, #DeliveryItems)
local item = DeliveryItems[itemnum].item local item = DeliveryItems[itemnum].item
local amount = math.random(1,4) local amount = math.random(1,4)
local check = MySQL.query.await('SELECT * FROM deliveriesdealer WHERE cid = ?', {getCid(src)}) local check = MySQL.query.await('SELECT * FROM deliveriesdealer WHERE cid = ?', {getCid(src)})
local locnum = math.random(1, #dloc) local locnum = math.random(1, #dloc)
local coord = json.encode({ local coord = json.encode({ x = dloc[locnum].coords.x, y = dloc[locnum].coords.y, z = dloc[locnum].coords.z , w = dloc[locnum].coords.w })
x = dloc[locnum].coords.x,
y = dloc[locnum].coords.y,
z = dloc[locnum].coords.z ,
w = dloc[locnum].coords.w
})
if not check[1] then if not check[1] then
MySQL.insert('INSERT INTO deliveriesdealer SET cid = ?, itemdata = ?, timestart = ?, maxtime = ?, location = ?', MySQL.insert('INSERT INTO deliveriesdealer SET cid = ?, itemdata = ?, timestart = ?, maxtime = ?, location = ?',
{getCid(src), json.encode({item = item, amount = amount}), os.time(), os.time() + (15 * 60), coord }) {getCid(src), json.encode({item = item, amount = amount}), os.time(), os.time() + (15 * 60), coord })
@@ -176,12 +171,7 @@ lib.addCommand("newdealer", {
}, function() }, function()
QBConfig.Dealers[dealerName] = { QBConfig.Dealers[dealerName] = {
name = dealerName, name = dealerName,
coords = { coords = { x = coords.x, y = coords.y, z = coords.z, h = GetEntityHeading(ped) },
x = coords.x,
y = coords.y,
z = coords.z,
h = GetEntityHeading(ped)
},
} }
TriggerClientEvent('md-drugs:client:RefreshDealers', -1, QBConfig.Dealers) TriggerClientEvent('md-drugs:client:RefreshDealers', -1, QBConfig.Dealers)
end) end)
+79 -52
View File
@@ -1,6 +1,8 @@
local QBCore, ESX = {}, {} local QBCore, ESX, qbx = {}, {}, nil
local notify = Config.Notify -- qb or ox local notify = Config.Notify -- qb or ox
local inventory = Config.Inventory -- qb or ox local inventory = Config.Inventory -- qb or ox
local invname = ''
------------------------------------------ logging stuff ------------------------------------------ logging stuff
local logs = false local logs = false
local logapi = GetConvar("fivemerrLogs", "") local logapi = GetConvar("fivemerrLogs", "")
@@ -14,8 +16,11 @@ if Config.Framework == 'qb' then
QBCore = exports['qb-core']:GetCoreObject() QBCore = exports['qb-core']:GetCoreObject()
elseif Config.Framework == 'esx' then elseif Config.Framework == 'esx' then
ESX = exports['es_extended']:getSharedObject() ESX = exports['es_extended']:getSharedObject()
elseif Config.Framework == 'qbx' then
qbx = exports.qbx_core
end end
CreateThread(function() CreateThread(function()
if logs then if logs then
print'^2 Logs Enabled for md-drugs' print'^2 Logs Enabled for md-drugs'
@@ -31,16 +36,10 @@ end)
function Log(message, type) function Log(message, type)
if logs == false then return end if logs == false then return end
local buffer = { local buffer = { level = "info", message = message, resource = GetCurrentResourceName(),
level = "info", metadata = { drugs = type, playerid = source}
message = message,
resource = GetCurrentResourceName(),
metadata = {
drugs = type,
playerid = source
}
} }
SetTimeout(500, function() SetTimeout(500, function()
PerformHttpRequest(endpoint, function(status, _, _, response) PerformHttpRequest(endpoint, function(status, _, _, response)
if status ~= 200 then if status ~= 200 then
if type(response) == 'string' then if type(response) == 'string' then
@@ -49,19 +48,8 @@ if logs == false then return end
end end
end, 'POST', json.encode(buffer), headers) end, 'POST', json.encode(buffer), headers)
buffer = nil buffer = nil
end) 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 ------------------------------------ Player Stuff functions
function getPlayer(source) function getPlayer(source)
local src = source local src = source
@@ -71,6 +59,9 @@ function getPlayer(source)
elseif Config.Framework == 'esx' then elseif Config.Framework == 'esx' then
local Player = ESX.GetPlayerFromId(src) local Player = ESX.GetPlayerFromId(src)
return Player return Player
elseif Config.Framework == 'qbx' then
local Player = qbx:GetPlayer(source)
return Player
end end
end end
@@ -81,6 +72,9 @@ function getPlayerByCid(cid)
elseif Config.Framework == 'esx' then elseif Config.Framework == 'esx' then
local Player = ESX.GetPlayerFromIdentifier(cid) local Player = ESX.GetPlayerFromIdentifier(cid)
return Player return Player
elseif Config.Framework == 'qbx' then
local Player = qbx:GetPlayerByCitizenId(cid)
return Player
end end
end end
@@ -92,6 +86,9 @@ function GetName(source)
elseif Config.Framework == 'esx' then elseif Config.Framework == 'esx' then
local Player = getPlayer(src) local Player = getPlayer(src)
return Player.getName() return Player.getName()
elseif Config.Framework == 'qbx' then
local Player = getPlayer(src)
return Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname
end end
end end
@@ -103,8 +100,12 @@ function getCid(source)
elseif Config.Framework == 'esx' then elseif Config.Framework == 'esx' then
local Player = getPlayer(src) local Player = getPlayer(src)
return Player.getIdentifier() return Player.getIdentifier()
elseif Config.Framework == 'qbx' then
local Player = getPlayer(src)
return Player.PlayerData.citizenid
end end
end end
function GetCoords(source) function GetCoords(source)
local ped = GetPlayerPed(source) local ped = GetPlayerPed(source)
local playerCoords = GetEntityCoords(ped) local playerCoords = GetEntityCoords(ped)
@@ -115,7 +116,8 @@ function dist(source, coords)
local playerPed = GetPlayerPed(source) local playerPed = GetPlayerPed(source)
local pcoords = GetEntityCoords(playerPed) local pcoords = GetEntityCoords(playerPed)
local dist = #(pcoords - coords) local dist = #(pcoords - coords)
return dist
return dist
end end
function CheckDist(source, coords) function CheckDist(source, coords)
@@ -158,6 +160,8 @@ function CUI(item, useFunction)
QBCore.Functions.CreateUseableItem(item, useFunction) QBCore.Functions.CreateUseableItem(item, useFunction)
elseif Config.Framework == 'esx' then elseif Config.Framework == 'esx' then
ESX.RegisterUsableItem(item, useFunction) ESX.RegisterUsableItem(item, useFunction)
elseif Config.Framework == 'qbx' then
qbx:CreateUseableItem(item, useFunction)
end end
end end
@@ -277,6 +281,12 @@ function addMoney(source, type, amount)
else else
return false return false
end end
elseif Config.Framework == 'qbx' then
if qbx:AddMoney(source, type, amount) then
return true
else
return false
end
end end
end end
@@ -299,6 +309,12 @@ function removeMoney(source, type, amount)
else else
return false return false
end end
elseif Config.Framework == 'qbx' then
if qbx:RemoveMoney(source, type, amount) then
return true
else
return false
end
end end
end end
local function handleFresh(source) local function handleFresh(source)
@@ -312,7 +328,6 @@ local function handleFresh(source)
end end
function getRep(source, type) function getRep(source, type)
local Player = getPlayer(source)
local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {getCid(source)}) local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {getCid(source)})
if not sql[1] then if not sql[1] then
local new = handleFresh(source) local new = handleFresh(source)
@@ -326,7 +341,6 @@ function getRep(source, type)
end end
function GetAllRep(source) function GetAllRep(source)
local Player = getPlayer(source)
local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {getCid(source)}) local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {getCid(source)})
if not sql[1] then if not sql[1] then
local new = handleFresh(source) local new = handleFresh(source)
@@ -339,8 +353,8 @@ 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 if not amount then amount = 1 end
local Player = getPlayer(source)
local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {getCid(source)}) local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {getCid(source)})
local reps = json.decode(sql[1].drugrep) local reps = json.decode(sql[1].drugrep)
local update local update
@@ -376,17 +390,17 @@ lib.addCommand('addCornerSellingTOREP', {
local old = json.decode(v.drugrep) local old = json.decode(v.drugrep)
local get = old[1] or old local get = old[1] or old
table.insert(new, { table.insert(new, {
coke = get.coke, coke = get.coke,
lsd = get.lsd, lsd = get.lsd,
heroin = get.heroin, heroin = get.heroin,
dealerrep = get.dealerrep, dealerrep = get.dealerrep,
cornerselling = { cornerselling = {
price = QBConfig.SellLevel[1].price, price = QBConfig.SellLevel[1].price,
rep = 0, rep = 0,
label = QBConfig.SellLevel[1].label, label = QBConfig.SellLevel[1].label,
level = 1 level = 1
} }
}) })
local news = json.encode(new) local news = json.encode(new)
MySQL.query.await('UPDATE drugrep SET drugrep = ? WHERE cid = ?', {news, v.cid}) MySQL.query.await('UPDATE drugrep SET drugrep = ? WHERE cid = ?', {news, v.cid})
end end
@@ -417,6 +431,8 @@ function getCops()
end end
end end
return amount return amount
elseif Config.Framework == 'qbx' then
return qbx:GetDutyCountType('leo')
end end
end end
@@ -447,8 +463,22 @@ function getNear(src)
end end
end end
return near 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 end
end end
function handleCornersell(source, item, amount, price) function handleCornersell(source, item, amount, price)
if RemoveItem(source, item, amount) then if RemoveItem(source, item, amount) then
if inventory == 'qb' then if inventory == 'qb' then
@@ -466,34 +496,28 @@ function handleCornersell(source, item, amount, price)
AddItem(source, 'black_money', price) AddItem(source, 'black_money', price)
return true return true
end end
else
return false
end end
return false
end end
lib.callback.register('md-drugs:server:GetCoppers', function(source, cb, args) lib.callback.register('md-drugs:server:GetCoppers', function(source, cb, args)
local amount = 0 return getCops()
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
end) end)
lib.callback.register('md-drugs:server:GetRep', function(source, cb, args) lib.callback.register('md-drugs:server:GetRep', function(source, cb, args)
local src = source
local rep = GetAllRep(source) local rep = GetAllRep(source)
return rep return rep
end) end)
CreateThread(function() CreateThread(function()
if not GetResourceState('ox_lib'):find("start") then if GetResourceState('ps-inventory') == 'started' then
print('^1 ox_lib Is A Depndancy, Not An Optional ') invname = 'ps-inventory'
elseif GetResourceState('qb-inventory') == 'started' then
invname = 'qb-inventory'
else
invname = 'inventory'
end end
end)
CreateThread(function()
local url = "https://raw.githubusercontent.com/Mustachedom/md-drugs/main/version.txt" local url = "https://raw.githubusercontent.com/Mustachedom/md-drugs/main/version.txt"
local version = GetResourceMetadata('md-drugs', "version" ) local version = GetResourceMetadata('md-drugs', "version" )
PerformHttpRequest(url, function(err, text, headers) PerformHttpRequest(url, function(err, text, headers)
@@ -501,4 +525,7 @@ CreateThread(function()
print('^2 Your Version:' .. version .. ' | Current Version:' .. text .. '' ) print('^2 Your Version:' .. version .. ' | Current Version:' .. text .. '' )
end end
end, "GET", "", "") end, "GET", "", "")
if GetResourceState('ox_lib') ~= 'started' then
print('^1 ox_lib Is A Depndancy, Not An Optional ')
end
end) end)
+2
View File
@@ -55,4 +55,6 @@ if Config.Framework == 'qb' then
QBCore = exports['qb-core']:GetCoreObject() QBCore = exports['qb-core']:GetCoreObject()
elseif Config.Framework == 'esx' then elseif Config.Framework == 'esx' then
ESX = exports['es_extended']:getSharedObject() ESX = exports['es_extended']:getSharedObject()
elseif Config.Framework == 'qbx' then
qbx = exports.qbx_core
end end