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
+166 -142

No files matched your search

+25 -28
View File
@@ -129,48 +129,50 @@ lib.callback.register('md-drugs:server:cornerselling:getAvailableDrugs', functio
local item = getItemCount(source, k)
if item >= 1 then
if item > 15 then item = 15 end
Log(GetName(source) .. ' Allowed To Sell ' .. k .. '!' , 'cornerselling')
local amount = math.random(1, item)
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 = k, amount = amount, price = result, cid = getCid(source), ped = ped})
return {item = k, amount = amount, price = result, ped = ped}
local price = (math.random(Drugs[k]['min'], Drugs[k]['max']) * amount) * rep.price
DrugDeals[getCid(source)] = {item = k, amount = amount, price = price, ped = ped}
Log(GetName(source) .. ' Allowed To Sell ' .. k .. '!' , 'cornerselling')
return DrugDeals[getCid(source)]
end
end
return {item = 'nothing', amount = 0, price = 0, ped = ped}
end)
lib.callback.register('md-drugs:server:hasDrugs', function(source)
local Player = getPlayer(source)
for k, v in pairs(Drugs) do
local item = hasItem(source, k, 1)
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 == getCid(source) and v.item == item and v.amount == amount and v.price == price then
if handleCornersell(src, item, amount, price) then
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
if not isIn then return false end
if DrugDeals[getCid(src)] then
if DrugDeals[getCid(src)].item == item and DrugDeals[getCid(src)].amount == amount and DrugDeals[getCid(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 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)
lib.addCommand('cornersell', {
@@ -179,18 +181,13 @@ 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 == getCid(source) then
TriggerClientEvent('md-drugs:client:cornerselling:remove', src, DrugDeals[k].ped)
table.remove(DrugDeals, k)
end
if DrugDeals[getCid(src)] then
DrugDeals[getCid(src)] = nil
end
end)