From dbed6b3c47cbdeae630ab7f2201c6a8e84c1976f Mon Sep 17 00:00:00 2001 From: Mustache Dom <123716453+Mustachedom@users.noreply.github.com> Date: Thu, 24 Oct 2024 19:45:39 -0700 Subject: [PATCH] made makeMenu function, moved all stores from config to server/travellingmerchant.lua --- client/deliveries.lua | 48 +------------ client/functions.lua | 30 ++++++++ client/target.lua | 8 +-- client/travellingmerchant.lua | 43 +----------- client/weed.lua | 24 +------ server/cocaine.lua | 128 ++++++++++++++++------------------ server/consumables.lua | 21 +++--- server/functions.lua | 7 +- server/lean.lua | 1 - server/lsd.lua | 68 +++++++----------- server/mescaline.lua | 4 +- server/meth.lua | 24 +++---- server/travellingmerchant.lua | 85 +++++++++++++++++++--- shared/config.lua | 44 +----------- shared/qbdrugsrewrite.lua | 20 +----- 15 files changed, 239 insertions(+), 316 deletions(-) diff --git a/client/deliveries.lua b/client/deliveries.lua index 10f8331..d2d96f9 100644 --- a/client/deliveries.lua +++ b/client/deliveries.lua @@ -1,51 +1,9 @@ local QBCore = exports['qb-core']:GetCoreObject() local isActive = false -RegisterNetEvent('md-drugs:client:opendealermenu', function() - local dealermenu = {} - local rep = GetRep() - print(rep.dealerrep) - if Config.StupidassNewQbItemName then - for k, v in pairs (QBConfig.ProductsStupidNameRewrite) do - if rep.dealerrep >= v.minrep then - dealermenu[#dealermenu + 1] = { - icon = GetImage(v.name), - title = GetLabel(v.name), - description = '$'..v.price, - event = "md-drugs:client:travellingmerchantox", - args = { - item = v.name, - cost = v.price, - amount = v.amount, - table = QBConfig.ProductsStupidNameRewrite, - num = k, - } - } - sorter(dealermenu, 'title') - end - end - else - for k, v in pairs (QBConfig.Products) do - if rep.dealerrep >= v.minrep then - dealermenu[#dealermenu + 1] = { - icon = GetImage(v.name), - title = GetLabel(v.name), - description = '$'..v.price, - event = "md-drugs:client:travellingmerchantox", - args = { - item = v.name, - cost = v.price, - amount = v.amount, - table = QBConfig.Products, - num = k, - } - } - sorter(dealermenu, 'title') - end - end - end - - lib.registerContext({id = 'dealermenu',title = "Dealer Menu", options = dealermenu}) +RegisterNetEvent('md-drugs:client:opendealermenu', function() + local rep = GetRep() + makeMenu('dealermenu', rep) lib.showContext('dealermenu') end) diff --git a/client/functions.lua b/client/functions.lua index b376a55..c88cda4 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -218,6 +218,36 @@ function sorter(sorting, value) table.sort(sorting, function(a, b) print(a[value], b[value]) return a[value] < b[value] end) end +function makeMenu(name, rep) + local menu = {} + local data = lib.callback.await('md-drugs:server:menu', false, name) + for k, v in pairs (data.table) do + local allow = false + if rep == nil then + allow = true + else + if rep.dealerrep >= v.minrep then allow = true end + end + if allow then + menu[#menu + 1] = { + icon = GetImage(v.name), + description = '$'.. v.price, + title = GetLabel(v.name), + onSelect = function() + local settext = "Cost: $"..v.price + local dialog = exports.ox_lib:inputDialog(v.name .."!", { + { type = 'select', label = "Payment Type", default = "cash", options = { { value = "cash"}, { value = "bank"},}}, + { type = 'number', label = "Amount to buy", description = settext, min = 0, max = v.amount, default = 1 }, + }) + if not dialog[1] then return end + TriggerServerEvent("md-drugs:server:purchaseGoods", dialog[2], dialog[1], v.name, v.price, data.table, k) + end, + } + end + end + sorter(menu, 'title') + lib.registerContext({id = data.id, title = data.title, options = menu}) +end function ItemCheck(item) diff --git a/client/target.lua b/client/target.lua index d45bcc4..d114f66 100644 --- a/client/target.lua +++ b/client/target.lua @@ -1,9 +1,9 @@ local QBCore = exports['qb-core']:GetCoreObject() -local icon = "fas fa-sign-in-alt" +local icon = "fa solid fa-eye" CreateThread(function() - AddBoxZoneSingle('telecokein', Config.CokeTeleIn, {action = function()tele(Config.CokeTeleOut)end, icon = icon, label = Lang.targets.coke.enter}) -- coke - AddBoxZoneSingle('telecokeout', Config.CokeTeleOut, {action = function()tele(Config.CokeTeleIn) end, icon = icon, label = Lang.targets.coke.exits}) -- coke - AddBoxZoneMulti('makepowder', Config.MakePowder, {event = "md-drugs:client:makepowder", icon = icon, label = Lang.targets.coke.chop}) -- coke + AddBoxZoneSingle('telecokein', Config.CokeTeleIn, {action = function()tele(Config.CokeTeleOut)end, icon = 'fa-solid fa-door-open', label = Lang.targets.coke.enter}) -- coke + AddBoxZoneSingle('telecokeout', Config.CokeTeleOut, {action = function()tele(Config.CokeTeleIn) end, icon = "fa-solid fa-door-closed", label = Lang.targets.coke.exit}) -- coke + AddBoxZoneMulti('makepowder', Config.MakePowder, {event = "md-drugs:client:makepowder", icon = "fa-solid fa-scissors", label = Lang.targets.coke.chop}) -- coke AddBoxZoneMulti('steallysergic', Config.lysergicacid, {event = "md-drugs:client:getlysergic", icon = icon, label = Lang.targets.lsd.lys}) -- lsd AddBoxZoneMulti('stealdiethylamide', Config.diethylamide, {event = "md-drugs:client:getdiethylamide", icon = icon, label = Lang.targets.lsd.die}) -- lsd AddBoxZoneMulti('gettabs', Config.gettabs, {event = "md-drugs:client:buytabs", icon = icon, label = Lang.targets.lsd.buyt}) -- lsd diff --git a/client/travellingmerchant.lua b/client/travellingmerchant.lua index a488602..9a48bb3 100644 --- a/client/travellingmerchant.lua +++ b/client/travellingmerchant.lua @@ -7,46 +7,9 @@ local current = "g_m_y_famdnf_01" local CurrentLocation = Config.Travellingmerchant[num] local travellingmerchant = CreatePed(0, current,CurrentLocation.x,CurrentLocation.y,CurrentLocation.z-1, CurrentLocation.w, false, false) Freeze(travellingmerchant, true, CurrentLocation.w) - AddSingleModel(travellingmerchant, { label = "Travelling Merchant", icon = "fas fa-eye", + AddSingleModel(travellingmerchant, { label = "Travelling Merchant", icon = "fas fa-eye", action = function() - local ShopMenu = {} - for k, v in pairs (Config.Items.items) do - ShopMenu[#ShopMenu + 1] = { - icon = GetImage(v.name), - description = '$'.. v.price, - title = GetLabel(v.name), - event = "md-drugs:client:travellingmerchantox", - args = { - item = v.name, - cost = v.price, - amount = v.amount, - table = Config.Items.items, - num = k - } - } - sorter(ShopMenu, 'title') - lib.registerContext({id = 'travellingmerchant',title = "Travelling Merchant", options = ShopMenu}) - end - - lib.showContext('travellingmerchant') - + makeMenu('travellingMerchant') + lib.showContext('travellingMerchant') end}, nil) end) - -RegisterNetEvent("md-drugs:client:travellingmerchantox", function(data) - local price = data.cost - local settext = "Amnt: "..data.amount.." | Cost: "..price or "Cost: "..price - local max = data.amount - local dialog = exports.ox_lib:inputDialog(data.item .."!", { - { type = 'select', label = "Payment Type", default = "cash", - options = { - { value = "cash"}, - { value = "bank"}, - } - }, - { type = 'number', label = "Amount to buy", description = settext, min = 0, max = max, default = 1 }, - }) - if not dialog[1] then return end - if data.cost == "Free" then data.cost = 0 end - TriggerServerEvent("md-drugs:server:travellingmerchantox", dialog[2], dialog[1], data.item, data.cost, data.table, data.num ) -end) diff --git a/client/weed.lua b/client/weed.lua index 05ce42a..121286b 100644 --- a/client/weed.lua +++ b/client/weed.lua @@ -191,32 +191,12 @@ AlienEffect() end) CreateThread(function() -local WeedShop = {} -local current = "u_m_m_jesus_01" - + local current = "u_m_m_jesus_01" lib.requestModel(current, Config.RequestModelTime) local CurrentLocation = Config.WeedSaleman local WeedGuy = CreatePed(0,current,CurrentLocation.x,CurrentLocation.y,CurrentLocation.z-1, CurrentLocation.w, false, false) Freeze(WeedGuy, true, CurrentLocation.w) - AddSingleModel(WeedGuy, {label = "Weed Shop",icon = "fas fa-eye",action = function() lib.showContext('WeedShop')end}, nil) - for k, v in pairs (Config.Weed.items) do - WeedShop[#WeedShop + 1] = { - icon = GetImage(v.name), - title = GetLabel(v.name), - description = '$'.. v.price, - event = "md-drugs:client:travellingmerchantox", - args = { - item = v.name, - cost = v.price, - amount = v.amount, - table = Config.Weed.items, - num = k, - } - } - sorter(WeedShop, 'title') - lib.registerContext({id = 'WeedShop',title = "Weed Shop", options = WeedShop}) - end - + AddSingleModel(WeedGuy, {label = "Weed Shop",icon = "fas fa-eye", action = function() makeMenu('WeedShop') lib.showContext('WeedShop')end}, nil) end) local function createBluntOptions(contextId, contextTitle, eventLabelPrefix, tableName) diff --git a/server/cocaine.lua b/server/cocaine.lua index 171c731..4118ffd 100644 --- a/server/cocaine.lua +++ b/server/cocaine.lua @@ -34,78 +34,74 @@ AddEventHandler("coke:pickupCane", function(loc) end) RegisterServerEvent('md-drugs:server:makepowder', function(num) - local src = source - if CheckDist(src, Config.MakePowder[num]['loc']) then return end - if Config.TierSystem then - local coke = getRep(src, 'coke') - if coke <= Config.Tier1 then - if not GetRecipe(src, 'cocaine', 'cokepowder', 'tier1') then return end - Log(GetName(src) .. ' Made Raw Coke' .. dist(src, Config.MakePowder[num]['loc']) .. ' vectors', 'coke') - elseif coke >= Config.Tier1 and coke <= Config.Tier2 then - if not GetRecipe(src, 'cocaine', 'cokepowder', 'tier2') then return end - Log(GetName(src) .. ' Made Raw Coke tier 2' .. dist(src, Config.MakePowder[num]['loc']) .. ' vectors', 'coke') - else - if not GetRecipe(src, 'cocaine', 'cokepowder', 'tier3') then return end - Log(GetName(src) ..' Made Raw Coke tier 3' .. dist(src, Config.MakePowder[num]['loc']) .. ' vectors', 'coke') - end - else - if not GetRecipe(src, 'cocaine', 'cokepowder', 'tier1') then return end - Log(GetName(src) .. ' Made Raw Coke' .. dist(src, Config.MakePowder[num]['loc']) .. ' vectors', 'coke') - end + local src = source + if CheckDist(src, Config.MakePowder[num]['loc']) then return end + local tier = 'tier1' + local logMessage = ' Made Raw Coke' + if Config.TierSystem then + local coke = getRep(src, 'coke') + if coke > Config.Tier1 and coke <= Config.Tier2 then + tier = 'tier2' + logMessage = ' Made Raw Coke tier 2' + elseif coke > Config.Tier2 then + tier = 'tier3' + logMessage = ' Made Raw Coke tier 3' + end + end + if not GetRecipe(src, 'cocaine', 'cokepowder', tier) then return end + Log(GetName(src) .. logMessage .. dist(src, Config.MakePowder[num]['loc']) .. ' vectors', 'coke') end) RegisterServerEvent('md-drugs:server:cutcokeone', function() - local src = source - local Player = QBCore.Functions.GetPlayer(src) - if Config.TierSystem then - local coke = Player.Functions.GetItemByName('coke') - local coke2 = Player.Functions.GetItemByName('cokestagetwo') - local coke3 = Player.Functions.GetItemByName('cokestagethree') - if coke then - if not GetRecipe(src, 'cocaine', 'cutcoke', 'tier1') then return end - Log(GetName(src) .. ' Cut Coke', 'coke') - elseif coke2 then - if not GetRecipe(src, 'cocaine', 'cutcoke', 'tier2') then return end - Log(GetName(src) .. ' Cut Coke tier 2', 'coke') - elseif coke3 then - if not GetRecipe(src, 'cocaine', 'cutcoke', 'tier3') then return end - Log(GetName(src) .. ' Cut Coke tier 3', 'coke') - else - Notifys(src,Lang.Coke.nocutcoke, "error") - end - else - if not GetRecipe(src, 'cocaine', 'cutcoke', 'tier1') then return end - Log(GetName(src) .. ' Cut Coke', 'coke') - end + local src = source + local Player = QBCore.Functions.GetPlayer(src) + local count = 0 + 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 count >= 1 then return end + if Player.Functions.GetItemByName(v.item) then + if not GetRecipe(src, 'cocaine', 'cutcoke', v.tier) then return end + Log(GetName(src) .. v.log, 'coke') + return + end + end + Notifys(src, Lang.Coke.nocutcoke, "error") + else + if not GetRecipe(src, 'cocaine', 'cutcoke', 'tier1') then return end + Log(GetName(src) .. ' Cut Coke', 'coke') + end end) RegisterServerEvent('md-drugs:server:bagcoke', function() - local src = source - local Player = QBCore.Functions.GetPlayer(src) - if Config.TierSystem then - local coke = getRep(source, 'coke') - local locoke = Player.Functions.GetItemByName('loosecoke') - local locoke2 = Player.Functions.GetItemByName('loosecokestagetwo') - local locoke3 = Player.Functions.GetItemByName('loosecokestagethree') - if locoke then - if not GetRecipe(src, 'cocaine', 'bagcoke', 'tier1') then return end - AddRep(src, 'coke') - Log(GetName(src) .. ' Bagged Coke and now has a rep of ' .. coke + 1, 'coke') - elseif locoke2 then - if not GetRecipe(src, 'cocaine', 'bagcoke', 'tier1') then return end - AddRep(src, 'coke') - Log(GetName(src) .. ' Bagged Coke tier 2 and now has a rep of ' .. coke + 1, 'coke') - elseif locoke3 then - if not GetRecipe(src, 'cocaine', 'bagcoke', 'tier3') then return end - AddRep(src, 'coke') - Log(GetName(source) .. ' Bagged Coke tier 3 and now has a rep of ' .. coke + 1, 'coke') - else - Notifys(src, Lang.Coke.nobagcoke, "error") - end - else - if not GetRecipe(src, 'cocaine', 'bagcoke', 'tier1') then return end - Log(GetName(source) .. ' Bagged Coke', 'coke') - end + local src = source + local Player = QBCore.Functions.GetPlayer(src) + local count = 0 + if Config.TierSystem then + local coke = getRep(src, 'coke') + 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 Player.Functions.GetItemByName(v.item) then + if count >= 1 then return end + if not GetRecipe(src, 'cocaine', 'bagcoke', v.tier) then return end + AddRep(src, 'coke') + Log(GetName(src) .. v.log .. ' and now has a rep of ' .. coke + 1, 'coke') + return + end + end + Notifys(src, Lang.Coke.nobagcoke, "error") + else + if not GetRecipe(src, 'cocaine', 'bagcoke', 'tier1') then return end + Log(GetName(src) .. ' Bagged Coke', 'coke') + end end) local cokecut = {loosecokestagetwo = 2, loosecokestagethree = 3} diff --git a/server/consumables.lua b/server/consumables.lua index d832447..ea97049 100644 --- a/server/consumables.lua +++ b/server/consumables.lua @@ -1,15 +1,15 @@ local QBCore = exports['qb-core']:GetCoreObject() -for k, v in pairs (Consumables.Items) do QBCore.Functions.CreateUseableItem(k, function(source, item) - local src = source - local Player = QBCore.Functions.GetPlayer(src) - if v.time == nil then v.time = Consumables.defaulttime end - if v.effect == nil then v.effect = 0 end - if v.anim == nil then v.anim = Consumables.defaultanim end - if v.progressbartext == nil then v.progressbartext = Consumables.defaultprogresstext end - if v.add == nil then v.add = {hunger = 0} end - TriggerClientEvent("md-drugs:client:consumedrugs", source, v.time, v.effect, v.anim, v.progressbartext, v.add, k) - end) +for k, v in pairs(Consumables.Items) do + QBCore.Functions.CreateUseableItem(k, function(source, item) + if not Itemcheck(source, k, 1) then return end + local time = v.time or Consumables.defaulttime + local effect = v.effect or 0 + local anim = v.anim or Consumables.defaultanim + local progressbartext = v.progressbartext or Consumables.defaultprogresstext + local add = v.add or {hunger = 0} + TriggerClientEvent("md-drugs:client:consumedrugs", source, time, effect, anim, progressbartext, add, k) + end) end RegisterNetEvent('md-drugs:server:removeconsum', function(item) @@ -18,7 +18,6 @@ RegisterNetEvent('md-drugs:server:removeconsum', function(item) end) RegisterNetEvent('md-drugs:server:updatestatus', function(stat, statval) - print(stat,statval) local Player = QBCore.Functions.GetPlayer(source) if stat == "thirst" then local value = Player.PlayerData.metadata.thirst + statval diff --git a/server/functions.lua b/server/functions.lua index b201ab9..794fdac 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -261,7 +261,12 @@ function AddRep(source, type) MySQL.update('UPDATE drugrep SET drugrep = ? WHERE cid = ?', {update, Player.PlayerData.citizenid}) return true end - + +function sortTab(tbl, type) + table.sort(tbl, function(a, b) + return a[type] < b[type] + end) +end function ChecknRemove(source, table) local Player = QBCore.Functions.GetPlayer(source) diff --git a/server/lean.lua b/server/lean.lua index 81b22d6..8ef87ed 100644 --- a/server/lean.lua +++ b/server/lean.lua @@ -19,7 +19,6 @@ end) QBCore.Functions.CreateUseableItem('leancup', function(source, item) local src = source - local Player = QBCore.Functions.GetPlayer(src) if Itemcheck(src, 'leancup', 1) then TriggerClientEvent('md-drugs:client:leancraft', src) end diff --git a/server/lsd.lua b/server/lsd.lua index 0fca2f1..02fafda 100644 --- a/server/lsd.lua +++ b/server/lsd.lua @@ -9,8 +9,7 @@ RegisterServerEvent('md-drugs:server:getlysergic', function(num) end) RegisterServerEvent('md-drugs:server:getdiethylamide', function(num) -local src = source -local Player = QBCore.Functions.GetPlayer(src) + local src = source if CheckDist(src, Config.diethylamide[num]['loc']) then return end if AddItem(src,'diethylamide', 2) then Log(GetName(src) ..' Got Diethylamide with a distance of ' .. dist(source, Config.diethylamide[num]['loc']) .. '!', 'lsd') @@ -28,7 +27,7 @@ end) lib.callback.register('md-drugs:server:removecleaningkit', function(source) -local src = source + local src = source if not Itemcheck(src, 'cleaningkit', 1) then return end if RemoveItem(src,"cleaningkit", 1) then Log(GetName(src) ..' Wiped Down Their LSD Lab Kit!' , 'lsd') @@ -37,21 +36,21 @@ local src = source end) RegisterServerEvent('md-drugs:server:getlabkitback', function() -local src = source + local src = source if AddItem(src,"lsdlabkit", 1) then Log(GetName(src) ..' Picked Up Their LSD Lab Kit Back At ' .. GetCoords(src) .. '!', 'lsd') end end) RegisterServerEvent('md-drugs:server:heatliquid', function() -local src = source + local src = source if not GetRecipe(src, 'lsd', 'vial', 'heat') then return end Log(GetName(src) ..' Heated Basic LSD!', 'lsd') end) RegisterServerEvent('md-drugs:server:failheating', function() -local src = source -if not ChecknRemove(source, {lysergic_acid = 1, diethylamide = 1}) then return end + local src = source + if not ChecknRemove(source, {lysergic_acid = 1, diethylamide = 1}) then return end Notifys(src,Lang.lsd.failed, "error") Log(GetName(src) ..' Failed Basic LSD Like An Idiot!', 'lsd') end) @@ -59,7 +58,6 @@ end) RegisterServerEvent('md-drugs:server:refinequalityacid', function() local src = source -local randomchance = math.random(1,100) if not Itemcheck(src, 'lsd_one_vial', 1) then return end if Config.TierSystem then local lsd = getRep(src, 'lsd') @@ -79,6 +77,7 @@ if not Itemcheck(src, 'lsd_one_vial', 1) then return end Log(GetName(src) ..' Refined Acid and Now Has A Rep Of ' .. lsd + 1 .. '!', 'lsd') end else + local randomchance = math.random(1,100) if RemoveItem(src,'lsd_one_vial', 1) then if randomchance <= 60 then AddItem(src,'lsd_vial_two', 1) @@ -127,44 +126,31 @@ RegisterServerEvent('md-drugs:server:getlabkit', function() end end) - - - RegisterServerEvent('md-drugs:server:maketabpaper', function() -local src = source -local Player = QBCore.Functions.GetPlayer(src) -if not Itemcheck(src,'tab_paper', 1) then return end - if RemoveItem(src,'lsd_one_vial', 1) then - RemoveItem(src,'tab_paper', 1) - AddItem(src,'smileyfacesheet', 1) - Log(GetName(src) ..' Made A Smiley Face Sheet', 'lsd') - elseif Player.Functions.RemoveItem('lsd_vial_two', 1) then - RemoveItem(src,'tab_paper', 1) - AddItem(src,'wildcherrysheet', 1) - Log(GetName(src) ..' Made A Wild Cherry Sheet', 'lsd') - elseif Player.Functions.RemoveItem('lsd_vial_three', 1) then - RemoveItem(src,'tab_paper', 1) - AddItem(src,'yinyangsheet', 1) - Log(GetName(src) ..' Made A Yin Yang Sheet', 'lsd') - elseif Player.Functions.RemoveItem('lsd_vial_four', 1) then - RemoveItem(src,'tab_paper', 1) - AddItem(src,'pineapplesheet', 1) - Log(GetName(src) ..' Made A Pine Apple Sheet', 'lsd') - elseif Player.Functions.RemoveItem('lsd_vial_five', 1) then - RemoveItem(src,'tab_paper', 1) - AddItem(src,'bartsheet', 1) - Log(GetName(src) ..' Made A Cluckin Bell Sheet', 'lsd') - elseif Player.Functions.RemoveItem('lsd_vial_six', 1) then - RemoveItem(src,'tab_paper', 1) - AddItem(src,'gratefuldeadsheet', 1) - Log(GetName(src) ..' Made A Maze Sheet', 'lsd') - else - Notifys(Lang.lsd.novial, "error") + local src = source + if not Itemcheck(src,'tab_paper', 1) then return end + local count = 0 + 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'} + } + sortTab(vialdata, 'vial') + for k, v in pairs (vialdata) do + if count >= 1 then return end + if RemoveItem(src, v.vial, 1) and RemoveItem(src, 'tab_paper', 1) then + AddItem(src, v.sheet, 1) + Log(GetName(src) ..' ' .. v.log, 'lsd') + count = count + 1 + end end end) local sheets = { - {item = 'smileyfacesheet', recieve = "Smiley_tabs", }, + {item = 'smileyfacesheet', recieve = "smiley_tabs", }, {item = 'wildcherrysheet', recieve = "wildcherry_tabs", }, {item = 'yinyangsheet', recieve = "yinyang_tabs", }, {item = 'pineapplesheet', recieve = "pineapple_tabs", }, diff --git a/server/mescaline.lua b/server/mescaline.lua index 2ecbe49..63a361f 100644 --- a/server/mescaline.lua +++ b/server/mescaline.lua @@ -1,14 +1,12 @@ local QBCore = exports['qb-core']:GetCoreObject() GlobalState.Mescaline = Config.Mescaline - Citizen.CreateThread(function() for _, v in pairs(Config.Mescaline) do v.taken = false end end) - function MescalineCooldown(loc) CreateThread(function() Wait(Config.respawnTime * 1000) @@ -22,7 +20,7 @@ end RegisterNetEvent("Mescaline:pickupCane", function(loc) - if CheckDist(source, Config.Mescaline[loc].location) then return end + if CheckDist(source, Config.Mescaline[loc].location) then return end if not Config.Mescaline[loc].taken then Config.Mescaline[loc].taken = true GlobalState.Mescaline = Config.Mescaline diff --git a/server/meth.lua b/server/meth.lua index d539aef..d510837 100644 --- a/server/meth.lua +++ b/server/meth.lua @@ -1,14 +1,14 @@ local QBCore = exports['qb-core']:GetCoreObject() RegisterServerEvent('md-drugs:server:startcook', function() - local src = source + local src = source if not GetRecipe(source, 'meth', 'cook', 'heat') then return end Notifys(src, "Adding Things To The Mix", "success") Log(GetName(source) .. ' Started A Meth Batch', 'Meth') end) RegisterServerEvent('md-drugs:server:givemethingridients', function() - local src = source + local src = source local chance = math.random(1,100) local amount = math.random(1,5) if chance <= 50 then @@ -30,18 +30,18 @@ end) RegisterServerEvent('md-drugs:server:geteph', function(num) local src = source - if CheckDist(src, Config.MethEph[num]['loc']) then return end - if AddItem(src, 'ephedrine', 1) then - Notifys(src, 'Got Ephedrine!', "success") - Log(GetName(src) .. ' Got ' .. 1 .. 'Of Ephedrine', 'Meth') - end + if CheckDist(src, Config.MethEph[num]['loc']) then return end + if AddItem(src, 'ephedrine', 1) then + Notifys(src, 'Got Ephedrine!', "success") + Log(GetName(src) .. ' Got ' .. 1 .. 'Of Ephedrine', 'Meth') + end end) RegisterServerEvent('md-drugs:server:getace', function(num) local src = source - if CheckDist(src, Config.Methace[num]['loc']) then return end - if AddItem(src, 'acetone', 1) then - Log(GetName(src) .. ' Got ' .. 1 .. 'Of Acetone', 'Meth') - Notifys(src, 'Got Acetone!', "success") - end + if CheckDist(src, Config.Methace[num]['loc']) then return end + if AddItem(src, 'acetone', 1) then + Log(GetName(src) .. ' Got ' .. 1 .. 'Of Acetone', 'Meth') + Notifys(src, 'Got Acetone!', "success") + end end) \ No newline at end of file diff --git a/server/travellingmerchant.lua b/server/travellingmerchant.lua index 0867d9f..51b8f6f 100644 --- a/server/travellingmerchant.lua +++ b/server/travellingmerchant.lua @@ -1,15 +1,84 @@ local QBCore = exports['qb-core']:GetCoreObject() local loc = math.random(1, #Config.Travellingmerchant) -RegisterServerEvent("md-drugs:server:travellingmerchantox", function(amount, money, item, price,table,num) - local src = source local Player = QBCore.Functions.GetPlayer(src) - if not table[num]['name'] == item then return end - if Player.Functions.RemoveMoney(tostring(money), tonumber(price) * tonumber(amount)) then - AddItem(source, item, amount) - Log(GetName(source) .. ' Bought ' .. amount .. ' Of ' .. item .. ' For ' .. tonumber(price) * tonumber(amount) .. '!', 'merchant') - end +local stores = { + travel = { + {name = "tab_paper", price = 50, amount = 50, }, + {name = "bakingsoda", price = 25, amount = 50, }, + {name = "isosafrole", price = 25, amount = 50, }, + {name = "mdp2p", price = 25, amount = 50, }, + {name = "lysergic_acid", price = 25, amount = 50, }, + {name = "diethylamide", price = 25, amount = 50, }, + {name = "lockpick", price = 2, amount = 1000, }, + {name = "emptyvial", price = 2, amount = 1000, }, + {name = "needle", price = 2, amount = 1000, }, + {name = "cokeburner", price = 25, amount = 50, }, + {name = "crackburner", price = 2, amount = 50, }, + {name = "lsdburner", price = 2, amount = 50, }, + {name = "heroinburner", price = 2, amount = 50, }, + {name = "mdlean", price = 50, amount = 50, }, + {name = "weedgrinder", price = 25, amount = 50, }, + {name = "mdbutter", price = 25, amount = 50, }, + {name = "flour", price = 25, amount = 50, }, + {name = "chocolate", price = 25, amount = 50, }, + {name = "butane", price = 25, amount = 50, }, + {name = "butanetorch", price = 2, amount = 1000, }, + {name = "dabrig", price = 2, amount = 1000, }, + {name = "mdwoods", price = 2, amount = 1000, }, + {name = "leancup", price = 25, amount = 50, }, + {name = "xtcburner", price = 25, amount = 50, }, + }, + Weed = { + {name = "weedgrinder", price = 25, amount = 50, }, + {name = "mdbutter", price = 25, amount = 50, }, + {name = "flour", price = 25, amount = 50, }, + {name = "chocolate", price = 25, amount = 50, }, + {name = "butane", price = 25, amount = 50, }, + {name = "butanetorch", price = 2, amount = 1000,}, + {name = "dabrig", price = 2, amount = 1000,}, + {name = "mdwoods", price = 2, amount = 1000}, + }, + Products = { + {name = "weed_white-widow_seed", price = 15, amount = 150, minrep = 0}, + {name = "weed_skunk_seed", price = 15, amount = 150, minrep = 0}, + {name = "weed_purple-haze_seed", price = 15, amount = 150, minrep = 0}, + {name = "weed_og-kush_seed", price = 15, amount = 150, minrep = 0}, + {name = "weed_amnesia_seed", price = 15, amount = 150, minrep = 0}, + }, + ProductsStupidNameRewrite = { + {name = "weed_whitewidow_seed", price = 15, amount = 150, minrep = 0}, + {name = "weed_skunk_seed", price = 15, amount = 150, minrep = 0}, + {name = "weed_purplehaze_seed", price = 15, amount = 150, minrep = 0}, + {name = "weed_ogkush_seed", price = 15, amount = 150, minrep = 0}, + {name = "weed_amnesia_seed", price = 15, amount = 150, minrep = 0}, + } +} +lib.callback.register('md-drugs:server:menu', function(source, data) + local src = source + if data == 'travellingMerchant' then + return {table = stores.travel, des = '$', id = 'travellingMerchant', title = 'travelling Merchant'} + elseif data == 'dealermenu' then + local table + if Config.StupidassNewQbItemName then table = stores.ProductsStupidNameRewrite else table = stores.Products end + return {table = table, id = 'dealermenu', title = "Dealer Menu"} + elseif data == 'WeedShop' then + return {table = stores.Weed, id = 'WeedShop', title = "Weed Shop"} + end +end) + +RegisterServerEvent("md-drugs:server:purchaseGoods", function(amount, money, item, price,table,num) + local src = source local Player = QBCore.Functions.GetPlayer(src) + for i = 1, #table do + if table[i].name == item then + if not table[i].price == price then return end + if Player.Functions.RemoveMoney(tostring(money), tonumber(table[i].price) * tonumber(amount)) then + AddItem(src, item, amount) + Log(GetName(src) .. ' Bought ' .. amount .. ' Of ' .. item .. ' For ' .. tonumber(price) * tonumber(amount) .. '!', 'merchant') + end + end + end end) lib.callback.register('md-drugs:server:GetMerchant', function(source) -return loc + return loc end) \ No newline at end of file diff --git a/shared/config.lua b/shared/config.lua index f1eed7f..18c02d7 100644 --- a/shared/config.lua +++ b/shared/config.lua @@ -158,20 +158,6 @@ Config.WeedDry = { -- where you dry leaves Config.Joblock = false -- if you want weed to be a job Config.weedjob = "" -- what the job name is -Config.Weed = { --- this is the store for the weed ingridients - label = "Weed Shop", - slots = 8, - items = { - {name = "weedgrinder", price = 25, amount = 50, }, - {name = "mdbutter", price = 25, amount = 50, }, - {name = "flour", price = 25, amount = 50, }, - {name = "chocolate", price = 25, amount = 50, }, - {name = "butane", price = 25, amount = 50, }, - {name = "butanetorch", price = 2, amount = 1000,}, - {name = "dabrig", price = 2, amount = 1000,}, - {name = "mdwoods", price = 2, amount = 1000,}, - } -} ----------------- Wholesale Config.SuccessfulChance = 90 --- this is the chance of a Success wholesale 1-100 @@ -191,35 +177,7 @@ Config.Travellingmerchant = { ------------ these are the random locations the me vector4(-1522.93, 1476.01, 111.45, 41.25), vector4(-3278.98, 973.38, 5.35, 101.53), } -Config.Items = { --- this is the store for the travelling merchant - items = { - {name = "tab_paper", price = 50, amount = 50,}, - {name = "bakingsoda", price = 25, amount = 50, }, - {name = "isosafrole", price = 25, amount = 50, }, - {name = "mdp2p", price = 25, amount = 50, }, - {name = "lysergic_acid", price = 25, amount = 50, }, - {name = "diethylamide", price = 25, amount = 50, }, - {name = "lockpick", price = 2, amount = 1000, }, - {name = "emptyvial", price = 2, amount = 1000, }, - {name = "needle", price = 2, amount = 1000, }, - {name = "cokeburner", price = 25, amount = 50, }, - {name = "crackburner", price = 2, amount = 50, }, - {name = "lsdburner", price = 2, amount = 50, }, - {name = "heroinburner", price = 2, amount = 50, }, - {name = "mdlean", price = 50, amount = 50, }, - {name = "weedgrinder", price = 25, amount = 50, }, - {name = "mdbutter", price = 25, amount = 50, }, - {name = "flour", price = 25, amount = 50, }, - {name = "chocolate", price = 25, amount = 50, }, - {name = "butane", price = 25, amount = 50, }, - {name = "butanetorch", price = 2, amount = 1000, }, - {name = "dabrig", price = 2, amount = 1000, }, - {name = "mdwoods", price = 2, amount = 1000, }, - {name = "leancup", price = 25, amount = 50, }, - {name = "xtcburner", price = 25, amount = 50, }, - - } -} + --------------------------------------- oxy runs ---- How oxyruns work. You pay for a truck, you get in it and it gives a route. There is a 20% chance that the car will be "hot" and you have to ditch it. No Routes will spawn if that pops up ----- when you get to the drop off point third eye the truck. You will carry a box to the ped. He will give you cash, some oxy and maybe a random item. Rinse and repeat diff --git a/shared/qbdrugsrewrite.lua b/shared/qbdrugsrewrite.lua index aace4f3..f3b2b6d 100644 --- a/shared/qbdrugsrewrite.lua +++ b/shared/qbdrugsrewrite.lua @@ -140,25 +140,7 @@ QBConfig.DrugsPrice = { ["cupofdextro"] = {min = 18, max = 40}, } - QBConfig.Dealers = {} - - - -- Shop QBConfig -QBConfig.Products = { - [1] = {name = "weed_white-widow_seed", price = 15, amount = 150, minrep = 0}, - [2] = {name = "weed_skunk_seed", price = 15, amount = 150, minrep = 0}, - [3] = {name = "weed_purple-haze_seed", price = 15, amount = 150, minrep = 0}, - [4] = {name = "weed_og-kush_seed", price = 15, amount = 150, minrep = 0}, - [5] = {name = "weed_amnesia_seed", price = 15, amount = 150, minrep = 0}, -} - -QBConfig.ProductsStupidNameRewrite = { - [1] = {name = "weed_whitewidow_seed", price = 15, amount = 150, minrep = 0}, - [2] = {name = "weed_skunk_seed", price = 15, amount = 150, minrep = 0}, - [3] = {name = "weed_purplehaze_seed", price = 15, amount = 150, minrep = 0}, - [4] = {name = "weed_ogkush_seed", price = 15, amount = 150, minrep = 0}, - [5] = {name = "weed_amnesia_seed", price = 15, amount = 150, minrep = 0}, -} +QBConfig.Dealers = {} QBConfig.UseMarkedBills = false -- true for marked bills, false for cash QBConfig.DeliveryRepGain = 1 -- amount of rep gained per delivery