- half done
This commit is contained in:
1 parent
d2f70d78ed
commit
ebc47ba5d7
41 files changed
+1499
-1012
No files matched your search
@@ -47,16 +47,16 @@ end)
|
||||
RegisterServerEvent("md-drugs:server:purchaseGoods", function(item)
|
||||
local src = source
|
||||
if not ps.checkDistance(src, loc, 10) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), "error")
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return
|
||||
end
|
||||
if not stores.travel[item] then
|
||||
ps.notify(src, ps.lang('Catches.invalidItem'), "error")
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.invalidItem'), "error")
|
||||
return
|
||||
end
|
||||
if ps.removeMoney(src, 'cash', stores.travel[item]) then
|
||||
ps.addItem(src, item, 1)
|
||||
else
|
||||
ps.notify(src, ps.lang('Catches.notEnoughMoney'), "error")
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notEnoughMoney'), "error")
|
||||
end
|
||||
end)
|
||||
+75
-66
@@ -1,5 +1,7 @@
|
||||
Recipes = Recipes or {}
|
||||
Locations = Locations or {}
|
||||
|
||||
local cocaineRecipes = {
|
||||
Recipes.Cocaine = {
|
||||
cokepowder = {
|
||||
tier1 = {take = {coca_leaf = 1}, give = {coke = 1}},
|
||||
tier2 = {take = {coca_leaf = 1}, give = {cokestagetwo = 1}},
|
||||
@@ -16,124 +18,131 @@ local cocaineRecipes = {
|
||||
tier3 = {take = {loosecokestagethree = 1, empty_weed_bag = 1}, give = {cokebaggystagethree = 1}},
|
||||
}
|
||||
}
|
||||
GlobalState.MDDrugsRecipes = Recipes
|
||||
|
||||
local cocaineLocations = {
|
||||
Locations.Cocaine = {
|
||||
MakePowder = {
|
||||
{loc = vector3(1086.20, -3195.30, -39.20), l = 1.0, w = 1.0, rot = 45.0, gang = ""},
|
||||
},
|
||||
CuttingCoke = {
|
||||
{loc = vector3(1095.61, -3195.62, -39.13), l = 1.0, w = 1.0, rot = 45.0, offset = vec3(-1.782227, 0.445068, -0.502701), rotation = vector3(0,0,0), gang = ""},
|
||||
--{loc = vector3(1092.74, -3196.68, -38.99), l = 1.0, w = 1.0, rot = 45.0, offset = vec3(1.983398, 0.407959, -0.642696), rotation = vector3(0,0,180.0), gang = ""},
|
||||
},
|
||||
BaggingCoke = {
|
||||
{loc = vector3(1093.16, -3195.78, -39.19), l = 1.0, w = 1.0, rot = 45.0,offset = vec3(4.515137, 2.542969, -0.814194), rotation = vector3(0,0,180.0), gang = ""},
|
||||
--{loc = vector3(1090.17, -3196.59, -38.99), l = 1.0, w = 1.0, rot = 45.0, offset = vec3(-5.207642, -1.666504, -1.014198), rotation = vector3(0,0, 0.0), gang = ""},
|
||||
},
|
||||
cokeTele = {
|
||||
{inside = vector3(1088.81, -3187.57, -38.99), outside = vector3(198.16, -1276.92, 29.33), l = 1.0, w = 1.0, rot = 45.0, gang = ""},
|
||||
}
|
||||
}
|
||||
GlobalState.MDDrugsLocations = Locations
|
||||
|
||||
ps.registerCallback('md-drugs:server:GetCokeLocations', function()
|
||||
return cocaineLocations
|
||||
end)
|
||||
local function getTier(source)
|
||||
if not Config.TierSystem then
|
||||
return 'tier1'
|
||||
end
|
||||
local rep = tonumber(getRep(source, 'coke'))
|
||||
if not rep then
|
||||
return
|
||||
end
|
||||
if rep < Config.Tier1 then
|
||||
return 'tier1'
|
||||
end
|
||||
if rep >= Config.Tier1 and rep <= Config.Tier2 then
|
||||
return 'tier2'
|
||||
end
|
||||
if rep >= Config.Tier2 then
|
||||
return 'tier3'
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
RegisterServerEvent('md-drugs:server:makepowder', function(num)
|
||||
local src = source
|
||||
|
||||
if timeOut(src, 'md-drugs:server:makepowder') then return end
|
||||
if not ps.checkDistance(src, cocaineLocations.MakePowder[num].loc, 3.5) then
|
||||
ps.warn(ps.lang('Catches.notIn', ps.getPlayerName(src)), 'md-drugs:server:makepowder')
|
||||
|
||||
if not checkDistance(src, Locations.Cocaine.MakePowder[num].loc, 3.5) then
|
||||
Bridge.Prints.Warm(Bridge.Language.Locale('Catches.notIn', ps.getPlayerName(src)), 'md-drugs:server:makepowder')
|
||||
return
|
||||
end
|
||||
local tier = 'tier1'
|
||||
if Config.TierSystem then
|
||||
local coke = tonumber(getRep(src, 'coke'))
|
||||
if coke > Config.Tier1 and coke <= Config.Tier2 then
|
||||
tier = 'tier2'
|
||||
elseif coke > Config.Tier2 then
|
||||
tier = 'tier3'
|
||||
end
|
||||
|
||||
local tier = getTier(src)
|
||||
if not tier then
|
||||
return
|
||||
end
|
||||
if not ps.craftItem(src, cocaineRecipes['cokepowder'][tier]) then
|
||||
verifyHas(src, cocaineRecipes['cokepowder'][tier].take)
|
||||
|
||||
if not craft(src, Recipes.Cocaine.cokepowder[tier]) then
|
||||
return
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:cutcokeone', function(num)
|
||||
local src = source
|
||||
local tier = 'tier1'
|
||||
|
||||
if timeOut(src, 'md-drugs:server:cutcokeone') then return end
|
||||
if not ps.checkDistance(src, cocaineLocations.CuttingCoke[num].loc, 2.5) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), 'error')
|
||||
|
||||
if not checkDistance(src, Locations.Cocaine.CuttingCoke[num].loc, 2.5) then
|
||||
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.notIn'), 'error')
|
||||
return
|
||||
end
|
||||
if Config.TierSystem then
|
||||
local cokeTiers = {
|
||||
{item = 'coke', tier = 'tier1', log = ' Cut Coke'},
|
||||
{item = 'cokestagetwo', tier = 'tier2', log = ' Cut Coke tier 2'},
|
||||
{item = 'cokestagethree', tier = 'tier3', log = ' Cut Coke tier 3'}
|
||||
}
|
||||
for _, v in ipairs(cokeTiers) do
|
||||
if ps.hasItem(src, v.item) then
|
||||
tier = v.tier
|
||||
break
|
||||
end
|
||||
local tier = 'tier1'
|
||||
local itemCheck = {
|
||||
{check = Bridge.Inventory.HasItem(src,'loosecoke'), tier = 'tier1'},
|
||||
{check = Bridge.Inventory.HasItem(src, 'loosecokestagetwo'), tier = 'tier2'},
|
||||
{check = Bridge.Inventory.HasItem(src, 'loosecokestagethree'), tier = 'tier3'},
|
||||
}
|
||||
for i = 1, #itemCheck do
|
||||
if itemCheck[i].check then
|
||||
tier = itemCheck[i].tier
|
||||
break
|
||||
end
|
||||
end
|
||||
if not ps.craftItem(src, cocaineRecipes['cutcoke'][tier]) then
|
||||
verifyHas(src, cocaineRecipes['cutcoke'][tier].take)
|
||||
if not craft(src, Recipes.Cocaine.cutcoke[tier]) then
|
||||
return
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:bagcoke', function(num)
|
||||
local src = source
|
||||
local tier = 'tier1'
|
||||
|
||||
if timeOut(src, 'md-drugs:server:bagcoke') then return end
|
||||
if not ps.checkDistance(src, cocaineLocations.BaggingCoke[num].loc, 2.5) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), 'error')
|
||||
|
||||
if not checkDistance(src, Locations.Cocaine.BaggingCoke[num].loc, 2.5) then
|
||||
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.notIn'), 'error')
|
||||
return
|
||||
end
|
||||
if Config.TierSystem then
|
||||
local cokeTiers = {
|
||||
{item = 'loosecoke', tier = 'tier1', log = ' Bagged Coke'},
|
||||
{item = 'loosecokestagetwo', tier = 'tier2', log = ' Bagged Coke tier 2'},
|
||||
{item = 'loosecokestagethree', tier = 'tier3', log = ' Bagged Coke tier 3'}
|
||||
}
|
||||
for _, v in ipairs(cokeTiers) do
|
||||
if ps.hasItem(src, v.item) then
|
||||
tier = v.tier
|
||||
break
|
||||
end
|
||||
end
|
||||
if not ps.craftItem(src, cocaineRecipes['bagcoke'][tier]) then
|
||||
verifyHas(src, cocaineRecipes['bagcoke'][tier].take)
|
||||
return
|
||||
end
|
||||
AddRep(src, 'coke')
|
||||
else
|
||||
if not ps.craftItem(src, cocaineRecipes['bagcoke'][tier]) then
|
||||
verifyHas(src, cocaineRecipes['bagcoke'][tier].take)
|
||||
return
|
||||
local tier = 'tier1'
|
||||
local itemCheck = {
|
||||
{check = Bridge.Inventory.HasItem(src,'coke'), tier = 'tier1'},
|
||||
{check = Bridge.Inventory.HasItem(src, 'cokestagetwo'), tier = 'tier2'},
|
||||
{check = Bridge.Inventory.HasItem(src, 'cokestagethree'), tier = 'tier3'},
|
||||
}
|
||||
for i = 1, #itemCheck do
|
||||
if itemCheck[i].check then
|
||||
tier = itemCheck[i].tier
|
||||
break
|
||||
end
|
||||
end
|
||||
if not craft(src, Recipes.Cocaine.bagcoke[tier]) then
|
||||
return
|
||||
end
|
||||
AddRep(src, 'coke', 1)
|
||||
end)
|
||||
|
||||
local cokecut = {loosecokestagetwo = 2, loosecokestagethree = 3}
|
||||
for k, v in pairs (cokecut) do
|
||||
ps.createUseable(k, function(source, item)
|
||||
Bridge.Framework.RegisterUsableItem(k, function(source, item)
|
||||
local src = source
|
||||
if not ps.hasItem(src, 'bakingsoda') then
|
||||
ps.notify(src, ps.lang('coke.needBakingSoda'), 'error')
|
||||
if not Bridge.Inventory.HasItem(src, 'bakingsoda') then
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('coke.needBakingSoda'), 'error')
|
||||
return
|
||||
end
|
||||
if ps.hasItem(src,item.name) then
|
||||
if Bridge.Inventory.HasItem(src,item.name) then
|
||||
local check = ps.callback('md-drugs:client:uncuff', src, 'Cutting It Further')
|
||||
if not check then return end
|
||||
if ps.removeItem(src, k, 1) and ps.removeItem(src, 'bakingsoda', 1) then
|
||||
ps.addItem(src, 'loosecoke', v)
|
||||
if Bridge.Inventory.RemoveItem(src, k, 1) and Bridge.Inventory.RemoveItem(src, 'bakingsoda', 1) then
|
||||
Bridge.Inventory.AddItem(src, 'loosecoke', v)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
+77
-40
@@ -122,6 +122,7 @@ local Drugs = {
|
||||
}
|
||||
|
||||
local drugsNames = {}
|
||||
local soldPeds = {}
|
||||
for k, v in pairs(Drugs) do
|
||||
table.insert(drugsNames, k)
|
||||
end
|
||||
@@ -135,53 +136,73 @@ local cornsellConfig = {
|
||||
policeRequired = 0, -- if you want cops to be required to sell set this to a number above 0
|
||||
robChance = 1, -- Chance To Be Robbed 1 = 1%
|
||||
}
|
||||
|
||||
local function beingRobbed(source, item, amount, ped)
|
||||
local src = source
|
||||
ps.removeItem(src, item, amount)
|
||||
ps.notify(src, ps.lang('Cornerselling.gotRobbed'), 'error')
|
||||
RobbedDrugs[ps.getIdentifier(source)] = {item = item, amount = amount, ped = ped}
|
||||
Bridge.Inventory.RemoveItem(src, item, amount)
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Cornerselling.gotRobbed'), 'error')
|
||||
RobbedDrugs[src] = {item = item, amount = amount, ped = ped}
|
||||
return true
|
||||
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, ps.lang('Cornerselling.gotBack'), 'success')
|
||||
RobbedDrugs[ps.getIdentifier(source)] = nil
|
||||
if RobbedDrugs[src] then
|
||||
if RobbedDrugs[src].item == item and RobbedDrugs[src].amount == amount then
|
||||
Bridge.Inventory.AddItem(src, item, amount)
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Cornerselling.gotBack'), 'success')
|
||||
RobbedDrugs[src] = nil
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ps.registerCallback('md-drugs:server:cornerselling:getAvailableDrugs', function(source, ped)
|
||||
local Player = ps.getPlayer(source)
|
||||
local function getLoc(src, ped)
|
||||
local coords, peds = GetEntityCoords(GetPlayerPed(src)), GetEntityCoords(ped)
|
||||
local dist = #(coords - peds)
|
||||
if dist < 5.0 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
Bridge.Callback.Register('md-drugs:server:cornerselling:getAvailableDrugs', function(source, ped)
|
||||
local src = source
|
||||
local rep = getRep(source, 'cornerselling')
|
||||
local priceAdjust = json.decode(rep).price
|
||||
if not Player then return nil end
|
||||
local priceAdjust = rep.price
|
||||
local ped = NetworkGetEntityFromNetworkId(ped)
|
||||
if not getLoc(src, ped) then
|
||||
return false
|
||||
end
|
||||
if soldPeds[src] == nil then
|
||||
soldPeds[src] = {}
|
||||
end
|
||||
if soldPeds[src][ped] then
|
||||
return false
|
||||
end
|
||||
for k, v in pairs(Drugs) do
|
||||
local item = ps.getItemCount(source, k) or 0
|
||||
if item >= 1 then
|
||||
local count = Bridge.Inventory.GetItemCount(src, k)
|
||||
if count >= 1 then
|
||||
local maths = math.random(1,100)
|
||||
if maths <= cornsellConfig.robChance then
|
||||
beingRobbed(source, k, item, ped)
|
||||
beingRobbed(source, k, count, ped)
|
||||
soldPeds[src][ped] = {item = k, amount = count}
|
||||
return 'robbed'
|
||||
else
|
||||
if item > 15 then item = 15 end
|
||||
local amount = math.random(1, item)
|
||||
if count > 15 then count = 15 end
|
||||
local amount = math.random(1, count)
|
||||
local price = (math.random(Drugs[k]['min'], Drugs[k]['max']) * amount) * priceAdjust
|
||||
DrugDeals[ps.getIdentifier(source)] = {item = k, amount = amount, price = math.floor(price), ped = ped}
|
||||
return DrugDeals[ps.getIdentifier(source)]
|
||||
DrugDeals[src] = {item = k, amount = amount, price = math.floor(price), ped = ped}
|
||||
soldPeds[src][ped] = DrugDeals[src]
|
||||
return DrugDeals[src]
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end)
|
||||
|
||||
ps.registerCallback('md-drugs:server:hasDrugs', function(source)
|
||||
Bridge.Callback.Register('md-drugs:server:hasDrugs', function(source)
|
||||
for k, v in pairs(Drugs) do
|
||||
if ps.hasItem(source, k, 1) then
|
||||
if Bridge.Inventory.HasItem(source, k) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -196,51 +217,67 @@ local function csCheck(src, item, amount, price)
|
||||
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
|
||||
if DrugDeals[src] then
|
||||
if DrugDeals[src].item == item and DrugDeals[src].amount == amount and DrugDeals[src].price == price then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
RegisterNetEvent('md-drugs:server:sellCornerDrugs', function(item, amount, price)
|
||||
RegisterNetEvent('md-drugs:server:sellCornerDrugs', function(item, amount, price, peds)
|
||||
local src = source
|
||||
if not csCheck(src, item, amount, price) then return end
|
||||
if not ps.removeItem(src, item, amount) then
|
||||
ps.notify(src, ps.lang('Cornerselling.notEnough'), 'error')
|
||||
DrugDeals[ps.getIdentifier(src)] = nil
|
||||
if not csCheck(src, item, amount, price) then
|
||||
return
|
||||
end
|
||||
local ped = NetworkGetEntityFromNetworkId(peds)
|
||||
if not getLoc(src, ped) then
|
||||
print('not close enough to ped')
|
||||
return
|
||||
end
|
||||
if not soldPeds[src] or not soldPeds[src][ped] then
|
||||
print('ped not in soldPeds')
|
||||
return
|
||||
end
|
||||
if not Bridge.Inventory.RemoveItem(src, item, amount) then
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Cornerselling.notEnough'), 'error')
|
||||
DrugDeals[src] = nil
|
||||
return
|
||||
end
|
||||
AddRep(src, 'cornerselling', Drugs[item].rep * amount)
|
||||
DrugDeals[ps.getIdentifier(src)] = nil
|
||||
DrugDeals[src] = nil
|
||||
if cornsellConfig.MarkedBills then
|
||||
ps.addItem(src, 'markedbills', price, {worth = price})
|
||||
Bridge.Inventory.AddItem(src, 'markedbills', price, nil, {worth = price})
|
||||
return
|
||||
end
|
||||
if cornsellConfig.CustomItem ~= '' then
|
||||
ps.addItem(src, cornsellConfig.CustomItem, price)
|
||||
Bridge.Inventory.AddItem(src, cornsellConfig.CustomItem, price)
|
||||
return
|
||||
end
|
||||
ps.addMoney(src, 'cash', price)
|
||||
Bridge.Framework.AddAccountBalance(src, 'cash', price)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('md-drugs:server:getBackRobbed', function()
|
||||
local tabl = RobbedDrugs[ps.getIdentifier(source)]
|
||||
RegisterNetEvent('md-drugs:server:getBackRobbed', function(peds)
|
||||
local src = source
|
||||
local tabl = RobbedDrugs[src]
|
||||
if tabl == nil then return end
|
||||
getDrugBack(source, tabl.item, tabl.amount)
|
||||
RobbedDrugs[ps.getIdentifier(source)] = nil
|
||||
local ped = NetworkGetEntityFromNetworkId(peds)
|
||||
if ped ~= tabl.ped then return end
|
||||
if not getLoc(src, ped) then return end
|
||||
|
||||
getDrugBack(src, tabl.item, tabl.amount)
|
||||
RobbedDrugs[src] = nil
|
||||
end)
|
||||
|
||||
ps.registerCommand('cornersell', {
|
||||
help = ps.lang('Cornerselling.comDes'),
|
||||
help = Bridge.Language.Locale('Cornerselling.comDes'),
|
||||
params = {
|
||||
},
|
||||
}, function(source, args, raw)
|
||||
local src = source
|
||||
local jobCount = ps.getJobTypeCount('leo')
|
||||
if jobCount < cornsellConfig.policeRequired then
|
||||
ps.notify(src, ps.lang('Catches.noCops'), 'error')
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.noCops'), 'error')
|
||||
return
|
||||
end
|
||||
TriggerClientEvent('md-drugs:client:cornerselling', src)
|
||||
@@ -248,7 +285,7 @@ end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:cornerselling:stop', function()
|
||||
local src = source
|
||||
if DrugDeals[ps.getIdentifier(src)] then
|
||||
DrugDeals[ps.getIdentifier(src)] = nil
|
||||
if DrugDeals[src] then
|
||||
DrugDeals[src] = nil
|
||||
end
|
||||
end)
|
||||
+45
-41
@@ -1,17 +1,20 @@
|
||||
local crackRecipe = {
|
||||
Recipes, Locations = Recipes or {}, Locations or {}
|
||||
|
||||
Recipes.Crack = {
|
||||
cookcrack = {
|
||||
tier1 = {take = {loosecoke = 1, bakingsoda = 1}, give = {crackrock = 1}},
|
||||
tier2 = {take = {loosecokestagetwo = 1, bakingsoda = 1}, give = {crackrockstagetwo = 1}},
|
||||
tier3 = {take = {loosecokestagethree = 1,bakingsoda = 1}, give = {crackrockstagethree = 1}},
|
||||
tier1 = {take = {loosecoke = 1, bakingsoda = 1}, give = {crackrock = 1}},
|
||||
tier2 = {take = {loosecokestagetwo = 1, bakingsoda = 1}, give = {crackrockstagetwo = 1}},
|
||||
tier3 = {take = {loosecokestagethree = 1,bakingsoda = 1}, give = {crackrockstagethree = 1}},
|
||||
},
|
||||
bagcrack = {
|
||||
tier1 = {take = {crackrock = 1, empty_weed_bag = 1}, give = {baggedcracked = 1}},
|
||||
tier2 = {take = {crackrockstagetwo = 1, empty_weed_bag = 1}, give = {baggedcrackedstagetwo = 1}},
|
||||
tier3 = {take = {crackrockstagethree = 1, empty_weed_bag = 1}, give = {baggedcrackedstagethree = 1}},
|
||||
tier1 = {take = {crackrock = 1, empty_weed_bag = 1}, give = {baggedcracked = 1}},
|
||||
tier2 = {take = {crackrockstagetwo = 1, empty_weed_bag = 1}, give = {baggedcrackedstagetwo = 1}},
|
||||
tier3 = {take = {crackrockstagethree = 1, empty_weed_bag = 1}, give = {baggedcrackedstagethree = 1}},
|
||||
}
|
||||
}
|
||||
GlobalState.MDDrugsRecipes = Recipes
|
||||
|
||||
local CrackLocations = {
|
||||
Locations.Crack = {
|
||||
makecrack = { -- make crack with baking soda with cut coke 1-3
|
||||
{loc = vector3(2433.47, 4970.02, 42.18), l = 1.0, w = 1.0, rot = 45.0, gang = ""},
|
||||
},
|
||||
@@ -19,21 +22,18 @@ local CrackLocations = {
|
||||
{loc = vector3(2436.55, 4964.96, 42.18), l = 1.0, w = 1.0, rot = 45.0, gang = ""},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
ps.registerCallback('md-drugs:server:GetCrackLocations', function()
|
||||
return CrackLocations
|
||||
end)
|
||||
GlobalState.MDDrugsLocations = Locations
|
||||
|
||||
RegisterServerEvent('md-drugs:server:makecrackone', function(num)
|
||||
local src = source
|
||||
local tier = 'tier1'
|
||||
|
||||
if timeOut(src, 'md-drugs:server:makecrackone') then return end
|
||||
if not ps.checkDistance(src, CrackLocations.makecrack[num].loc, 2.0) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), 'error')
|
||||
|
||||
if not checkDistance(src, Locations.Crack.makecrack[num].loc, 2.0) then
|
||||
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.notIn'), 'error')
|
||||
return
|
||||
end
|
||||
|
||||
local tier = 'tier1'
|
||||
if Config.TierSystem then
|
||||
local crackTiers = {
|
||||
{item = 'loosecoke', tier = 'tier1'},
|
||||
@@ -41,14 +41,13 @@ RegisterServerEvent('md-drugs:server:makecrackone', function(num)
|
||||
{item = 'loosecokestagethree', tier = 'tier3'}
|
||||
}
|
||||
for _, v in ipairs(crackTiers) do
|
||||
if ps.hasItem(src, v.item) then
|
||||
if Bridge.Inventory.HasItem(src, v.item) then
|
||||
tier = v.tier
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if not ps.craftItem(src, crackRecipe['cookcrack'][tier]) then
|
||||
verifyHas(src, crackRecipe['cookcrack'][tier].take)
|
||||
if not craft(src, Recipes.Crack.cookcrack[tier]) then
|
||||
return
|
||||
end
|
||||
end)
|
||||
@@ -56,41 +55,46 @@ end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:bagcrack', function(num)
|
||||
local src = source
|
||||
local tier = 'tier1'
|
||||
|
||||
if timeOut(src, 'md-drugs:server:bagcrack') then return end
|
||||
if not ps.checkDistance(src, CrackLocations.bagcrack[num].loc, 2.0) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), 'error')
|
||||
|
||||
if not checkDistance(src, Locations.Crack.bagcrack[num].loc, 2.0) then
|
||||
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.notIn'), 'error')
|
||||
return
|
||||
end
|
||||
|
||||
local tier = 'tier1'
|
||||
if Config.TierSystem then
|
||||
local crackTiers = {
|
||||
{item = 'crackrock', tier = 'tier1'},
|
||||
{item = 'crackrockstagetwo', tier = 'tier2'},
|
||||
{item = 'crackrock', tier = 'tier1'},
|
||||
{item = 'crackrockstagetwo', tier = 'tier2'},
|
||||
{item = 'crackrockstagethree', tier = 'tier3'}
|
||||
}
|
||||
for _, v in ipairs(crackTiers) do
|
||||
if ps.hasItem(src, v.item) then
|
||||
if Bridge.Inventory.HasItem(src, v.item) then
|
||||
tier = v.tier
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if not ps.craftItem(src, crackRecipe['bagcrack'][tier]) then
|
||||
verifyHas(src, crackRecipe['bagcrack'][tier].take)
|
||||
if not craft(src, Recipes.Crack.bagcrack[tier]) then
|
||||
return
|
||||
end
|
||||
end)
|
||||
|
||||
local cokecut = {crackrockstagetwo = 2, crackrockstagethree = 3}
|
||||
for k, v in pairs (cokecut) do
|
||||
ps.createUseable(k, function(source, item)
|
||||
Bridge.Framework.RegisterUsableItem(k, function(source, item)
|
||||
local src = source
|
||||
if ps.hasItem(src, item.name) then
|
||||
if not ps.hasItem(src, 'bakingsoda', 1) then return end
|
||||
local check = ps.callback('md-drugs:client:uncuff', src, 'Cutting Crack Rock Further')
|
||||
if not Bridge.Inventory.HasItem(src, 'bakingsoda') then
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('coke.needBakingSoda'), 'error')
|
||||
return
|
||||
end
|
||||
if Bridge.Inventory.HasItem(src,item.name) then
|
||||
local check = ps.callback('md-drugs:client:uncuff', src, 'Cutting It Further')
|
||||
if not check then return end
|
||||
if ps.removeItem(src, k, 1) and ps.removeItem(src, 'bakingsoda', 1) then
|
||||
ps.addItem(src, 'crackrock', v)
|
||||
if Bridge.Inventory.RemoveItem(src, k, 1) and Bridge.Inventory.RemoveItem(src, 'bakingsoda', 1) then
|
||||
Bridge.Inventory.AddItem(src, 'crackrock', v)
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -98,18 +102,18 @@ end
|
||||
|
||||
RegisterNetEvent("md-drugs:server:failcrackone", function(num)
|
||||
local src = source
|
||||
if not ps.checkDistance(src, CrackLocations.makecrack[num].loc, 2.0) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), 'error')
|
||||
if not checkDistance(src, Locations.Crack.makecrack[num].loc, 2.0) then
|
||||
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.notIn'), 'error')
|
||||
return
|
||||
end
|
||||
local items = {
|
||||
loosecoke = 1,
|
||||
loosecokestagetwo = 1,
|
||||
loosecokestagethree = 1
|
||||
'loosecoke',
|
||||
'loosecokestagetwo',
|
||||
'loosecokestagethree',
|
||||
}
|
||||
for k,v in pairs(items) do
|
||||
if ps.hasItem(src, k, v) then
|
||||
ps.removeItem(src, k, v)
|
||||
if Bridge.Inventory.HasItem(src, v) then
|
||||
Bridge.Inventory.RemoveItem(src, v, 1)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
+69
-65
@@ -1,4 +1,4 @@
|
||||
|
||||
Locations = Locations or {}
|
||||
|
||||
local dloc = {
|
||||
{coords = vector4(282.48, -1814.32, 27.23, 145.11)},
|
||||
@@ -88,36 +88,29 @@ local Products = {
|
||||
{name = "weed_amnesia_seed", price = 15, amount = 150, minrep = 0},
|
||||
}
|
||||
|
||||
ps.registerCallback('md-drugs:server:dealerList', function()
|
||||
local Dealers = {}
|
||||
|
||||
|
||||
Bridge.Callback.Register('md-drugs:server:dealerList', function(source, location)
|
||||
local coords = json.decode(Dealers[location].coords)
|
||||
coords = vector3(coords.x, coords.y, coords.z)
|
||||
if not checkDistance(source, coords, 4.0) then
|
||||
return
|
||||
end
|
||||
return Products
|
||||
end)
|
||||
|
||||
ps.registerCallback('md-drugs:server:getDealers', function(source)
|
||||
local check = MySQL.query.await('SELECT * FROM dealers', {})
|
||||
local loc = json.encode({x = 899.98, y = -2603.24, z = 6.11, h = 176.12 })
|
||||
if not check[1] then
|
||||
MySQL.insert('INSERT INTO dealers SET name = ?, coords = ?, time = ?, createdby = ?', {'MD', loc, 'any', 'code Newb'})
|
||||
Wait(2000)
|
||||
local check2 = MySQL.query.await('SELECT * FROM dealers', {})
|
||||
return check2
|
||||
else
|
||||
return check
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
local DeliveryItems = {
|
||||
{ item = "weed_brick", minrep = 0, payout = {min = 10, max = 50}},
|
||||
{ item = "coke_brick", minrep = 0, payout = {min = 10, max = 50}},
|
||||
}
|
||||
|
||||
ps.registerCallback('md-drugs:server:GetDeliveryItem', function(source, data)
|
||||
Bridge.Callback.Register('md-drugs:server:GetDeliveryItem', function(source, data)
|
||||
local src = source
|
||||
local Player = ps.getPlayer(src)
|
||||
local itemnum = math.random(1, #DeliveryItems)
|
||||
local item = DeliveryItems[itemnum].item
|
||||
local amount = math.random(1,4)
|
||||
local check = MySQL.query.await('SELECT * FROM deliveriesdealer WHERE cid = ?', {ps.getIdentifier(src)})
|
||||
local check = MySQL.query.await('SELECT * FROM deliveriesdealer WHERE cid = ?', {Bridge.Framework.GetPlayerIdentifier(src)})
|
||||
local locnum = math.random(1, #dloc)
|
||||
local coord = json.encode({
|
||||
x = dloc[locnum].coords.x,
|
||||
@@ -127,8 +120,8 @@ ps.registerCallback('md-drugs:server:GetDeliveryItem', function(source, data)
|
||||
})
|
||||
if not check[1] then
|
||||
MySQL.insert('INSERT INTO deliveriesdealer SET cid = ?, itemdata = ?, timestart = ?, maxtime = ?, location = ?',
|
||||
{ps.getIdentifier(src), json.encode({item = item, amount = amount}), os.time(), os.time() + (15 * 60), coord })
|
||||
ps.addItem(src, item, amount)
|
||||
{Bridge.Framework.GetPlayerIdentifier(src), json.encode({item = item, amount = amount}), os.time(), os.time() + (15 * 60), coord })
|
||||
Bridge.Inventory.AddItem(src, item, amount)
|
||||
local tab = {
|
||||
bool = true,
|
||||
item = item,
|
||||
@@ -141,11 +134,11 @@ ps.registerCallback('md-drugs:server:GetDeliveryItem', function(source, data)
|
||||
local timeout = math.floor(os.difftime(time, check[1].maxtime) / 60)
|
||||
|
||||
if timeout > 15 then
|
||||
MySQL.query.await('DELETE FROM deliveriesdealer WHERE cid = ?', {ps.getIdentifier(src)})
|
||||
ps.notify(src, ps.lang('Deliveries.slowAf'), 'error' )
|
||||
MySQL.query.await('DELETE FROM deliveriesdealer WHERE cid = ?', {Bridge.Framework.GetPlayerIdentifier(src)})
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Deliveries.slowAf'), 'error' )
|
||||
return {bool = false}
|
||||
end
|
||||
ps.notify(src,ps.lang('Deliveries.alreadyDelivering'), 'error' )
|
||||
Bridge.Notify.SendNotify(src,Bridge.Language.Locale('Deliveries.alreadyDelivering'), 'error' )
|
||||
local tab = {
|
||||
bool = false,
|
||||
item = item,
|
||||
@@ -158,37 +151,43 @@ end)
|
||||
|
||||
RegisterNetEvent('md-drugs:server:giveDeliveryItems', function(item, amount)
|
||||
local src = source
|
||||
local Player = ps.getPlayer(src)
|
||||
local check = MySQL.query.await('SELECT * FROM deliveriesdealer WHERE cid = ?', {ps.getIdentifier(src)})
|
||||
local id = Bridge.Framework.GetPlayerIdentifier(src)
|
||||
local check = MySQL.query.await('SELECT * FROM deliveriesdealer WHERE cid = ?', {id})
|
||||
if not check[1] then return end
|
||||
local time = os.time()
|
||||
local timeout = math.floor(os.difftime(time, check[1].maxtime) / 60)
|
||||
local itemData = json.decode(check[1].itemdata)
|
||||
if timeout >= 15 then
|
||||
MySQL.query.await('DELETE FROM deliveriesdealer WHERE cid = ?', {ps.getIdentifier(src)})
|
||||
ps.notify(src, ps.lang('Deliveries.slowAf'), 'error' )
|
||||
MySQL.query.await('DELETE FROM deliveriesdealer WHERE cid = ?', {id})
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Deliveries.slowAf'), 'error' )
|
||||
return
|
||||
end
|
||||
|
||||
if item ~= itemData.item then return end
|
||||
if amount ~= itemData.amount then return end
|
||||
if ps.removeItem(src, item, amount) then
|
||||
local coords = json.decode(check[1].location)
|
||||
coords = vector3(coords.x, coords.y, coords.z)
|
||||
if not checkDistance(src, coords, 5.0) then
|
||||
return
|
||||
end
|
||||
if Bridge.Inventory.RemoveItem(src, item, amount) then
|
||||
for k, v in pairs (DeliveryItems) do
|
||||
if v.item == item then
|
||||
local income = math.random(v.payout.min, v.payout.max)
|
||||
ps.addMoney(src, 'cash', income)
|
||||
AddRep(src, 'dealerrep')
|
||||
Bridge.Framework.AddAccountBalance(src, 'cash', income)
|
||||
AddRep(src, 'dealerrep')
|
||||
end
|
||||
end
|
||||
MySQL.query.await('DELETE FROM deliveriesdealer WHERE cid = ?', {ps.getIdentifier(src)})
|
||||
MySQL.query.await('DELETE FROM deliveriesdealer WHERE cid = ?', {id})
|
||||
end
|
||||
end)
|
||||
|
||||
-- TODO: COmmands
|
||||
ps.registerCommand("newdealer", {
|
||||
help = ps.lang('Deliveries.newDealerHelp.help'),
|
||||
help = Bridge.Language.Locale('Deliveries.newDealerHelp.help'),
|
||||
description = {
|
||||
{ name = "name", help = ps.lang('Deliveries.newDealerHelp.name'), type = "string" },
|
||||
{ name = "min", help = ps.lang('Deliveries.newDealerHelp.timeMin'), type = "number" },
|
||||
{ name = "max", help = ps.lang('Deliveries.newDealerHelp.timeMax'), type = "number" }
|
||||
{ name = "name", help = Bridge.Language.Locale('Deliveries.newDealerHelp.name'), type = "string" },
|
||||
{ name = "min", help = Bridge.Language.Locale('Deliveries.newDealerHelp.timeMin'), type = "number" },
|
||||
{ name = "max", help = Bridge.Language.Locale('Deliveries.newDealerHelp.timeMax'), type = "number" }
|
||||
},
|
||||
admin = true,
|
||||
}, function(source, args)
|
||||
@@ -202,29 +201,22 @@ ps.registerCommand("newdealer", {
|
||||
|
||||
local result = MySQL.scalar.await('SELECT name FROM dealers WHERE name = ?', { dealerName })
|
||||
if result then
|
||||
return ps.notify(source,ps.lang('Deliveries.DealerExists'), "error")
|
||||
return Bridge.Notify.SendNotify(source,Bridge.Language.Locale('Deliveries.DealerExists'), "error")
|
||||
end
|
||||
|
||||
MySQL.insert('INSERT INTO dealers (name, coords, time, createdby) VALUES (?, ?, ?, ?)', {
|
||||
dealerName, pos, 'nil', ps.getIdentifier(source)
|
||||
}, function()
|
||||
QBConfig.Dealers[dealerName] = {
|
||||
name = dealerName,
|
||||
coords = {
|
||||
x = coords.x,
|
||||
y = coords.y,
|
||||
z = coords.z,
|
||||
h = GetEntityHeading(ped)
|
||||
},
|
||||
}
|
||||
TriggerClientEvent('md-drugs:client:RefreshDealers', -1, QBConfig.Dealers)
|
||||
end)
|
||||
dealerName, pos, 'nil', Bridge.Framework.GetPlayerIdentifier(source)
|
||||
})
|
||||
Wait(1000)
|
||||
Locations.Dealers = MySQL.query.await('SELECT * FROM dealers')
|
||||
GlobalState.MDDrugsLocations = Locations
|
||||
TriggerClientEvent('md-drugs:client:RefreshDealers', -1)
|
||||
end)
|
||||
|
||||
ps.registerCommand("deletedealer", {
|
||||
help = ps.lang('Deliveries.deleteDealerHelp.help'),
|
||||
help = Bridge.Language.Locale('Deliveries.deleteDealerHelp.help'),
|
||||
description = {
|
||||
{ name = "name", help = ps.lang('Deliveries.deleteDealerHelp.name'), type = "string" }
|
||||
{ name = "name", help = Bridge.Language.Locale('Deliveries.deleteDealerHelp.name'), type = "string" }
|
||||
},
|
||||
admin = true
|
||||
}, function(source, args)
|
||||
@@ -233,24 +225,36 @@ ps.registerCommand("deletedealer", {
|
||||
|
||||
if result and result[1] then
|
||||
MySQL.query('DELETE FROM dealers WHERE name = ?', { dealerName })
|
||||
QBConfig.Dealers[dealerName] = nil
|
||||
TriggerClientEvent('md-drugs:client:RefreshDealers', -1, QBConfig.Dealers)
|
||||
ps.notify(source, ps.lang('Deliveries.deleteDealerSuccess'), "success")
|
||||
Wait(1000)
|
||||
Locations.Dealers = MySQL.query.await('SELECT * FROM dealers')
|
||||
GlobalState.MDDrugsLocations = Locations
|
||||
TriggerClientEvent('md-drugs:client:RefreshDealers', -1)
|
||||
Bridge.Notify.SendNotify(source, Bridge.Language.Locale('Deliveries.deleteDealerSuccess'), "success")
|
||||
else
|
||||
ps.notify(source, ps.lang('Deliveries.deleteDealerFail'), "error")
|
||||
Bridge.Notify.SendNotify(source, Bridge.Language.Locale('Deliveries.deleteDealerFail'), "error")
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('md-drugs:server:buyItemDealer', function(num)
|
||||
RegisterNetEvent('md-drugs:server:buyItemDealer', function(num, loc)
|
||||
local src = source
|
||||
local itemData = Products[num]
|
||||
if not itemData then return end
|
||||
local Player = ps.getPlayer(src)
|
||||
if not Player then return end
|
||||
if not ps.removeMoney(src, 'cash', itemData.price) or not ps.removeMoney(src,'bank', itemData.price) then
|
||||
ps.notify(src, ps.lang('Catches.notEnoughMoney'), 'error')
|
||||
local coords = json.decode(Dealers[loc].coords)
|
||||
coords = vector3(coords.x, coords.y, coords.z)
|
||||
if not checkDistance(src, coords, 5.0) then
|
||||
return
|
||||
end
|
||||
ps.addItem(src, itemData.name, 1)
|
||||
ps.notify(src, string.format(ps.lang('Deliveries.buyItemSuccess'), 1, ps.getLabel(itemData.name), itemData.price), 'success')
|
||||
end)
|
||||
if not Bridge.Framework.RemoveAccountBalance(src, 'cash', itemData.price) or not Bridge.Framework.RemoveAccountBalance(src,'bank', itemData.price) then
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notEnoughMoney'), 'error')
|
||||
return
|
||||
end
|
||||
Bridge.Inventory.AddItem(src, itemData.name, 1)
|
||||
Bridge.Notify.SendNotify(src, string.format(Bridge.Language.Locale('Deliveries.buyItemSuccess'), 1, ps.getLabel(itemData.name), itemData.price), 'success')
|
||||
end)
|
||||
|
||||
Dealers = MySQL.query.await('SELECT * FROM dealers')
|
||||
if Dealers and not Dealers[1] then
|
||||
MySQL.insert('INSERT INTO dealers SET name = ?, coords = ?, time = ?, createdby = ?', {'MD', json.encode({x = 899.98, y = -2603.24, z = 6.11, h = 176.12 }), 'any', 'code Newb'})
|
||||
end
|
||||
Locations.Dealers = Dealers
|
||||
GlobalState.MDDrugsLocations = Locations
|
||||
+90
-65
@@ -1,111 +1,136 @@
|
||||
local timeOutPlayers = {}
|
||||
local playerRep = {}
|
||||
|
||||
function checkDistance(src, coords, dist)
|
||||
local pcoords = GetEntityCoords(GetPlayerPed(src))
|
||||
coords = vector3(coords.x, coords.y, coords.z)
|
||||
if #(pcoords - coords) > dist then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
local function timeOutThread(src)
|
||||
local id = Bridge.Framework.GetPlayerIdentifier(src)
|
||||
CreateThread(function()
|
||||
timeOutPlayers[ps.getIdentifier(src)] = true
|
||||
timeOutPlayers[id] = true
|
||||
Wait(3000)
|
||||
timeOutPlayers[ps.getIdentifier(src)] = nil
|
||||
timeOutPlayers[id] = nil
|
||||
end)
|
||||
end
|
||||
|
||||
function timeOut(src, event)
|
||||
if timeOutPlayers[ps.getIdentifier(src)] then
|
||||
ps.warn(ps.lang('Catches.onCooldownWarn', ps.getPlayerName(src), event))
|
||||
if timeOutPlayers[src] then
|
||||
local first, last = Bridge.Framework.GetPlayerName(src)
|
||||
Bridge.Prints.Warn(Bridge.Language.Locale('Catches.onCooldownWarn', first .. ' ' .. last, event))
|
||||
return true
|
||||
end
|
||||
timeOutThread(src)
|
||||
return false
|
||||
end
|
||||
|
||||
function verifyHas(source, items)
|
||||
local need = 0
|
||||
local have = 0
|
||||
local missingList = {}
|
||||
|
||||
for k, v in pairs(items) do
|
||||
function craft(source, recipe)
|
||||
local need, have, oops = 0,0,{}
|
||||
for item, amount in pairs (recipe.take) do
|
||||
need = need + 1
|
||||
if ps.hasItem(source, k, v) then
|
||||
local count = Bridge.Inventory.GetItemCount(source, item)
|
||||
if count >= amount then
|
||||
have = have + 1
|
||||
else
|
||||
local label = ps.getItemLabel(k) or k
|
||||
table.insert(missingList, v .. " " .. label)
|
||||
table.insert(oops, 'You Need ' .. amount .. ' X ' .. Bridge.Inventory.GetItemInfo(item).label)
|
||||
end
|
||||
end
|
||||
|
||||
if need == have then
|
||||
return true
|
||||
if have ~= need then
|
||||
for index, text in pairs (oops) do
|
||||
Bridge.Notify.SendNotify(source, text, 'error')
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local message = ps.lang('Catches.itemMissings') .. table.concat(missingList, "\n")
|
||||
ps.notify(source, message, 'error')
|
||||
return false
|
||||
for item, amount in pairs (recipe.take) do
|
||||
if not Bridge.Inventory.RemoveItem(source, item, amount) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
for item, amount in pairs (recipe.give) do
|
||||
Bridge.Inventory.AddItem(source, item, amount)
|
||||
end
|
||||
return true
|
||||
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 = ?', {ps.getIdentifier(source), table, ps.getPlayerName(source)})
|
||||
return json.decode(table)
|
||||
local id = Bridge.Framework.GetPlayerIdentifier(source)
|
||||
local player = {
|
||||
coke = 0,
|
||||
lsd = 0,
|
||||
heroin = 0,
|
||||
dealerrep = 0,
|
||||
cornerselling = {
|
||||
price = QBConfig.SellLevel[1].price,
|
||||
rep = 0,
|
||||
label = QBConfig.SellLevel[1].label,
|
||||
level = 1
|
||||
}
|
||||
}
|
||||
playerRep[id] = player
|
||||
local first, last = Bridge.Framework.GetPlayerName(source)
|
||||
MySQL.insert('INSERT INTO drugrep SET cid = ?, drugrep = ?, name = ?', {id, player, first .. ' ' .. last})
|
||||
end
|
||||
|
||||
local function loadRep(source)
|
||||
local id = Bridge.Framework.GetPlayerIdentifier(source)
|
||||
local hasRep = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {id})
|
||||
if hasRep and not hasRep[1] then
|
||||
handleFresh(source)
|
||||
end
|
||||
if hasRep and hasRep[1] then
|
||||
playerRep[id] = json.decode(hasRep[1].drugrep)
|
||||
end
|
||||
end
|
||||
|
||||
function getRep(source, type)
|
||||
local sql = MySQL.query.await('SELECT JSON_UNQUOTE(JSON_EXTRACT(drugrep, ?)) AS rep FROM drugrep WHERE cid = ?', {'$.' .. type, ps.getIdentifier(source)})
|
||||
if not sql[1] then
|
||||
local new = handleFresh(source)
|
||||
return new[type]
|
||||
else
|
||||
return sql[1].rep
|
||||
local id = Bridge.Framework.GetPlayerIdentifier(source)
|
||||
if not playerRep[id] then
|
||||
loadRep(source)
|
||||
end
|
||||
return playerRep[id][type]
|
||||
end
|
||||
|
||||
function GetAllRep(source)
|
||||
local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {ps.getIdentifier(source)})
|
||||
if not sql[1] then
|
||||
local new = handleFresh(source)
|
||||
return new
|
||||
else
|
||||
local rep = json.decode(sql[1].drugrep)
|
||||
if rep.coke == nil then return rep[1] end
|
||||
return rep
|
||||
local id = Bridge.Framework.GetPlayerIdentifier(source)
|
||||
if not playerRep[id] then
|
||||
loadRep(source)
|
||||
end
|
||||
return playerRep[id]
|
||||
end
|
||||
|
||||
function AddRep(source, type, amount)
|
||||
if not Config.TierSystem then return false end
|
||||
if not amount then amount = 1 end
|
||||
local sql = MySQL.query.await('SELECT * FROM drugrep WHERE cid = ?', {ps.getIdentifier(source)})
|
||||
local reps = json.decode(sql[1].drugrep)
|
||||
local update
|
||||
local rep = ''
|
||||
if reps.coke == nil then rep = reps[1] else rep = reps end
|
||||
if type == 'cornerselling' then
|
||||
for k, v in pairs (QBConfig.SellLevel) do
|
||||
if rep.cornerselling.level == k then
|
||||
if rep.cornerselling.rep + amount >= v.maxrep then
|
||||
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 + 1}})
|
||||
else
|
||||
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
|
||||
if update == '' then return false end
|
||||
MySQL.update('UPDATE drugrep SET drugrep = ? WHERE cid = ?', {update, ps.getIdentifier(source)})
|
||||
return true
|
||||
else
|
||||
rep[type] = rep[type] + amount
|
||||
MySQL.update('UPDATE drugrep SET drugrep = ? WHERE cid = ?', {json.encode(rep), ps.getIdentifier(source)})
|
||||
return true
|
||||
local id = Bridge.Framework.GetPlayerIdentifier(source)
|
||||
if not playerRep[id] then
|
||||
loadRep(source)
|
||||
end
|
||||
if type == 'cornerselling' then
|
||||
local rep = playerRep[id].cornerselling
|
||||
local cornerData = QBConfig.SellLevel[rep.level]
|
||||
if rep.rep + amount >= cornerData.maxrep then
|
||||
rep.level = rep.level + 1
|
||||
rep.label = QBConfig.SellLevel[rep.level].label
|
||||
rep.price = QBConfig.SellLevel[rep.level].price
|
||||
end
|
||||
rep.rep = rep.rep + amount
|
||||
else
|
||||
playerRep[id][type] = playerRep[id][type] + amount
|
||||
end
|
||||
MySQL.query.await('UPDATE drugrep SET drugrep = ? WHERE cid = ?', {json.encode(playerRep[id]), id})
|
||||
end
|
||||
|
||||
-- TODO: Callbacks
|
||||
ps.registerCallback('md-drugs:server:GetCoppers', function(source, cb, args)
|
||||
return ps.getJobTypeCount('leo')
|
||||
return Bridge.Framework.GetPlayersByJob('police')
|
||||
end)
|
||||
|
||||
ps.registerCallback('md-drugs:server:GetRep', function(source, cb, args)
|
||||
local rep = GetAllRep(source)
|
||||
return rep
|
||||
end)
|
||||
ps.versionCheck('md-drugs', 'https://raw.githubusercontent.com/Mustachedom/md-drugs/refs/heads/main/version.txt', 'https://github.com/Mustachedom/md-drugs/')
|
||||
--TODO: fix versioncheck
|
||||
Bridge.Version.VersionChecker('Mustachedom/md-drugs/', false)
|
||||
+125
-127
@@ -1,5 +1,7 @@
|
||||
Recipes, Locations = Recipes or {}, Locations or {}
|
||||
|
||||
local heroinLabKits = {}
|
||||
local heroinRecipes = {
|
||||
Recipes.Heroin = {
|
||||
dryheroin = {
|
||||
tier1 = {take = {poppyresin = 1}, give = {heroin = 1}},
|
||||
tier2 = {take = {poppyresin = 1}, give = {heroinstagetwo = 1}},
|
||||
@@ -17,12 +19,13 @@ local heroinRecipes = {
|
||||
},
|
||||
fillneedle = {
|
||||
tier1 = {take = {heroinvial = 1, needle = 1}, give = {heroin_ready = 1}},
|
||||
tier2 = {take = {heroinvialstagetwo = 1, needle = 1}, give = {heroin_readystagetwo = 1}},
|
||||
tier2 = {take = {heroinvialstagetwo = 1, needle = 1}, give = {heroin_readystagetwo = 1}},
|
||||
tier3 = {take = {heroinvialstagethree = 1, needle = 1}, give = {heroin_readystagethree = 1}},
|
||||
}
|
||||
}
|
||||
GlobalState.MDDrugsRecipes = Recipes
|
||||
|
||||
local heroinLocations = {
|
||||
Locations.Heroin = {
|
||||
dryplant = { -- turn resin into powder
|
||||
{loc = vector3(-1353.77, -335.58, 43.92), l = 1.0, w = 1.0, rot = 45.0, gang = ""},
|
||||
},
|
||||
@@ -36,48 +39,46 @@ local heroinLocations = {
|
||||
{ped = 'a_m_m_farmer_01',loc = vector4(-1366.32, -334.40, 44.44,180.0), l = 1.0, w = 1.0, rot = 45.0, gang = ""},
|
||||
}
|
||||
}
|
||||
GlobalState.MDDrugsLocations = Locations
|
||||
|
||||
local prices = {
|
||||
heroinlabkitprice = 10000
|
||||
}
|
||||
|
||||
ps.registerCallback('md-drugs:server:GetHeroinLocations', function(source)
|
||||
return heroinLocations
|
||||
end)
|
||||
|
||||
|
||||
ps.registerCallback('removeCleaningkit', function(source)
|
||||
for k, v in pairs(heroinLabKits) do
|
||||
if v.ownerid == ps.getIdentifier(source) then
|
||||
ps.removeItem(source, 'cleaningkit', 1)
|
||||
return true
|
||||
end
|
||||
Bridge.Callback.Register('md-drugs:server:removeCleaningKitHeroin', function(source)
|
||||
if heroinLabKits[source] then
|
||||
return Bridge.Inventory.RemoveItem(source, 'cleaningkit', 1)
|
||||
end
|
||||
return false
|
||||
end)
|
||||
|
||||
local function getTier(source)
|
||||
if not Config.TierSystem then
|
||||
return 'tier1'
|
||||
end
|
||||
local heroin = tonumber(getRep(source, 'heroin'))
|
||||
if heroin <= Config.Tier1 then
|
||||
return 'tier1'
|
||||
elseif heroin >= Config.Tier1 and heroin <= Config.Tier2 then
|
||||
return'tier2'
|
||||
else
|
||||
return 'tier3'
|
||||
end
|
||||
end
|
||||
|
||||
RegisterServerEvent('md-drugs:server:dryplant', function(num)
|
||||
local src = source
|
||||
|
||||
if timeOut(src, 'md-drugs:server:dryplant') then return end
|
||||
if not ps.checkDistance(src, heroinLocations.dryplant[num].loc, 3.0) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), 'error')
|
||||
|
||||
if not checkDistance(src, Locations.Heroin.dryplant[num].loc, 3.0) then
|
||||
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.notIn'), 'error')
|
||||
return
|
||||
end
|
||||
|
||||
local tier = 'tier1'
|
||||
if Config.TierSystem then
|
||||
local heroin = tonumber(getRep(src, 'heroin'))
|
||||
if heroin <= Config.Tier1 then
|
||||
tier = 'tier1'
|
||||
elseif heroin >= Config.Tier1 and heroin <= Config.Tier2 then
|
||||
tier = 'tier2'
|
||||
else
|
||||
tier = 'tier3'
|
||||
end
|
||||
end
|
||||
if not ps.craftItem(src, heroinRecipes['dryheroin'][tier]) then
|
||||
verifyHas(src, heroinRecipes['dryheroin'][tier].take)
|
||||
local tier = getTier(src)
|
||||
if not craft(src, Recipes.Heroin.dryheroin[tier]) then
|
||||
return
|
||||
end
|
||||
end)
|
||||
@@ -87,85 +88,92 @@ RegisterServerEvent('md-drugs:server:cutheroin', function(num)
|
||||
|
||||
if timeOut(src, 'md-drugs:server:cutheroin') then return end
|
||||
|
||||
if not ps.checkDistance(src, heroinLocations.cutheroinone[num].loc, 3.0) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), 'error')
|
||||
if not checkDistance(src, Locations.Heroin.cutheroinone[num].loc, 3.0) then
|
||||
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.notIn'), 'error')
|
||||
return
|
||||
end
|
||||
|
||||
local tier = 'tier1'
|
||||
if Config.TierSystem then
|
||||
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 ps.craftItem(src, heroinRecipes['cutheroin'][v]) then
|
||||
verifyHas(src, heroinRecipes['cutheroin'][v].take)
|
||||
return
|
||||
end
|
||||
AddRep(src, 'heroin')
|
||||
return
|
||||
for item, tiers in pairs (itemList) do
|
||||
if Bridge.Inventory.HasItem(src, item) then
|
||||
tier = tiers
|
||||
end
|
||||
end
|
||||
else
|
||||
if not ps.craftItem(src, heroinRecipes['cutheroin']['tier1']) then
|
||||
verifyHas(src, heroinRecipes['cutheroin']['tier1'].take)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if not craft(src, Recipes.Heroin.cutheroin[tier]) then
|
||||
return
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:getheroinlabkit', function(num)
|
||||
local src = source
|
||||
|
||||
if timeOut(src, 'md-drugs:server:getheroinlabkit') then return end
|
||||
if not ps.checkDistance(src, heroinLocations.buyKit[num].loc, 3.0) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), 'error')
|
||||
|
||||
if not checkDistance(src, Locations.Heroin.buyKit[num].loc, 3.0) then
|
||||
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.notIn'), 'error')
|
||||
return
|
||||
end
|
||||
local has = ps.hasItem(src, 'heroinlabkit')
|
||||
if has then ps.notify(src, ps.lang('heroin.hasKitAlready'), 'error') return end
|
||||
if ps.removeMoney(src, 'cash', prices.heroinlabkitprice) then
|
||||
ps.addItem(src, 'heroinlabkit', 1)
|
||||
|
||||
local has = Bridge.Inventory.HasItem(src, 'heroinlabkit')
|
||||
if has then
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('heroin.hasKitAlready'), 'error')
|
||||
return
|
||||
end
|
||||
if Bridge.Framework.RemoveAccountBalance(src, 'cash', prices.heroinlabkitprice) then
|
||||
Bridge.Inventory.AddItem(src, 'heroinlabkit', 1)
|
||||
else
|
||||
ps.notify(src, ps.lang('heroin.notEnoughMoney', prices.heroinlabkitprice), 'error')
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('heroin.notEnoughMoney', prices.heroinlabkitprice), 'error')
|
||||
end
|
||||
end)
|
||||
|
||||
local function hasHKit(src)
|
||||
for k, v in pairs(heroinLabKits) do
|
||||
if v.ownerid == ps.getIdentifier(src) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
RegisterServerEvent('md-drugs:server:getheroinlabkitback', function()
|
||||
local src = source
|
||||
if not hasHKit(src) then return end
|
||||
for k, v in pairs (heroinLabKits) do
|
||||
if v.ownerid == ps.getIdentifier(src) then
|
||||
table.remove(heroinLabKits, k)
|
||||
ps.addItem(src, 'heroinlabkit', 1)
|
||||
end
|
||||
|
||||
if not heroinLabKits[src] then
|
||||
return
|
||||
end
|
||||
|
||||
local loc = vector3(heroinLabKits[src].coords.x, heroinLabKits[src].coords.y, heroinLabKits[src].coords.z)
|
||||
if not checkDistance(src, loc, 5.0) then
|
||||
return
|
||||
end
|
||||
|
||||
heroinLabKits[src] = nil
|
||||
Bridge.Inventory.AddItem(src, 'heroinlabkit', 1)
|
||||
end)
|
||||
|
||||
|
||||
ps.createUseable('heroinlabkit', function(source, item)
|
||||
Bridge.Framework.RegisterUsableItem('heroinlabkit', function(source, item)
|
||||
local src = source
|
||||
if not ps.hasItem(src, 'heroinlabkit', 1) then return end
|
||||
local placed, loc = ps.callback('md-drugs:client:setheroinlabkit', src)
|
||||
|
||||
if not Bridge.Inventory.HasItem(src, 'heroinlabkit', 1) then
|
||||
return
|
||||
end
|
||||
|
||||
if heroinLabKits[src] then
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('heroin.hasKitAlreadyPlaced'), "error")
|
||||
return
|
||||
end
|
||||
|
||||
local placed, loc = Bridge.Callback.Trigger('md-drugs:client:setheroinlabkit', src)
|
||||
if placed then
|
||||
if ps.removeItem(src, 'heroinlabkit', 1) then
|
||||
table.insert(heroinLabKits, {
|
||||
if Bridge.Inventory.RemoveItem(src, 'heroinlabkit', 1) then
|
||||
heroinLabKits[src] = {
|
||||
src = src,
|
||||
ownerid = ps.getIdentifier(src),
|
||||
ownerid = Bridge.Framework.GetPlayerIdentifier(src),
|
||||
coords = loc,
|
||||
name = ps.getPlayerName(src)
|
||||
})
|
||||
ps.notify(src, ps.lang('heroin.placedKit'), "success")
|
||||
}
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('heroin.placedKit'), "success")
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -175,9 +183,13 @@ RegisterServerEvent('md-drugs:server:heatliquidheroin', function()
|
||||
|
||||
if timeOut(src, 'md-drugs:server:heatliquidheroin') then return end
|
||||
|
||||
if not hasHKit(src) then return end
|
||||
if not ps.hasItem(src, 'emptyvial', 1) then return end
|
||||
|
||||
if not heroinLabKits[src] then
|
||||
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.notIn'), 'error')
|
||||
return
|
||||
end
|
||||
|
||||
if not Bridge.Inventory.HasItem(src, 'emptyvial', 1) then return end
|
||||
local tier = 'tier1'
|
||||
if Config.TierSystem then
|
||||
local itemList = {
|
||||
heroincut = 'tier1',
|
||||
@@ -185,37 +197,34 @@ RegisterServerEvent('md-drugs:server:heatliquidheroin', function()
|
||||
heroincutstagethree = 'tier3'
|
||||
}
|
||||
for k, v in pairs(itemList) do
|
||||
local cuth = ps.hasItem(src, k)
|
||||
if cuth then
|
||||
if not ps.craftItem(src, heroinRecipes['fillvial'][v]) then
|
||||
verifyHas(src, heroinRecipes['fillvial'][v].take)
|
||||
return
|
||||
end
|
||||
AddRep(src, 'heroin')
|
||||
return
|
||||
if Bridge.Inventory.HasItem(src, k) then
|
||||
tier = v
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
if not ps.craftItem(src, heroinRecipes['fillvial']['tier1']) then
|
||||
verifyHas(src, heroinRecipes['fillvial']['tier1'].take)
|
||||
return
|
||||
end
|
||||
end
|
||||
if not craft(src, Recipes.Heroin.fillvial[tier]) then
|
||||
return
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:failheatingheroin', function()
|
||||
local src = source
|
||||
if not hasHKit(src) then return end
|
||||
|
||||
if not heroinLabKits[src] then
|
||||
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.notIn'), 'error')
|
||||
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, ps.lang('heroin.failed'), "error")
|
||||
if Bridge.Inventory.RemoveItem(src, k, v) then
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('heroin.failed'), "error")
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -224,33 +233,27 @@ end)
|
||||
RegisterServerEvent('md-drugs:server:fillneedle', function(num)
|
||||
local src = source
|
||||
if timeOut(src, 'md-drugs:server:fillneedle') then return end
|
||||
if not ps.checkDistance(src, heroinLocations.fillneedle[num].loc, 3.0) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), 'error')
|
||||
|
||||
if not checkDistance(src, Locations.Heroin.fillneedle[num].loc, 3.0) then
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notIn'), 'error')
|
||||
return
|
||||
end
|
||||
if not ps.hasItem(src, 'needle', 1) then return end
|
||||
local tier = 'tier1'
|
||||
if Config.TierSystem then
|
||||
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 ps.craftItem(src, heroinRecipes['fillneedle'][v.tier]) then
|
||||
verifyHas(src, heroinRecipes['fillneedle'][v.tier].take)
|
||||
return
|
||||
end
|
||||
AddRep(src, 'heroin')
|
||||
return
|
||||
heroinvial = 'tier1',
|
||||
heroinvialstagetwo = 'tier2',
|
||||
heroinvialstagethree = 'tier3'
|
||||
}
|
||||
for item, tiers in pairs (itemList) do
|
||||
if Bridge.Inventory.HasItem(src, item) then
|
||||
tier = tiers
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
if not ps.craftItem(src, heroinRecipes['fillneedle']['tier1']) then
|
||||
verifyHas(src, heroinRecipes['fillneedle']['tier1'].take)
|
||||
return
|
||||
end
|
||||
end
|
||||
if not craft(src, Recipes.Heroin.fillneedle[tier]) then
|
||||
return
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -263,25 +266,20 @@ RegisterServerEvent('md-drugs:server:failheroin', function()
|
||||
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, ps.lang('Heroin.failneedle'), "error")
|
||||
if Bridge.Inventory.RemoveItem(src, k, v) then
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Heroin.failneedle'), "error")
|
||||
return
|
||||
end
|
||||
end
|
||||
else
|
||||
ps.removeItem(src, 'heroinvial', 1)
|
||||
Bridge.Inventory.RemoveItem(src, 'heroinvial', 1)
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('playerDropped', function()
|
||||
local src = source
|
||||
for k, v in pairs(heroinLabKits) do
|
||||
if v.src == src then
|
||||
table.remove(heroinLabKits, k)
|
||||
ps.addItem(src, 'heroinlabkit', 1)
|
||||
end
|
||||
if heroinLabKits[src] then
|
||||
heroinLabKits[src] = nil
|
||||
Bridge.Inventory.AddItem(src, 'heroinlabkit', 1)
|
||||
end
|
||||
|
||||
end)
|
||||
+1
-1
@@ -37,7 +37,7 @@ end
|
||||
RegisterServerEvent('md-drugs:server:givelean', function()
|
||||
local src = source
|
||||
local amount = math.random(1,5)
|
||||
if not onRun[ps.getIdentifier(src)] then return ps.notify(src, ps.lang('lean.notOnRun'), "error") end
|
||||
if not onRun[ps.getIdentifier(src)] then return Bridge.Notify.SendNotify(src, Bridge.Language.Locale('lean.notOnRun'), "error") end
|
||||
onRun[ps.getIdentifier(src)] = onRun[ps.getIdentifier(src)] + 1
|
||||
if math.random(1,100) <= 50 then
|
||||
ps.addItem(src, "mdlean", amount)
|
||||
|
||||
+136
-107
@@ -1,215 +1,246 @@
|
||||
|
||||
Recipes, Locations = Recipes or {}, Locations or {}
|
||||
local prices = {
|
||||
tabcost = 100, -- price per piece of tab paper event does 10 at a time
|
||||
lsdlabkitcost = 10000 -- price of the lsd lab kit
|
||||
}
|
||||
local lsdRecipes = {
|
||||
Recipes.LSD = {
|
||||
vial = {
|
||||
heat = {take = {lysergic_acid = 1, diethylamide = 1,}, give = {lsd_one_vial = 1}}
|
||||
},
|
||||
}
|
||||
|
||||
local lsdLocations = {
|
||||
GlobalState.MDDrugsRecipes = Recipes
|
||||
Locations.LSD = {
|
||||
lysergicacid = { -- get lysergic acid
|
||||
{loc = vector3(-1381.21, -327.75, 39.85), l = 1.0, w = 1.0, rot = 45.0, gang = ""},
|
||||
{loc = vector3(2405.53, 5008.39, 46.02), l = 1.0, w = 1.0, rot = 45.0, gang = ""},
|
||||
},
|
||||
diethylamide = { -- get diethylamide
|
||||
{loc = vector3(-1371.71, -316.02, 39.53), l = 1.0, w = 1.0, rot = 45.0, gang = ""},
|
||||
{loc = vector3(-1372.89, -319.47, 39.05), l = 1.0, w = 1.0, rot = 45.0, gang = ""},
|
||||
{loc = vector3(2408.38, 5011.18, 46.08), l = 1.0, w = 1.0, rot = 45.0, gang = ""},
|
||||
},
|
||||
gettabs = { -- buy tab paper
|
||||
{loc = vector3(-1370.77, -314.51, 39.58), l = 1.0, w = 1.0, rot = 45.0, gang = ""},
|
||||
{loc = vector3(-1378.26, -336.56, 39.31), l = 1.0, w = 1.0, rot = 45.0, gang = ""},
|
||||
{loc = vector3(2409.59, 5012.45, 46.09), l = 1.0, w = 1.0, rot = 45.0, gang = ""},
|
||||
},
|
||||
buyLSDkit = {
|
||||
{ped = 'g_f_y_families_01', loc = vector4(2598.47, 5033.06, 105.86, 283.51), l = 1.0, w = 1.0, rot = 283.51, gang = ""},
|
||||
{ped = 'g_f_y_families_01', loc = vector4(-1376.66, -325.52, 39.63, 142.1), l = 1.0, w = 1.0, rot = 283.51, gang = ""},
|
||||
},
|
||||
}
|
||||
|
||||
ps.registerCallback('md-drugs:server:GetLSDLocations', function(source)
|
||||
return lsdLocations
|
||||
end)
|
||||
GlobalState.MDDrugsLocations = Locations
|
||||
|
||||
local lsdTables = {}
|
||||
|
||||
RegisterServerEvent('md-drugs:server:getlysergic', function(num)
|
||||
local src = source
|
||||
|
||||
if timeOut(src, 'md-drugs:server:getlysergic') then return end
|
||||
if not ps.checkDistance(src, lsdLocations.lysergicacid[num].loc, 2.0) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), "error")
|
||||
|
||||
if not checkDistance(src, Locations.LSD.lysergicacid[num].loc, 2.0) then
|
||||
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return
|
||||
end
|
||||
ps.addItem(src, 'lysergic_acid', 2)
|
||||
Bridge.Inventory.AddItem(src, 'lysergic_acid', 2)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:getdiethylamide', function(num)
|
||||
local src = source
|
||||
if timeOut(src, 'md-drugs:server:getdiethylamide') then return end
|
||||
if not ps.checkDistance(src, lsdLocations.diethylamide[num].loc, 2.0) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), "error")
|
||||
if not checkDistance(src, Locations.LSD.diethylamide[num].loc, 2.0) then
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return
|
||||
end
|
||||
ps.addItem(src, 'diethylamide', 2)
|
||||
Bridge.Inventory.AddItem(src, 'diethylamide', 2)
|
||||
end)
|
||||
|
||||
|
||||
ps.createUseable('lsdlabkit', function(source, item)
|
||||
Bridge.Framework.RegisterUsableItem('lsdlabkit', function(source, item)
|
||||
local src = source
|
||||
local placed, loc = ps.callback('md-drugs:client:setlsdlabkit', src)
|
||||
local placed, loc = Bridge.Callback.Trigger('md-drugs:client:setlsdlabkit', src)
|
||||
if placed then
|
||||
if ps.removeItem(src, 'lsdlabkit', 1) then
|
||||
table.insert(lsdTables, {
|
||||
owner = ps.getPlayerName(src),
|
||||
ownerid = ps.getIdentifier(src),
|
||||
if Bridge.Inventory.RemoveItem(src, 'lsdlabkit', 1) then
|
||||
lsdTables[src] = {
|
||||
src = src,
|
||||
loc = loc
|
||||
})
|
||||
}
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
local function hasLabKit(source)
|
||||
local src = source
|
||||
for k, v in pairs (lsdTables) do
|
||||
if v.ownerid == ps.getIdentifier(src) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ps.registerCallback('md-drugs:server:removecleaningkit', function(source)
|
||||
Bridge.Callback.Register('md-drugs:server:removecleaningkit', function(source)
|
||||
local src = source
|
||||
return ps.removeItem(src, "cleaningkit", 1)
|
||||
if not lsdTables[src] then return false end
|
||||
if not checkDistance(src, lsdTables[src].loc, 3.0) then
|
||||
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return false
|
||||
end
|
||||
return Bridge.Inventory.RemoveItem(src, "cleaningkit", 1)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:getlabkitback', function()
|
||||
local src = source
|
||||
for k, v in pairs (lsdTables) do
|
||||
if v.ownerid == ps.getIdentifier(src) then
|
||||
table.remove(lsdTables, k)
|
||||
ps.addItem(src, 'lsdlabkit', 1)
|
||||
end
|
||||
if timeOut(src, 'md-drugs:server:getlabkitback') then return end
|
||||
if lsdTables[src] then
|
||||
lsdTables[src] = nil
|
||||
Bridge.Inventory.AddItem(src, 'lsdlabkit', 1)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:heatliquid', function()
|
||||
local src = source
|
||||
if not hasLabKit(src) then return end
|
||||
if not lsdTables[src] then return end
|
||||
|
||||
if timeOut(src, 'md-drugs:server:heatliquid') then return end
|
||||
if not ps.craftItem(src, lsdRecipes['vial']['heat']) then
|
||||
verifyHas(src, lsdRecipes['vial']['heat'].take)
|
||||
if not checkDistance(src, lsdTables[src].loc, 3.0) then
|
||||
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return
|
||||
end
|
||||
if not craft(src, Recipes.LSD['vial']['heat']) then
|
||||
return
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:failheating', function()
|
||||
local src = source
|
||||
if not hasLabKit(src) then return end
|
||||
ps.removeItem(src, 'lysergic_acid', 1)
|
||||
ps.removeItem(src, 'diethylamide', 1)
|
||||
ps.notify(src, ps.lang('lsd.failed'), "error")
|
||||
if not lsdTables[src] then return end
|
||||
|
||||
if not checkDistance(src, lsdTables[src].loc, 3.0) then
|
||||
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return
|
||||
end
|
||||
|
||||
Bridge.Inventory.RemoveItem(src, 'lysergic_acid', 1)
|
||||
Bridge.Inventory.RemoveItem(src, 'diethylamide', 1)
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('lsd.failed'), "error")
|
||||
end)
|
||||
|
||||
|
||||
RegisterServerEvent('md-drugs:server:refinequalityacid', function()
|
||||
local src = source
|
||||
if not hasLabKit(src) then return end
|
||||
if timeOut(src, 'md-drugs:server:refinequalityacid') then return end
|
||||
if not ps.hasItem(src, 'lsd_one_vial', 1) then return end
|
||||
|
||||
if not lsdTables[src] then
|
||||
return
|
||||
end
|
||||
if not checkDistance(src, lsdTables[src].loc, 3.0) then
|
||||
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return
|
||||
end
|
||||
|
||||
if timeOut(src, 'md-drugs:server:refinequalityacid') then
|
||||
return
|
||||
end
|
||||
local removed = Bridge.Inventory.RemoveItem(src, 'lsd_one_vial', 1)
|
||||
if not removed then
|
||||
return
|
||||
end
|
||||
if Config.TierSystem then
|
||||
local lsd = tonumber(getRep(src, 'lsd'))
|
||||
if ps.removeItem(src, 'lsd_one_vial', 1) then
|
||||
if lsd <= 30 then
|
||||
ps.addItem(src,'lsd_vial_two', 1)
|
||||
elseif lsd >= 31 and lsd <= 60 then
|
||||
ps.addItem(src,'lsd_vial_three', 1)
|
||||
elseif lsd >= 61 and lsd <= 90 then
|
||||
ps.addItem(src,'lsd_vial_four', 1)
|
||||
elseif lsd >= 91 and lsd <= 120 then
|
||||
ps.addItem(src,'lsd_vial_five', 1)
|
||||
else
|
||||
ps.addItem(src,'lsd_vial_six', 1)
|
||||
end
|
||||
AddRep(src,'lsd')
|
||||
if lsd <= 30 then
|
||||
Bridge.Inventory.AddItem(src,'lsd_vial_two', 1)
|
||||
elseif lsd >= 31 and lsd <= 60 then
|
||||
Bridge.Inventory.AddItem(src,'lsd_vial_three', 1)
|
||||
elseif lsd >= 61 and lsd <= 90 then
|
||||
Bridge.Inventory.AddItem(src,'lsd_vial_four', 1)
|
||||
elseif lsd >= 91 and lsd <= 120 then
|
||||
Bridge.Inventory.AddItem(src,'lsd_vial_five', 1)
|
||||
else
|
||||
Bridge.Inventory.AddItem(src,'lsd_vial_six', 1)
|
||||
end
|
||||
AddRep(src,'lsd')
|
||||
else
|
||||
local randomchance = math.random(1,100)
|
||||
if ps.removeItem(src,'lsd_one_vial', 1) then
|
||||
if randomchance <= 60 then
|
||||
ps.addItem(src,'lsd_vial_two', 1)
|
||||
elseif randomchance >= 61 and randomchance <= 75 then
|
||||
ps.addItem(src,'lsd_vial_three', 1)
|
||||
elseif randomchance >= 76 and randomchance <= 85 then
|
||||
ps.addItem(src,'lsd_vial_four', 1)
|
||||
elseif randomchance >= 86 and randomchance <= 93 then
|
||||
ps.addItem(src,'lsd_vial_five', 1)
|
||||
else
|
||||
ps.addItem(src,'lsd_vial_six', 1)
|
||||
end
|
||||
if randomchance <= 60 then
|
||||
Bridge.Inventory.AddItem(src,'lsd_vial_two', 1)
|
||||
elseif randomchance >= 61 and randomchance <= 75 then
|
||||
Bridge.Inventory.AddItem(src,'lsd_vial_three', 1)
|
||||
elseif randomchance >= 76 and randomchance <= 85 then
|
||||
Bridge.Inventory.AddItem(src,'lsd_vial_four', 1)
|
||||
elseif randomchance >= 86 and randomchance <= 93 then
|
||||
Bridge.Inventory.AddItem(src,'lsd_vial_five', 1)
|
||||
else
|
||||
Bridge.Inventory.AddItem(src,'lsd_vial_six', 1)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:failrefinequality', function()
|
||||
local src = source
|
||||
if not hasLabKit(src) then return end
|
||||
ps.removeItem(src,'lsd_one_vial', 1)
|
||||
|
||||
if not lsdTables[src] then return end
|
||||
|
||||
if not checkDistance(src, lsdTables[src].loc, 3.0) then
|
||||
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return
|
||||
end
|
||||
|
||||
Bridge.Inventory.RemoveItem(src,'lsd_one_vial', 1)
|
||||
end)
|
||||
|
||||
|
||||
RegisterServerEvent('md-drugs:server:gettabpaper', function(num)
|
||||
local src = source
|
||||
|
||||
if timeOut(src, 'md-drugs:server:gettabpaper') then return end
|
||||
if not ps.checkDistance(src, lsdLocations.gettabs[num].loc, 3.0) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), "error")
|
||||
|
||||
if not checkDistance(src, Locations.LSD.gettabs[num].loc, 3.0) then
|
||||
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return
|
||||
end
|
||||
if ps.removeMoney(src, 'cash', prices.tabcost * 10) then
|
||||
ps.addItem(src,'tab_paper', 10)
|
||||
|
||||
if Bridge.Framework.RemoveAccountBalance(src, 'cash', prices.tabcost * 10) then
|
||||
Bridge.Inventory.AddItem(src,'tab_paper', 10)
|
||||
else
|
||||
ps.notify(src, ps.lang('Catches.notEnoughMoney'), "error")
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notEnoughMoney'), "error")
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:getlabkit', function(num)
|
||||
local src = source
|
||||
if timeOut(src, 'md-drugs:server:getlabkit') then return end
|
||||
if ps.hasItem(src,'lsdlabkit', 1) then
|
||||
|
||||
if Bridge.Inventory.HasItem(src,'lsdlabkit', 1) then
|
||||
return
|
||||
end
|
||||
if not ps.checkDistance(src, lsdLocations.buyLSDkit[num].loc, 3.0) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), "error")
|
||||
|
||||
if not checkDistance(src, Locations.LSD.buyLSDkit[num].loc, 3.0) then
|
||||
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return
|
||||
end
|
||||
if ps.removeMoney(src, 'cash', prices.lsdlabkitcost) then
|
||||
ps.addItem(src,'lsdlabkit', 1)
|
||||
if Bridge.Framework.RemoveAccountBalance(src, 'cash', prices.lsdlabkitcost) then
|
||||
Bridge.Inventory.AddItem(src,'lsdlabkit', 1)
|
||||
else
|
||||
ps.notify(src, ps.lang('Catches.notEnoughMoney'), "error")
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notEnoughMoney'), "error")
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:maketabpaper', function()
|
||||
local src = source
|
||||
if timeOut(src, 'md-drugs:server:maketabpaper') then return end
|
||||
if not hasLabKit(src) then return end
|
||||
if not ps.hasItem(src,'tab_paper', 1) then return end
|
||||
if not lsdTables[src] then return end
|
||||
if not checkDistance(src, lsdTables[src].loc, 3.0) then
|
||||
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return
|
||||
end
|
||||
|
||||
local vialdata = {
|
||||
{vial = 'lsd_one_vial', sheet = 'smileyfacesheet', log = 'Made A Smiley Face Sheet'},
|
||||
{vial = 'lsd_vial_two', sheet = 'wildcherrysheet', log = 'Made A Wild Cherry Sheet'},
|
||||
{vial = 'lsd_vial_three', sheet = 'yinyangsheet', log = 'Made A Yin Yang Sheet'},
|
||||
{vial = 'lsd_vial_four', sheet = 'pineapplesheet', log = 'Made A Pine Apple Sheet'},
|
||||
{vial = 'lsd_vial_five', sheet = 'bartsheet', log = 'Made A Cluckin Bell Sheet'},
|
||||
{vial = 'lsd_vial_six', sheet = 'gratefuldeadsheet', log = 'Made A Maze Sheet'}
|
||||
{vial = 'lsd_one_vial', give = {smileyfacesheet = 1}, take = {lsd_one_vial = 1, tab_paper = 1}},
|
||||
{vial = 'lsd_vial_two', give = {wildcherrysheet = 1}, take = {lsd_vial_two = 1, tab_paper = 1}},
|
||||
{vial = 'lsd_vial_three', give = {yinyangsheet = 1}, take = {lsd_vial_three = 1, tab_paper = 1}},
|
||||
{vial = 'lsd_vial_four', give = {pineapplesheet = 1}, take = {lsd_vial_four = 1, tab_paper = 1}},
|
||||
{vial = 'lsd_vial_five', give = {bartsheet = 1}, take = {lsd_vial_five = 1, tab_paper = 1}},
|
||||
{vial = 'lsd_vial_six', give = {gratefuldeadsheet = 1}, take = {lsd_vial_six = 1, tab_paper = 1}}
|
||||
}
|
||||
local vial = 1
|
||||
for k, v in ipairs (vialdata) do
|
||||
local check = ps.hasItem(src, v.vial) and ps.hasItem(src, 'tab_paper')
|
||||
local check = Bridge.Inventory.HasItem(src, v.vial)
|
||||
if check then
|
||||
if ps.removeItem(src, v.vial, 1) and ps.removeItem(src, 'tab_paper', 1) then
|
||||
ps.addItem(src, v.sheet, 1)
|
||||
end
|
||||
vial = k
|
||||
break
|
||||
end
|
||||
end
|
||||
if not craft(src, vialdata[vial]) then
|
||||
return
|
||||
end
|
||||
end)
|
||||
|
||||
local sheets = {
|
||||
@@ -222,21 +253,19 @@ local sheets = {
|
||||
}
|
||||
|
||||
for k, v in pairs (sheets) do
|
||||
ps.createUseable(v.item, function(source)
|
||||
Bridge.Framework.RegisterUsableItem(v.item, function(source)
|
||||
local src = source
|
||||
local math = math.random(1,10)
|
||||
if ps.removeItem(src, v.item, 1) then
|
||||
ps.addItem(src, v.recieve, math)
|
||||
if Bridge.Inventory.RemoveItem(src, v.item, 1) then
|
||||
Bridge.Inventory.AddItem(src, v.recieve, math)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
AddEventHandler('playerDropped', function()
|
||||
local src = source
|
||||
for k, v in pairs (lsdTables) do
|
||||
if v.ownerid == ps.getPlayerCitizenId(src) then
|
||||
table.remove(lsdTables, k)
|
||||
ps.addItem(src, 'lsdlabkit', 1)
|
||||
end
|
||||
if lsdTables[src] then
|
||||
lsdTables[src] = nil
|
||||
Bridge.Inventory.AddItem(src, 'lsdlabkit', 1)
|
||||
end
|
||||
end)
|
||||
+13
-11
@@ -1,36 +1,38 @@
|
||||
local mescalineLocation = {
|
||||
Recipes, locations = Recipes or {}, locations or {}
|
||||
|
||||
Locations.Mescaline = {
|
||||
DryOutMescaline = { -- where to dry out your mescaline
|
||||
{loc = vector3(1850.12, 2595.23, 45.67), l = 1.0, w = 1.0, rot = 0.0, gang = ""},
|
||||
},
|
||||
}
|
||||
local mescalineRecipes = {
|
||||
GlobalState.MDDrugsLocations = Locations
|
||||
Recipes.Mescaline = {
|
||||
mescaline = {
|
||||
dry = {
|
||||
dried = {take = {cactusbulb = 1}, give = {driedmescaline = 1} }
|
||||
}
|
||||
},
|
||||
}
|
||||
GlobalState.MDDrugsRecipes = Recipes
|
||||
|
||||
ps.registerCallback('md-drugs:server:GetMescalineLocs', function(source)
|
||||
return mescalineLocation
|
||||
end)
|
||||
|
||||
RegisterNetEvent("md-drugs:server:drymescaline", function(num)
|
||||
local src = source
|
||||
if timeOut(src, 'md-drugs:server:drymescaline') then return end
|
||||
if not ps.checkDistance(src, mescalineLocation.DryOutMescaline[num].loc, 3.0) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), "error")
|
||||
|
||||
if not checkDistance(src, Locations.Mescaline.DryOutMescaline[num].loc, 3.0) then
|
||||
Bridge.Prints.Warn(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return
|
||||
end
|
||||
if not ps.craftItem(src, mescalineRecipes.mescaline.dry.dried) then
|
||||
verifyHas(src, mescalineRecipes.mescaline.dry.dried.take)
|
||||
|
||||
if not craft(src, Recipes.Mescaline.mescaline.dry.dried) then
|
||||
return
|
||||
end
|
||||
end)
|
||||
|
||||
ps.createUseable("driedmescaline", function(source, item)
|
||||
Bridge.Framework.RegisterUsableItem("driedmescaline", function(source, item)
|
||||
local src = source
|
||||
if ps.removeItem(src, "driedmescaline", 1) then
|
||||
if Bridge.Inventory.RemoveItem(src, "driedmescaline", 1) then
|
||||
TriggerClientEvent("md-drugs:client:takemescaline", src)
|
||||
end
|
||||
end)
|
||||
+66
-59
@@ -1,8 +1,7 @@
|
||||
|
||||
Recipes, Locations = Recipes or {}, Locations or {}
|
||||
local onRun = {}
|
||||
local cool = {}
|
||||
|
||||
local methLocs = {
|
||||
local vehicles = {}
|
||||
Locations.Meth = {
|
||||
CookMeth = {
|
||||
{loc = vector3(1006.09, -3200.59, -38.52), l = 1.0, w = 1.0, rot = 45.0, offset = vec3(4.79, 2.13, -0.41), rotation = vector3(0,0,0.0), gang = ""},
|
||||
},
|
||||
@@ -33,113 +32,121 @@ local methLocs = {
|
||||
{inside = vector3(996.91, -3200.83, -36.39), outside = vector3(-2222.04, 303.99, 174.6), l = 1.0, w = 1.0, rot = 45.0, gang = ""},
|
||||
}
|
||||
}
|
||||
GlobalState.MDDrugsLocations = Locations
|
||||
|
||||
local methRecipes = {
|
||||
Recipes.Meth = {
|
||||
cook = {
|
||||
heat = {take = {ephedrine = 1, acetone = 1}, give = {}} --Missing item
|
||||
heat = {take = {ephedrine = 1, acetone = 1}, give = {}}
|
||||
},
|
||||
bag = {
|
||||
bags = {take = {empty_weed_bag = 5}, give = {methbags = 5} }
|
||||
}
|
||||
}
|
||||
GlobalState.MDDrugsRecipes = Recipes
|
||||
|
||||
ps.registerCallback('md-drugs:server:GetMethLocs', function(source)
|
||||
return methLocs
|
||||
end)
|
||||
|
||||
local function setTimeout(identifier)
|
||||
if onRun[identifier] then
|
||||
local function setTimeout(src)
|
||||
if onRun[src] then
|
||||
CreateThread(function()
|
||||
Wait(10 * 60 * 1000)
|
||||
onRun[identifier] = nil
|
||||
onRun[src] = nil
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
local function coolDown(identifier)
|
||||
if cool[identifier] then
|
||||
return false
|
||||
else
|
||||
cool[identifier] = true
|
||||
CreateThread(function()
|
||||
Wait(3500)
|
||||
cool[identifier] = nil
|
||||
end)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
RegisterServerEvent('md-drugs:server:givemethingridients', function()
|
||||
RegisterServerEvent('md-drugs:server:givemethingridients', function(veh)
|
||||
local src = source
|
||||
local amount = math.random(1,5)
|
||||
if not onRun[ps.getIdentifier(src)] then return ps.notify(src, ps.lang('meth.notOnRun'), "error") end
|
||||
onRun[ps.getIdentifier(src)] = onRun[ps.getIdentifier(src)] + 1
|
||||
if math.random(1,100) <= 50 then
|
||||
ps.addItem(src, "ephedrine", amount)
|
||||
else
|
||||
ps.addItem(src, "acetone", amount)
|
||||
|
||||
local vehicle = NetworkGetEntityFromNetworkId(veh)
|
||||
if vehicles[src] ~= vehicle then
|
||||
return Bridge.Notify.SendNotify(src, Bridge.Language.Locale('meth.noVehicle'), "error")
|
||||
end
|
||||
if onRun[ps.getIdentifier(src)] >= 4 then
|
||||
onRun[ps.getIdentifier(src)] = nil
|
||||
|
||||
if not DoesEntityExist(vehicle) and GetEntityModel(vehicle) == GetHashKey('journey') then
|
||||
return Bridge.Notify.SendNotify(src, Bridge.Language.Locale('meth.noVehicle'), "error")
|
||||
end
|
||||
|
||||
if timeOut(src, 'md-drugs:server:givemethingridients') then return end
|
||||
|
||||
if not onRun[src] then
|
||||
return Bridge.Notify.SendNotify(src, Bridge.Language.Locale('meth.notOnRun'), "error")
|
||||
end
|
||||
onRun[src] = onRun[src] + 1
|
||||
|
||||
local chance = math.random(1,2) == 1 and 'ephedrine' or 'acetone'
|
||||
if onRun[src] == 5 then
|
||||
DeleteEntity(vehicle)
|
||||
onRun[src] = nil
|
||||
vehicles[src] = nil
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('meth.finishedRun'), "success")
|
||||
end
|
||||
Bridge.Inventory.AddItem(src, chance, amount)
|
||||
end)
|
||||
|
||||
|
||||
RegisterServerEvent('md-drugs:server:getmeth', function(num)
|
||||
local src = source
|
||||
if timeOut(src, 'md-drugs:server:getmeth') then return end
|
||||
if not ps.checkDistance(src, methLocs.BagMeth[num].loc, 2.5) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), "error")
|
||||
|
||||
if not checkDistance(src, Locations.Meth.BagMeth[num].loc, 2.5) then
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return
|
||||
end
|
||||
if not ps.craftItem(src, methRecipes.bag.bags) then
|
||||
verifyHas(src, methRecipes.bag.bags.take)
|
||||
|
||||
if not craft(src, Recipes.Meth.bag.bags) then
|
||||
return
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:geteph', function(num)
|
||||
local src = source
|
||||
if not ps.checkDistance(src, methLocs.MethEph[num].loc, 2.5) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), "error")
|
||||
if timeOut(src, 'md-drugs:server:geteph') then return end
|
||||
if not checkDistance(src, Locations.Meth.MethEph[num].loc, 2.5) then
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return
|
||||
end
|
||||
if timeOut(src, 'md-drugs:server:geteph') then return end
|
||||
ps.addItem(src, 'ephedrine', 1)
|
||||
Bridge.Inventory.AddItem(src, 'ephedrine', 1)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:getace', function(num)
|
||||
local src = source
|
||||
if not ps.checkDistance(src, methLocs.MethAce[num].loc, 2.5) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), "error")
|
||||
if timeOut(src, 'md-drugs:server:getace') then return end
|
||||
if not checkDistance(src, Locations.Meth.MethAce[num].loc, 2.5) then
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return
|
||||
end
|
||||
if timeOut(src, 'md-drugs:server:getace') then return end
|
||||
ps.addItem(src, 'acetone', 1)
|
||||
Bridge.Inventory.AddItem(src, 'acetone', 1)
|
||||
end)
|
||||
|
||||
ps.registerCallback('md-drugs:server:startcook', function(source, num)
|
||||
Bridge.Callback.Register('md-drugs:server:startcook', function(source, num)
|
||||
local src = source
|
||||
if not ps.checkDistance(src, methLocs.CookMeth[num].loc, 2.5) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), "error")
|
||||
if not checkDistance(src, Locations.Meth.CookMeth[num].loc, 2.5) then
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return false
|
||||
end
|
||||
local recipe = ps.craftItem(src, methRecipes.cook.heat)
|
||||
if not recipe then
|
||||
verifyHas(src, methRecipes.cook.heat.take)
|
||||
if not craft(src, Recipes.Meth.cook.heat) then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end)
|
||||
|
||||
ps.registerCallback('md-drugs:server:registerMeth', function(source)
|
||||
local identifier = ps.getIdentifier(source)
|
||||
if not identifier then return false end
|
||||
if onRun[identifier] then
|
||||
Bridge.Callback.Register('md-drugs:server:registerMeth', function(source, loc, vehNetId)
|
||||
local src = source
|
||||
if onRun[source] then
|
||||
return false
|
||||
else
|
||||
onRun[identifier] = 0
|
||||
setTimeout(identifier)
|
||||
if checkDistance(src, Locations.Meth.MethHeist[loc].loc, 10.0) then
|
||||
local vehicle = NetworkGetEntityFromNetworkId(vehNetId)
|
||||
if DoesEntityExist(vehicle) and GetEntityModel(vehicle) == GetHashKey('journey') then
|
||||
vehicles[src] = vehicle
|
||||
else
|
||||
return false
|
||||
end
|
||||
else
|
||||
return false
|
||||
end
|
||||
onRun[source] = 0
|
||||
setTimeout(source)
|
||||
return true
|
||||
end
|
||||
end)
|
||||
|
||||
+4
-4
@@ -33,10 +33,10 @@ ps.registerCallback('md-drugs:server:payfortruck', function(source)
|
||||
local src = source
|
||||
if ps.removeMoney(src, 'cash', prices.payfortruck) or ps.removeMoney(src, 'bank', prices.payfortruck) then
|
||||
onRoute[src] = true
|
||||
ps.notify(src, ps.lang('oxy.paid', prices.payfortruck), "success")
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('oxy.paid', prices.payfortruck), "success")
|
||||
return true
|
||||
else
|
||||
ps.notify(src, ps.lang('Catches.notEnoughMoney'), "error")
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notEnoughMoney'), "error")
|
||||
return false
|
||||
end
|
||||
end)
|
||||
@@ -46,12 +46,12 @@ RegisterServerEvent('md-drugs:server:giveoxybox', function()
|
||||
local src = source
|
||||
if timeOut(src, 'md-drugs:server:giveoxybox') then return end
|
||||
if not onRoute[src] then
|
||||
ps.notify(src, ps.lang('oxy.notOn'), "error")
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('oxy.notOn'), "error")
|
||||
return
|
||||
end
|
||||
|
||||
if not ps.checkDistance(src, oxyLocs.oxylocations[onRoute[src]], 3.5) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), "error")
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
+3
-3
@@ -25,7 +25,7 @@ ps.createUseable('prescription_pad', function(source, item)
|
||||
{label = ps.getItemLabel('xanax_prescription'), value = 'xanax_prescription'}
|
||||
}
|
||||
local data = ps.callback('md-drugs:client:prescriptionpad', src, near, options)
|
||||
if not data then return ps.notify(src, ps.lang('pharma.canceled'), "error") end
|
||||
if not data then return Bridge.Notify.SendNotify(src, Bridge.Language.Locale('pharma.canceled'), "error") end
|
||||
ps.addItem(ps.getSource(data.who), data.what, 1)
|
||||
end
|
||||
end)
|
||||
@@ -46,7 +46,7 @@ for m, d in pairs (pharmabottle) do
|
||||
if d == k then
|
||||
if ps.removeItem(src, d, 1) then
|
||||
ps.addItem(src, v, math.random(10,30))
|
||||
ps.notify(src,ps.lang('pharma.unbottle'), "success")
|
||||
Bridge.Notify.SendNotify(src,Bridge.Language.Locale('pharma.unbottle'), "success")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -58,7 +58,7 @@ RegisterServerEvent('md-drugs:server:fillprescription', function(num)
|
||||
local src = source
|
||||
if timeOut(src, 'md-drugs:server:fillprescription') then return end
|
||||
if not ps.checkDistance(src, pharmaLocations.FillPrescription[num].loc, 3.5) then
|
||||
return ps.notify(src, ps.lang('Catches.notIn'), "error")
|
||||
return Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
end
|
||||
local pres = {
|
||||
vicodin_prescription = 'vicodinbottle',
|
||||
|
||||
@@ -228,7 +228,7 @@ for k, v in pairs (plantData) do
|
||||
v.itemGive(src)
|
||||
end
|
||||
else
|
||||
ps.notify(src, ps.lang('Catches.notIn'), 'error')
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notIn'), 'error')
|
||||
return
|
||||
end
|
||||
end)
|
||||
|
||||
+2
-2
@@ -2,10 +2,10 @@
|
||||
ps.createUseable('shrooms', function(source, item)
|
||||
local src = source
|
||||
if not ps.callback("md-drugs:client:shrooms", src) then
|
||||
ps.notify(src, ps.lang('shrooms.cancel'), "error")
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('shrooms.cancel'), "error")
|
||||
return
|
||||
end
|
||||
ps.removeItem(src, 'shrooms', 1)
|
||||
ps.notify(src, ps.lang('shrooms.took'), 'success')
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('shrooms.took'), 'success')
|
||||
end)
|
||||
|
||||
+7
-7
@@ -59,17 +59,17 @@ end)
|
||||
RegisterNetEvent('md-drugs:server:buyWeedItem', function(loc, name, amount)
|
||||
local src = source
|
||||
if not ps.checkDistance(src, weedLocs.WeedSalesman[loc].loc, 3.5) then
|
||||
ps.notify(src, ps.lang('Checks.notIn'), "error")
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Checks.notIn'), "error")
|
||||
return
|
||||
end
|
||||
if not weedStore[name] then
|
||||
ps.notify(src, ps.lang('weed.itemDoesntExist'), "error")
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('weed.itemDoesntExist'), "error")
|
||||
return
|
||||
end
|
||||
if ps.removeMoney(src, 'cash', weedStore[name] * amount) or ps.removeMoney(src, 'bank', weedStore[name] * amount) then
|
||||
ps.addItem(src, name, amount)
|
||||
else
|
||||
ps.notify(src, ps.lang('Catches.notEnoughMoney'), "error")
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notEnoughMoney'), "error")
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -79,7 +79,7 @@ RegisterServerEvent('md-drugs:server:dryoutweed', function()
|
||||
if ps.removeItem(src,"wetcannabis", 1) then
|
||||
ps.addItem(src,"drycannabis", 1)
|
||||
else
|
||||
ps.notify(src, ps.lang('weed.noDry'), "error")
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('weed.noDry'), "error")
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -112,13 +112,13 @@ ps.createUseable("dabrig", function(source, item)
|
||||
TriggerClientEvent("md-drugs:client:dodabs", src)
|
||||
end
|
||||
else
|
||||
ps.notify(src, ps.lang('weed.needItem', ps.getItemLabel("butanetorch")), 'error')
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('weed.needItem', ps.getItemLabel("butanetorch")), 'error')
|
||||
end
|
||||
end)
|
||||
|
||||
ps.createUseable("weedgrinder", function(source, item)
|
||||
local src = source
|
||||
if not ps.hasItem(src, "drycannabis") then ps.notify(src, ps.lang('weed.needItem', ps.getItemLabel("drycannabis")), 'error') return end
|
||||
if not ps.hasItem(src, "drycannabis") then Bridge.Notify.SendNotify(src, Bridge.Language.Locale('weed.needItem', ps.getItemLabel("drycannabis")), 'error') return end
|
||||
local check = ps.callback('md-drugs:client:uncuff', src, 'Grinding Weed')
|
||||
if not check then return end
|
||||
if ps.removeItem(src, "drycannabis",1 ) then
|
||||
@@ -128,7 +128,7 @@ end)
|
||||
|
||||
ps.createUseable("mdwoods", function(source, item)
|
||||
local src = source
|
||||
local check = ps.callback('md-drugs:client:uncuff', src, ps.lang('weed.crackBlunt'))
|
||||
local check = ps.callback('md-drugs:client:uncuff', src, Bridge.Language.Locale('weed.crackBlunt'))
|
||||
if not check then return end
|
||||
if ps.removeItem(src, "mdwoods",1 ) then
|
||||
ps.addItem(src, "bluntwrap", 5)
|
||||
|
||||
+3
-3
@@ -38,7 +38,7 @@ RegisterServerEvent('md-drugs:server:buyWhippitItem', function(loc, item,amount)
|
||||
if not itemShop[item] then return end
|
||||
local price = itemShop[item] * amount
|
||||
if not ps.removeMoney(src, 'cash', price, 'whippit-shop') then
|
||||
return ps.notify(src, ps.lang('Whippit.notEnoughMoney', price), 'error')
|
||||
return Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Whippit.notEnoughMoney', price), 'error')
|
||||
end
|
||||
ps.addItem(src, item, amount)
|
||||
end)
|
||||
@@ -56,11 +56,11 @@ ps.createUseable('cracker', function(source)
|
||||
end
|
||||
end
|
||||
if not balloonItem then
|
||||
return ps.notify(src, ps.lang('Whippit.needBalloon'), 'error')
|
||||
return Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Whippit.needBalloon'), 'error')
|
||||
end
|
||||
|
||||
if not ps.removeItem(src, 'whipped_cream_cannister', 1) then
|
||||
return ps.notify(src, ps.lang('Whippit.needCanister'), 'error')
|
||||
return Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Whippit.needCanister'), 'error')
|
||||
end
|
||||
if not ps.removeItem(src, balloonItem, 1) then
|
||||
return ps.warn(src, 'Failed to remove balloon', 'error')
|
||||
|
||||
@@ -108,7 +108,7 @@ for k, v in pairs (burners) do
|
||||
TriggerClientEvent("md-drugs:client:GetLocation", active[ps.getIdentifier(source)].src, active[ps.getIdentifier(source)])
|
||||
return
|
||||
end
|
||||
if ps.getJobTypeCount('leo') < settings.PoliceCount then return ps.notify(source, ps.lang('wholesale.notEnoughCops'), 'error') end
|
||||
if ps.getJobTypeCount('leo') < settings.PoliceCount then return Bridge.Notify.SendNotify(source, Bridge.Language.Locale('wholesale.notEnoughCops'), 'error') end
|
||||
if ps.removeItem(source, k, 1) then
|
||||
local drugs, count = {}, 0
|
||||
for m, d in pairs (v) do
|
||||
@@ -120,7 +120,7 @@ for k, v in pairs (burners) do
|
||||
end
|
||||
if count < settings.WholesaleMinQuantity then
|
||||
ps.addItem(source, k, 1)
|
||||
ps.notify(source, ps.lang('wholesale.not_enough_drugs') or 'Not enough drugs for wholesale deal', 'error')
|
||||
Bridge.Notify.SendNotify(source, Bridge.Language.Locale('wholesale.not_enough_drugs') or 'Not enough drugs for wholesale deal', 'error')
|
||||
return
|
||||
end
|
||||
active[ps.getIdentifier(source)] = {
|
||||
@@ -152,7 +152,7 @@ RegisterNetEvent('md-drugs:server:SuccessSale', function()
|
||||
end
|
||||
local deal = active[id]
|
||||
if deal.count < settings.WholesaleMinQuantity then
|
||||
ps.notify(src, 'Not enough drugs for wholesale deal', 'error')
|
||||
Bridge.Notify.SendNotify(src, 'Not enough drugs for wholesale deal', 'error')
|
||||
active[id] = nil
|
||||
return
|
||||
end
|
||||
@@ -167,7 +167,7 @@ RegisterNetEvent('md-drugs:server:SuccessSale', function()
|
||||
end
|
||||
end
|
||||
if need ~= have then
|
||||
ps.notify(src, 'You are missing some drugs for the deal', 'error')
|
||||
Bridge.Notify.SendNotify(src, 'You are missing some drugs for the deal', 'error')
|
||||
active[id] = nil
|
||||
return
|
||||
end
|
||||
@@ -179,12 +179,12 @@ RegisterNetEvent('md-drugs:server:SuccessSale', function()
|
||||
end
|
||||
end
|
||||
if not removed then
|
||||
ps.notify(src,'Failed to remove drugs for the deal', 'error')
|
||||
Bridge.Notify.SendNotify(src,'Failed to remove drugs for the deal', 'error')
|
||||
active[id] = nil
|
||||
return
|
||||
end
|
||||
ps.addMoney(src, 'cash', finalPrice, 'Wholesale sale successful' .. ' $' .. finalPrice)
|
||||
ps.notify(src, 'Wholesale sale successful' .. ' $' .. finalPrice, 'success')
|
||||
Bridge.Notify.SendNotify(src, 'Wholesale sale successful' .. ' $' .. finalPrice, 'success')
|
||||
active[id] = nil
|
||||
end)
|
||||
|
||||
|
||||
+8
-8
@@ -63,7 +63,7 @@ local activePresses = {}
|
||||
RegisterServerEvent('md-drugs:server:stealisosafrole', function(num)
|
||||
local src = source
|
||||
if not ps.checkDistance(src, xtcLocations.isosafrole[num].loc, 3.0) then
|
||||
ps.notify(src, ps.lang('Checks.notIn'), "error")
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Checks.notIn'), "error")
|
||||
return
|
||||
end
|
||||
if timeOut(src, 'md-drugs:server:stealisosafrole') then return end
|
||||
@@ -73,7 +73,7 @@ end)
|
||||
RegisterServerEvent('md-drugs:server:stealmdp2p', function(num)
|
||||
local src = source
|
||||
if not ps.checkDistance(src, xtcLocations.mdp2p[num].loc, 3.0) then
|
||||
ps.notify(src, ps.lang('Checks.notIn'), "error")
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Checks.notIn'), "error")
|
||||
return
|
||||
end
|
||||
if timeOut(src, 'md-drugs:server:stealmdp2p') then return end
|
||||
@@ -118,7 +118,7 @@ end)
|
||||
RegisterServerEvent('md-drugs:server:makextc', function(data)
|
||||
local src = source
|
||||
if not activePresses[src] then
|
||||
ps.notify(src, ps.lang('xtc.noPressOut'), 'error')
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('xtc.noPressOut'), 'error')
|
||||
return
|
||||
end
|
||||
if timeOut(src, 'md-drugs:server:makextc') then return end
|
||||
@@ -132,14 +132,14 @@ end)
|
||||
RegisterServerEvent('md-drugs:server:buypress', function(loc, item)
|
||||
local src = source
|
||||
if not ps.checkDistance(src, xtcLocations.xtcpress[loc].loc, 2.0) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), "error")
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return
|
||||
end
|
||||
if timeOut(src, 'md-drugs:server:buypress') then return end
|
||||
if ps.removeMoney(src,"cash", RecipeList.presses['singlepress'].cash) then
|
||||
ps.addItem(src, "singlepress", 1)
|
||||
else
|
||||
ps.notify(src, ps.lang('Catches.notEnoughMoney'), "error")
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notEnoughMoney'), "error")
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -147,7 +147,7 @@ RegisterServerEvent('md-drugs:server:upgradepress', function(data, item)
|
||||
local src = source
|
||||
if timeOut(src, 'md-drugs:server:upgradepress') then return end
|
||||
if not ps.checkDistance(src, xtcLocations.xtcpress[data].loc, 2.0) then
|
||||
ps.notify(src, ps.lang('Catches.notIn'), "error")
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notIn'), "error")
|
||||
return
|
||||
end
|
||||
if not ps.craftItem(src, RecipeList.presses[item]) then
|
||||
@@ -164,7 +164,7 @@ end)
|
||||
RegisterServerEvent('md-drugs:server:makingrawxtc', function(num)
|
||||
local src = source
|
||||
if not ps.checkDistance(src, xtcLocations.rawxtcloc[num].loc, 3.0) then
|
||||
ps.notify(src, ps.lang('Checks.notIn'), "error")
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Checks.notIn'), "error")
|
||||
return
|
||||
end
|
||||
if timeOut(src, 'md-drugs:server:makingrawxtc') then return end
|
||||
@@ -207,7 +207,7 @@ RegisterServerEvent('md-drugs:server:stamp', function(num, color)
|
||||
elseif ps.removeItem(src, colors[color].."4", 1) then
|
||||
ps.addItem(src, item..'4', 1)
|
||||
else
|
||||
ps.notify(src, ps.lang('xtc.noPills'), 'error')
|
||||
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('xtc.noPills'), 'error')
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
Reference in new issue
Block a user