From d46e28e8f2bba80d0cb206aea4b9590027bb94f4 Mon Sep 17 00:00:00 2001 From: Mustache Dom <123716453+Mustachedom@users.noreply.github.com> Date: Wed, 21 Jan 2026 01:36:38 -0700 Subject: [PATCH] added troll feature --- client/deliveries.lua | 179 ++++++++------- client/wholesale.lua | 304 ++++++++++++------------ client/xtc.lua | 101 ++++---- clientRun.lua | 6 +- server/deliveries.lua | 522 +++++++++++++++++++++--------------------- server/functions.lua | 28 ++- server/wholesale.lua | 394 +++++++++++++++---------------- server/xtc.lua | 95 ++++---- serverRun.lua | 6 +- 9 files changed, 833 insertions(+), 802 deletions(-) diff --git a/client/deliveries.lua b/client/deliveries.lua index 83c69fa..d19c944 100644 --- a/client/deliveries.lua +++ b/client/deliveries.lua @@ -1,89 +1,90 @@ ---TODO: Make dealers better -local isActive = false -local dealer = {} -local function SpawnDealer() - if #dealer >= 1 then - for k,v in pairs (dealer) do - DeletePed(v) - end - dealer = {} - end - for k,v in pairs(GlobalState.MDDrugsLocations.Dealers) do - local Ped = "g_m_y_famdnf_01" - requestModel(Ped, 30000) - local loc = json.decode(v.coords) - dealer[k] = CreatePed(0, Ped,loc.x,loc.y, loc.z-1, loc.h, false, false) - Freeze(dealer[k], true, loc.h) - Bridge.Target.AddLocalEntity(dealer[k], { - { - icon = 'fas fa-user-secret', - label = Bridge.Language.Locale('Deliveries.targetGetDel'), - action = function() - local data = Bridge.Callback.Trigger('md-drugs:server:GetDeliveryItem', k) - if type(data) == 'table' and data.coords then - TriggerEvent('md-drugs:client:setLocation', data) - end - end, - }, - { - icon = "fa-solid fa-store", - label = Bridge.Language.Locale('Deliveries.targetOpenShop'), - action = function() - local rep = GetRep() - local items = Bridge.Callback.Trigger('md-drugs:server:dealerList', k) - local options = {} - for m, d in pairs (items) do - if rep.dealerrep >= d.minrep then - options[#options+1] = { - title = Bridge.Inventory.GetItemInfo(d.name).label, - description = '$' .. d.price, - icon = Bridge.Inventory.GetItemInfo(d.name).image, - onSelect = function() - TriggerServerEvent('md-drugs:server:buyItemDealer', m, k) - end, - } - end - end - Bridge.Menu.Open({ - id = 'DealerMenu', - title = Bridge.Language.Locale('Deliveries.shopHeader'), - description = Bridge.Language.Locale('Deliveries.shopHeader'), - options = options - }) - end, - } - }) - end -end - -RegisterNetEvent('md-drugs:client:RefreshDealers', function() - SpawnDealer() -end) - -SpawnDealer() - -RegisterNetEvent('md-drugs:client:setLocation', function(data) - local coord = json.decode(data.coords) - SetNewWaypoint(coord.x, coord.y) - if isActive then return end - isActive = true - local Buyer = CreatePed(0, "g_m_y_famdnf_01",coord.x, coord.y, coord.z-1, coord.w, false, false) - Freeze(Buyer, true, coord.w) - Bridge.Target.AddLocalEntity(Buyer, { - { - icon = 'fas fa-user-secret', - label = Bridge.Language.Locale('Deliveries.targetHandOff'), - action = function() - if not progressbar(Bridge.Language.Locale('Deliveries.delivering'), 4000, 'uncuff') then return end - isActive = false - DeletePed(Buyer) - TriggerServerEvent('md-drugs:server:giveDeliveryItems', data.item, data.amount) - end, - canInteract = function() - if isActive then - return true - end - end - } - }) -end) +----TODO: Make dealers better +--local isActive = false +--local dealer = {} +--local function SpawnDealer() +-- if #dealer >= 1 then +-- for k,v in pairs (dealer) do +-- DeletePed(v) +-- end +-- dealer = {} +-- end +-- for k,v in pairs(GlobalState.MDDrugsLocations.Dealers) do +-- local Ped = "g_m_y_famdnf_01" +-- requestModel(Ped, 30000) +-- local loc = json.decode(v.coords) +-- dealer[k] = CreatePed(0, Ped,loc.x,loc.y, loc.z-1, loc.h, false, false) +-- Freeze(dealer[k], true, loc.h) +-- Bridge.Target.AddLocalEntity(dealer[k], { +-- { +-- icon = 'fas fa-user-secret', +-- label = Bridge.Language.Locale('Deliveries.targetGetDel'), +-- action = function() +-- local data = Bridge.Callback.Trigger('md-drugs:server:GetDeliveryItem', k) +-- if type(data) == 'table' and data.coords then +-- TriggerEvent('md-drugs:client:setLocation', data) +-- end +-- end, +-- }, +-- { +-- icon = "fa-solid fa-store", +-- label = Bridge.Language.Locale('Deliveries.targetOpenShop'), +-- action = function() +-- local rep = GetRep() +-- local items = Bridge.Callback.Trigger('md-drugs:server:dealerList', k) +-- local options = {} +-- for m, d in pairs (items) do +-- if rep.dealerrep >= d.minrep then +-- options[#options+1] = { +-- title = Bridge.Inventory.GetItemInfo(d.name).label, +-- description = '$' .. d.price, +-- icon = Bridge.Inventory.GetItemInfo(d.name).image, +-- onSelect = function() +-- TriggerServerEvent('md-drugs:server:buyItemDealer', m, k) +-- end, +-- } +-- end +-- end +-- Bridge.Menu.Open({ +-- id = 'DealerMenu', +-- title = Bridge.Language.Locale('Deliveries.shopHeader'), +-- description = Bridge.Language.Locale('Deliveries.shopHeader'), +-- options = options +-- }) +-- end, +-- } +-- }) +-- end +--end +-- +--RegisterNetEvent('md-drugs:client:RefreshDealers', function() +-- SpawnDealer() +--end) +-- +--SpawnDealer() +-- +--RegisterNetEvent('md-drugs:client:setLocation', function(data) +-- local coord = json.decode(data.coords) +-- SetNewWaypoint(coord.x, coord.y) +-- if isActive then return end +-- isActive = true +-- local Buyer = CreatePed(0, "g_m_y_famdnf_01",coord.x, coord.y, coord.z-1, coord.w, false, false) +-- Freeze(Buyer, true, coord.w) +-- Bridge.Target.AddLocalEntity(Buyer, { +-- { +-- icon = 'fas fa-user-secret', +-- label = Bridge.Language.Locale('Deliveries.targetHandOff'), +-- action = function() +-- if not progressbar(Bridge.Language.Locale('Deliveries.delivering'), 4000, 'uncuff') then return end +-- isActive = false +-- DeletePed(Buyer) +-- TriggerServerEvent('md-drugs:server:giveDeliveryItems', data.item, data.amount) +-- end, +-- canInteract = function() +-- if isActive then +-- return true +-- end +-- end +-- } +-- }) +--end) +-- \ No newline at end of file diff --git a/client/wholesale.lua b/client/wholesale.lua index 04adb58..45f2932 100644 --- a/client/wholesale.lua +++ b/client/wholesale.lua @@ -1,152 +1,152 @@ -local miss = false -local settings = ps.callback('md-drugs:server:GetWSsettings') - -function SetUpPeds(drugCount) - local attackerCount = settings.WholesaleAmbushBase - if settings.WholesaleAmbushScale then - if drugCount > settings.WholesaleAmbushTier1 then - attackerCount = 3 - end - if drugCount > settings.WholesaleAmbushTier2 then - attackerCount = 4 - end - if drugCount > settings.WholesaleAmbushTier3 then - attackerCount = 5 - end - end - local weaponTier = settings.WholesaleWeaponsTier1 - if settings.WholesaleWeaponTiers then - if drugCount > settings.WholesaleAmbushTier3 then - weaponTier = settings.WholesaleWeaponsTier4 - elseif drugCount > settings.WholesaleAmbushTier2 then - weaponTier = settings.WholesaleWeaponsTier3 - elseif drugCount > settings.WholesaleAmbushTier1 then - weaponTier = settings.WholesaleWeaponsTier2 - end - end - local playerPed = PlayerPedId() - local playerCoords = GetEntityCoords(playerPed, false) - local models = {"g_m_y_ballasout_01", "g_m_y_famdnf_01", "g_m_y_famca_01", "g_m_y_mexgoon_01", "g_m_y_salvagoon_01"} - for i = 1, attackerCount do - local angle = (360 / attackerCount) * i - local x = playerCoords.x + math.cos(math.rad(angle)) * 15 - local y = playerCoords.y + math.sin(math.rad(angle)) * 15 - local z = playerCoords.z - local modelHash = GetHashKey(models[math.random(1, #models)]) - requestModel(modelHash) - local ped = CreatePed(4, modelHash, x, y, z, 0.0, true, false) - local weapon = weaponTier[math.random(1, #weaponTier)] - SetPedRelationshipGroupHash(ped, GetHashKey("HATES_PLAYER")) - SetPedCombatAttributes(ped, 46, true) - SetPedCombatAttributes(ped, 0, true) - SetPedCombatAttributes(ped, 5, true) - SetPedCombatAttributes(ped, 2, true) - local healthMultiplier = 1.0 - if drugCount > settings.WholesaleAmbushTier3 then - healthMultiplier = 1.5 - elseif drugCount > settings.WholesaleAmbushTier2 then - healthMultiplier = 1.3 - elseif drugCount > settings.WholesaleAmbushTier1 then - healthMultiplier = 1.2 - end - local baseHealth = GetEntityHealth(ped) - SetEntityHealth(ped, math.floor(baseHealth * healthMultiplier)) - GiveWeaponToPed(ped, GetHashKey(weapon), 500, false, true) - TaskCombatPed(ped, playerPed, 0, 16) - local blip = AddBlipForEntity(ped) - SetBlipAsShortRange(blip, true) - SetBlipColour(blip, 1) - SetBlipScale(blip, 0.7) - SetEntityAsNoLongerNeeded(ped) - end - local tierName = "Basic" - if drugCount > settings.WholesaleAmbushTier3 then - tierName = "Elite" - elseif drugCount > settings.WholesaleAmbushTier2 then - tierName = "Advanced" - elseif drugCount > settings.WholesaleAmbushTier1 then - tierName = "Medium" - end - Bridge.Notify.SendNotify(string.format(Bridge.Language.Locale('wholesale.ambush'), attackerCount, tierName), 'error') -end - -RegisterNetEvent("md-drugs:client:GetLocation", function(drug) - if miss then - SetNewWaypoint(drug.location.x, drug.location.y) - else - local loc = drug.location - local timer = 0 - miss = true - SetNewWaypoint(loc.x, loc.y) - if settings.WholesaleShowEstimates and drug.count > 0 then - local bonusTiers = math.floor(drug.count / 10) - local potentialBonus = math.min(bonusTiers * settings.WholesaleQuantityBonus, settings.WholesaleMaxBonus) - local bonusPercent = math.floor(potentialBonus * 100) - local minPayout = math.floor(drug.price.min * (1 + potentialBonus)) - local maxPayout = math.floor(drug.price.max * (1 + potentialBonus)) - local totalMinPayout = drug.count * minPayout - local totalMaxPayout = drug.count * maxPayout - Bridge.Notify.SendNotify(string.format(Bridge.Language.Locale('wholesale.count'), drug.count), 'info') - if bonusPercent > 0 then - Bridge.Notify.SendNotify(string.format(Bridge.Language.Locale('wholesale.bonus'), bonusPercent), 'info') - end - Bridge.Notify.SendNotify(string.format(Bridge.Language.Locale('wholesale.estimate'), totalMinPayout, totalMaxPayout), 'info') - elseif drug.count <= 0 then - Bridge.Notify.SendNotify(Bridge.Language.Locale('wholesale.no_drugs'), 'error') - end - requestModel("g_m_y_famdnf_01", settings.RequestModelTime) - local current = "g_m_y_famdnf_01" - local drugdealer = CreatePed(0, current,loc.x,loc.y,loc.z-1, 90.0, false, false) - FreezeEntityPosition(drugdealer, true) - SetEntityInvincible(drugdealer, true) - Bridge.Target.AddLocalEntity(drugdealer, {{ - label = Bridge.Language.Locale('wholesale.targetBuyer'), - icon = "fas fa-eye", - action = function() - local luck = math.random(1,100) - if luck <= settings.SuccessfulChance then - if not ps.progressbar(Bridge.Language.Locale('wholesale.wholesaling'), 4000, 'uncuff') then return end - TriggerServerEvent("md-drugs:server:SuccessSale", drug) - else - ps.progressbar("Deal Going Bad", 4000, 'uncuff') - if settings.WholesaleAmbushEnabled then - SetUpPeds(drug.count) - end - if settings.WholesaleFailPoliceAlert > 0 then - local alertChance = math.random(1, 100) - if alertChance <= settings.WholesaleFailPoliceAlert then - PoliceCall(100) - end - end - TriggerServerEvent('md-drugs:server:CleanupWholesale') - end - Wait(3000) - DeleteEntity(drugdealer) - miss = false - end - }},drugdealer ) - repeat - Wait(1000) - timer = timer + 1 - until #(GetEntityCoords(PlayerPedId()) - vector3(loc.x, loc.y, loc.z) ) < 4.0 or timer == settings.WholesaleTimeout + 1 - PoliceCall(settings.AlertPoliceWholesale) - if timer <= settings.WholesaleTimeout or #(GetEntityCoords(PlayerPedId()) - vector3(loc.x, loc.y, loc.z) ) < 4.0 then - timer = 0 - else - Bridge.Notify.SendNotify(Bridge.Language.Locale('wholesale.tooLong'), 'error') - DeleteEntity(drugdealer) - TriggerServerEvent('md-drugs:server:CleanupWholesale') - if settings.WholesaleResetOnTimeout then - miss = false - end - end - end -end) - -RegisterNetEvent('md-drugs:client:WholesaleComplete', function(data) - local bonusText = "" - if data.bonus > 0 then - bonusText = " (+" .. data.bonus .. "% quantity bonus)" - end - Bridge.Notify.SendNotify(string.format(Bridge.Language.Locale('wholesale.complete'), data.quantity, data.payout, bonusText), 'success') -end) \ No newline at end of file +--local miss = false +--local settings = ps.callback('md-drugs:server:GetWSsettings') +-- +--function SetUpPeds(drugCount) +-- local attackerCount = settings.WholesaleAmbushBase +-- if settings.WholesaleAmbushScale then +-- if drugCount > settings.WholesaleAmbushTier1 then +-- attackerCount = 3 +-- end +-- if drugCount > settings.WholesaleAmbushTier2 then +-- attackerCount = 4 +-- end +-- if drugCount > settings.WholesaleAmbushTier3 then +-- attackerCount = 5 +-- end +-- end +-- local weaponTier = settings.WholesaleWeaponsTier1 +-- if settings.WholesaleWeaponTiers then +-- if drugCount > settings.WholesaleAmbushTier3 then +-- weaponTier = settings.WholesaleWeaponsTier4 +-- elseif drugCount > settings.WholesaleAmbushTier2 then +-- weaponTier = settings.WholesaleWeaponsTier3 +-- elseif drugCount > settings.WholesaleAmbushTier1 then +-- weaponTier = settings.WholesaleWeaponsTier2 +-- end +-- end +-- local playerPed = PlayerPedId() +-- local playerCoords = GetEntityCoords(playerPed, false) +-- local models = {"g_m_y_ballasout_01", "g_m_y_famdnf_01", "g_m_y_famca_01", "g_m_y_mexgoon_01", "g_m_y_salvagoon_01"} +-- for i = 1, attackerCount do +-- local angle = (360 / attackerCount) * i +-- local x = playerCoords.x + math.cos(math.rad(angle)) * 15 +-- local y = playerCoords.y + math.sin(math.rad(angle)) * 15 +-- local z = playerCoords.z +-- local modelHash = GetHashKey(models[math.random(1, #models)]) +-- requestModel(modelHash) +-- local ped = CreatePed(4, modelHash, x, y, z, 0.0, true, false) +-- local weapon = weaponTier[math.random(1, #weaponTier)] +-- SetPedRelationshipGroupHash(ped, GetHashKey("HATES_PLAYER")) +-- SetPedCombatAttributes(ped, 46, true) +-- SetPedCombatAttributes(ped, 0, true) +-- SetPedCombatAttributes(ped, 5, true) +-- SetPedCombatAttributes(ped, 2, true) +-- local healthMultiplier = 1.0 +-- if drugCount > settings.WholesaleAmbushTier3 then +-- healthMultiplier = 1.5 +-- elseif drugCount > settings.WholesaleAmbushTier2 then +-- healthMultiplier = 1.3 +-- elseif drugCount > settings.WholesaleAmbushTier1 then +-- healthMultiplier = 1.2 +-- end +-- local baseHealth = GetEntityHealth(ped) +-- SetEntityHealth(ped, math.floor(baseHealth * healthMultiplier)) +-- GiveWeaponToPed(ped, GetHashKey(weapon), 500, false, true) +-- TaskCombatPed(ped, playerPed, 0, 16) +-- local blip = AddBlipForEntity(ped) +-- SetBlipAsShortRange(blip, true) +-- SetBlipColour(blip, 1) +-- SetBlipScale(blip, 0.7) +-- SetEntityAsNoLongerNeeded(ped) +-- end +-- local tierName = "Basic" +-- if drugCount > settings.WholesaleAmbushTier3 then +-- tierName = "Elite" +-- elseif drugCount > settings.WholesaleAmbushTier2 then +-- tierName = "Advanced" +-- elseif drugCount > settings.WholesaleAmbushTier1 then +-- tierName = "Medium" +-- end +-- Bridge.Notify.SendNotify(string.format(Bridge.Language.Locale('wholesale.ambush'), attackerCount, tierName), 'error') +--end +-- +--RegisterNetEvent("md-drugs:client:GetLocation", function(drug) +-- if miss then +-- SetNewWaypoint(drug.location.x, drug.location.y) +-- else +-- local loc = drug.location +-- local timer = 0 +-- miss = true +-- SetNewWaypoint(loc.x, loc.y) +-- if settings.WholesaleShowEstimates and drug.count > 0 then +-- local bonusTiers = math.floor(drug.count / 10) +-- local potentialBonus = math.min(bonusTiers * settings.WholesaleQuantityBonus, settings.WholesaleMaxBonus) +-- local bonusPercent = math.floor(potentialBonus * 100) +-- local minPayout = math.floor(drug.price.min * (1 + potentialBonus)) +-- local maxPayout = math.floor(drug.price.max * (1 + potentialBonus)) +-- local totalMinPayout = drug.count * minPayout +-- local totalMaxPayout = drug.count * maxPayout +-- Bridge.Notify.SendNotify(string.format(Bridge.Language.Locale('wholesale.count'), drug.count), 'info') +-- if bonusPercent > 0 then +-- Bridge.Notify.SendNotify(string.format(Bridge.Language.Locale('wholesale.bonus'), bonusPercent), 'info') +-- end +-- Bridge.Notify.SendNotify(string.format(Bridge.Language.Locale('wholesale.estimate'), totalMinPayout, totalMaxPayout), 'info') +-- elseif drug.count <= 0 then +-- Bridge.Notify.SendNotify(Bridge.Language.Locale('wholesale.no_drugs'), 'error') +-- end +-- requestModel("g_m_y_famdnf_01", settings.RequestModelTime) +-- local current = "g_m_y_famdnf_01" +-- local drugdealer = CreatePed(0, current,loc.x,loc.y,loc.z-1, 90.0, false, false) +-- FreezeEntityPosition(drugdealer, true) +-- SetEntityInvincible(drugdealer, true) +-- Bridge.Target.AddLocalEntity(drugdealer, {{ +-- label = Bridge.Language.Locale('wholesale.targetBuyer'), +-- icon = "fas fa-eye", +-- action = function() +-- local luck = math.random(1,100) +-- if luck <= settings.SuccessfulChance then +-- if not ps.progressbar(Bridge.Language.Locale('wholesale.wholesaling'), 4000, 'uncuff') then return end +-- TriggerServerEvent("md-drugs:server:SuccessSale", drug) +-- else +-- ps.progressbar("Deal Going Bad", 4000, 'uncuff') +-- if settings.WholesaleAmbushEnabled then +-- SetUpPeds(drug.count) +-- end +-- if settings.WholesaleFailPoliceAlert > 0 then +-- local alertChance = math.random(1, 100) +-- if alertChance <= settings.WholesaleFailPoliceAlert then +-- PoliceCall(100) +-- end +-- end +-- TriggerServerEvent('md-drugs:server:CleanupWholesale') +-- end +-- Wait(3000) +-- DeleteEntity(drugdealer) +-- miss = false +-- end +-- }},drugdealer ) +-- repeat +-- Wait(1000) +-- timer = timer + 1 +-- until #(GetEntityCoords(PlayerPedId()) - vector3(loc.x, loc.y, loc.z) ) < 4.0 or timer == settings.WholesaleTimeout + 1 +-- PoliceCall(settings.AlertPoliceWholesale) +-- if timer <= settings.WholesaleTimeout or #(GetEntityCoords(PlayerPedId()) - vector3(loc.x, loc.y, loc.z) ) < 4.0 then +-- timer = 0 +-- else +-- Bridge.Notify.SendNotify(Bridge.Language.Locale('wholesale.tooLong'), 'error') +-- DeleteEntity(drugdealer) +-- TriggerServerEvent('md-drugs:server:CleanupWholesale') +-- if settings.WholesaleResetOnTimeout then +-- miss = false +-- end +-- end +-- end +--end) +-- +--RegisterNetEvent('md-drugs:client:WholesaleComplete', function(data) +-- local bonusText = "" +-- if data.bonus > 0 then +-- bonusText = " (+" .. data.bonus .. "% quantity bonus)" +-- end +-- Bridge.Notify.SendNotify(string.format(Bridge.Language.Locale('wholesale.complete'), data.quantity, data.payout, bonusText), 'success') +--end) \ No newline at end of file diff --git a/client/xtc.lua b/client/xtc.lua index 3c07415..63d017c 100644 --- a/client/xtc.lua +++ b/client/xtc.lua @@ -1,20 +1,26 @@ local xtcpress = false -local locations = ps.callback('md-drugs:server:GetXtcLocs') +local locations = GlobalState.MDDrugsLocations.XTC -local function getRecipeList(tbl) - local rec = {} - for m, d in pairs(tbl) do table.insert(rec, ps.getLabel(m) .. ' X ' .. d) end - return table.concat(rec, ', ') +local function getRecipeList(tbl, type) + local rec + if type == 'presses' then + rec = {'XTC FROM THE PREVIOUS TIER REQUIRED TO UPGRADE \n '} + else + rec = {'REQUIRED INGREDIENTS: \n '} + end + + for m, d in pairs(tbl) do table.insert(rec, Bridge.Inventory.GetItemInfo(m).label .. ' X ' .. d .. ' \n ') end + return table.concat(rec, ' ') end -ps.registerCallback('md-drugs:client:setpress', function(xtcData) +Bridge.Callback.Register('md-drugs:client:setpress', function(xtcData) if xtcpress then Bridge.Notify.SendNotify(Bridge.Language.Locale('xtc.alreadyOut'), 'error') return end local coords, head = StartRay2() xtcpress = true - if not ps.progressbar(Bridge.Language.Locale('xtc.settingDown'), 4000, 'uncuff') then return end + if not progressbar(Bridge.Language.Locale('xtc.settingDown'), 4000, 'uncuff') then return end local press = CreateObject("bkr_prop_coke_press_01aa", coords.x, coords.y, coords.z, true, false, false) PlaceObjectOnGroundProperly(press) Freeze(press, true, head) @@ -27,19 +33,24 @@ ps.registerCallback('md-drugs:client:setpress', function(xtcData) local options = {} for k, v in pairs(xtcData.recipes) do local descript = getRecipeList(v.take) + local itemInfo = Bridge.Inventory.GetItemInfo(k) options[#options + 1] = { - icon = ps.getImage(k), - title = ps.getLabel(k), + icon = itemInfo.image, + title = Bridge.Language.Locale(k), description = descript, - action = function() + onSelect = function() if not minigame() then Bridge.Notify.SendNotify(Bridge.Language.Locale('xtc.fail'), "error") return end - if not ps.progressbar(Bridge.Language.Locale('xtc.making', ps.getLabel(k)), 4000, 'uncuff') then return end + if not progressbar(Bridge.Language.Locale('xtc.making', Bridge.Language.Locale(k)), 4000, 'uncuff') then return end TriggerServerEvent("md-drugs:server:makextc", k) end, distance = 2.0 } end - ps.menu('XTC Recipes', 'XTC Recipes', options) + Bridge.Menu.Open({ + id = 'XTC Recipes', + title = 'XTC Recipes', + options = options + }) end, canInteract = function() if xtcpress then return true end @@ -49,7 +60,7 @@ ps.registerCallback('md-drugs:client:setpress', function(xtcData) icon = "fas fa-eye", label = Bridge.Language.Locale('xtc.targetPickup'), action = function() - if not ps.progressbar(Bridge.Language.Locale('xtc.picking'), 5000, 'uncuff') then return end + if not progressbar(Bridge.Language.Locale('xtc.picking'), 5000, 'uncuff') then return end DeleteObject(press) xtcpress = false TriggerServerEvent("md-drugs:server:getpressback") @@ -64,13 +75,13 @@ ps.registerCallback('md-drugs:client:setpress', function(xtcData) end) for k, v in pairs(locations.mdp2p) do - ps.boxTarget('mdp2p'..k, v.loc, {length = v.l, width = v.w, heading = v.rot}, { + Bridge.Target.AddBoxZone('mdp2p'..k, v.loc, vector3(v.l, v.w, 2.0), v.rot or 180.0, { { icon = 'fa-solid fa-flask', label = Bridge.Language.Locale('xtc.targetStealMDP2P'), action = function() if not minigame() then Bridge.Notify.SendNotify(Bridge.Language.Locale('xtc.fail'), "error") return end - if not ps.progressbar(Bridge.Language.Locale('xtc.stealingMDP2P'), 4000, 'uncuff') then return end + if not progressbar(Bridge.Language.Locale('xtc.stealingMDP2P'), 4000, 'uncuff') then return end TriggerServerEvent("md-drugs:server:stealmdp2p", k) end, canInteract = function() @@ -80,13 +91,13 @@ for k, v in pairs(locations.mdp2p) do }) end for k, v in pairs(locations.isosafrole) do - ps.boxTarget('isosafrole'..k, v.loc, {length = v.l, width = v.w, heading = v.rot}, { + Bridge.Target.AddBoxZone('isosafrole'..k, v.loc, vector3(v.l, v.w, 2.0), v.rot or 180.0, { { icon = 'fa-solid fa-flask', label = Bridge.Language.Locale('xtc.targetStealIsosafrole'), action = function() if not minigame() then Bridge.Notify.SendNotify(Bridge.Language.Locale('xtc.fail'), "error") return end - if not ps.progressbar(Bridge.Language.Locale('xtc.stealingIsosafrole'), 4000, 'uncuff') then return end + if not progressbar(Bridge.Language.Locale('xtc.stealingIsosafrole'), 4000, 'uncuff') then return end TriggerServerEvent("md-drugs:server:stealisosafrole", k) end, canInteract = function() @@ -97,13 +108,13 @@ for k, v in pairs(locations.isosafrole) do end for k, v in pairs(locations.rawxtcloc) do - ps.boxTarget('xtcraw'..k, v.loc, {length = v.l, width = v.w, heading = v.rot}, { + Bridge.Target.AddBoxZone('xtcraw'..k, v.loc, vector3(v.l, v.w, 2.0), v.rot or 180.0, { { icon = 'fa-solid fa-flask', label = Bridge.Language.Locale('xtc.targetRaw'), action = function() if not minigame() then Bridge.Notify.SendNotify(Bridge.Language.Locale('xtc.fail'), "error") return end - if not ps.progressbar(Bridge.Language.Locale('xtc.makingRaw'), 4000, 'uncuff') then return end + if not progressbar(Bridge.Language.Locale('xtc.makingRaw'), 4000, 'uncuff') then return end TriggerServerEvent("md-drugs:server:makingrawxtc", k) end, canInteract = function() @@ -121,30 +132,32 @@ for k, v in pairs(locations.xtcpress) do { icon = 'fa-solid fa-flask', label = Bridge.Language.Locale('xtc.getPress'), - action = function() + onSelect = function() local options = {} - local recipeList = ps.callback('md-drugs:server:getpressrecipes') + local recipeList = GlobalState.MDDrugsRecipes.XTC.presses for m, d in pairs(recipeList) do if m == 'singlepress' then + local itemInfo = Bridge.Inventory.GetItemInfo(m) options[#options + 1] = { - icon = ps.getImage(m), - title = ps.getLabel(m), + icon = itemInfo.image, + title = itemInfo.label, description = Bridge.Language.Locale('xtc.buySingle', d.cash), type = d.type, - action = function() - if not ps.progressbar(Bridge.Language.Locale('xtc.buyp'), 4000, 'uncuff') then return end + onSelect = function() + if not progressbar(Bridge.Language.Locale('xtc.buyp'), 4000, 'uncuff') then return end TriggerServerEvent('md-drugs:server:buypress',k, m) end, } else - local descript = getRecipeList(d.take) + local itemInfo = Bridge.Inventory.GetItemInfo(m) + local descript = getRecipeList(d.take, 'presses') options[#options + 1] = { - icon = ps.getImage(m), - title = ps.getLabel(m), + icon = itemInfo.image, + title = itemInfo.label, description = descript, type = d.type, - action = function() - if not ps.progressbar(Bridge.Language.Locale('xtc.buyp'), 4000, 'uncuff') then return end + onSelect = function() + if not progressbar(Bridge.Language.Locale('xtc.buyp'), 4000, 'uncuff') then return end TriggerServerEvent("md-drugs:server:upgradepress", k, m) end, distance = 2.0 @@ -152,7 +165,11 @@ for k, v in pairs(locations.xtcpress) do end end table.sort(options, function(a, b) return a.type < b.type end) - ps.menu('XTC Presses', 'XTC Presses', options) + Bridge.Menu.Open({ + id = 'XTC Presses', + title = 'XTC Presses', + options = options + }) end, canInteract = function() return handleGang(v.gang) end } @@ -160,32 +177,36 @@ for k, v in pairs(locations.xtcpress) do end for k, v in pairs (locations.stamp) do - ps.boxTarget('xtcstamp'..k, v.loc, {length = v.l, width = v.w, heading = v.rot}, { + Bridge.Target.AddBoxZone('xtcstamp'..k, v.loc, vector3(v.l, v.w, 2.0), v.rot or 180.0, { { icon = 'fa-solid fa-flask', label = Bridge.Language.Locale('xtc.targetStamp'), - action = function() + onSelect = function() local item = { - {item = 'white_xtc', label = ps.getLabel('white_xtc'), color = 'white'}, - {item = 'red_xtc', label = ps.getLabel('red_xtc'), color = 'red'}, - {item = 'orange_xtc', label = ps.getLabel('orange_xtc'), color = 'orange'}, - {item = 'blue_xtc', label = ps.getLabel('blue_xtc'), color = 'blue'}, + {item = 'white_xtc', label = Bridge.Inventory.GetItemInfo('white_xtc').label, color = 'white'}, + {item = 'red_xtc', label = Bridge.Inventory.GetItemInfo('red_xtc').label, color = 'red'}, + {item = 'orange_xtc', label = Bridge.Inventory.GetItemInfo('orange_xtc').label, color = 'orange'}, + {item = 'blue_xtc', label = Bridge.Inventory.GetItemInfo('blue_xtc').label, color = 'blue'}, } local options = {} for m, d in pairs (item) do options[#options + 1] = { - icon = ps.getImage(d.item), + icon = Bridge.Inventory.GetItemInfo(d.item).image, title = d.label, description = Bridge.Language.Locale('xtc.stamp_desc', d.color), action = function() if not minigame() then Bridge.Notify.SendNotify(Bridge.Language.Locale('xtc.fail'), "error") return end - if not ps.progressbar(Bridge.Language.Locale('xtc.stamping', d.label), 4000, 'uncuff') then return end + if not progressbar(Bridge.Language.Locale('xtc.stamping', d.label), 4000, 'uncuff') then return end TriggerServerEvent("md-drugs:server:stamp", k, d.color) end, distance = 2.0 } end - ps.menu('Stamp Pills', 'Stamp Pills', options) + Bridge.Menu.Open({ + id = 'XTC Stamp', + title = 'XTC Stamp', + options = options + }) end, canInteract = function() return handleGang(v.gang) end } diff --git a/clientRun.lua b/clientRun.lua index 31c4e46..e88b1a4 100644 --- a/clientRun.lua +++ b/clientRun.lua @@ -2,18 +2,18 @@ function loadFile(filePath) local resourceName = 'md-drugs' local fullScript = LoadResourceFile(resourceName, filePath) if not fullScript then - ps.error("Error: Failed to load module '" .. filePath .. "' from resource '" .. resourceName .. "'.") + Bridge.Prints.Error("Error: Failed to load module '" .. filePath .. "' from resource '" .. resourceName .. "'.") return false end local chunk, err = load(fullScript, filePath, "t") if not chunk then - ps.error("Error loading Lua chunk from '" .. filePath .. "': " .. tostring(err)) + Bridge.Prints.Error("Error loading Lua chunk from '" .. filePath .. "': " .. tostring(err)) return false end local success, execErr = pcall(chunk) if not success then - ps.error("Error executing Lua chunk from '" .. filePath .. "': " .. tostring(execErr)) + Bridge.Prints.Error("Error executing Lua chunk from '" .. filePath .. "': " .. tostring(execErr)) return false end diff --git a/server/deliveries.lua b/server/deliveries.lua index c0faf40..714338a 100644 --- a/server/deliveries.lua +++ b/server/deliveries.lua @@ -1,261 +1,261 @@ -Locations = Locations or {} - -local dloc = { - {coords = vector4(282.48, -1814.32, 27.23, 145.11)}, - {coords = vector4(-296.11, -1300.65, 31.31, 270.87)}, - {coords = vector4(-36.64, -1492.04, 31.22, 151.91)}, - {coords = vector4(282.48, -1814.32, 27.23, 232.19)}, - {coords = vector4(54.54, -1873.22, 22.81, 131.47)}, - {coords = vector4(-269.34, -2437.25, 6.40, 252.67)}, - {coords = vector4(269.19, -3248.55, 5.79, 252.67)}, - {coords = vector4(632.94, -3015.44, 7.34, 3.44)}, - {coords = vector4(1049.55, -2427.88, 30.30, 79.52)}, - {coords = vector4(853.16, -2207.32, 30.68, 284.88)}, - {coords = vector4(903.10, -1721.98, 32.25, 168.71)}, - {coords = vector4(1289.30, -1710.49, 55.48, 208.57)}, - {coords = vector4(1412.01, -1490.53, 60.66, 132.46)}, - {coords = vector4(734.26, -1311.26, 27.01, 102.99)}, - {coords = vector4(1231.60, -1083.06, 38.53, 102.99)}, - {coords = vector4(1143.55, -1000.19, 45.32, 257.05)}, - {coords = vector4(1264.82, -702.87, 64.72, 257.05)}, - {coords = vector4(1119.65, -639.76, 56.81, 284.53)}, - {coords = vector4(1129.59, -462.59, 66.49, 79.23)}, - {coords = vector4(42.80, -811.45, 31.43, 79.23)}, - {coords = vector4(-509.48, -1001.66, 23.55, 79.23)}, - {coords = vector4(-830.97, -862.41, 20.69, 13.72)}, - {coords = vector4(-1320.26, -1177.34, 4.89, 74.29)}, - {coords = vector4(-1097.63, -1673.24, 8.40, 136.51)}, - {coords = vector4(-1147.61, -1452.10, 4.60, 51.50)}, - {coords = vector4(-1241.69, -1208.39, 8.52, 107.56)}, - {coords = vector4(-1876.92, -584.44, 11.85, 329.54)}, - {coords = vector4(-1303.94, -441.39, 35.22, 128.73)}, - {coords = vector4(-1705.48, -433.46, 42.17, 128.73)}, - {coords = vector4(-1305.99, 336.35, 65.50, 35.13)}, - {coords = vector4(-741.80, 484.84, 109.47, 110.85)}, - {coords = vector4(-409.57, 341.49, 108.91, 270.45)}, - {coords = vector4(-126.44, 588.18, 204.71, 8.12)}, - {coords = vector4(211.42, -101.42, 73.28, 174.10)}, - {coords = vector4(490.61, -95.04, 66.44, 273.57)}, - {coords = vector4(387.19, -993.59, 29.42, 273.57)}, - {coords = vector4(-500.47, -712.37, 33.21, 273.57)}, - {coords = vector4(2572.20, 479.97, 108.68, 80.27)}, - {coords = vector4(-430.10, 1205.41, 325.76, 169.25)}, - {coords = vector4(-126.06, 1896.58, 197.33, 169.25)}, - {coords = vector4(-2521.08, 2310.31, 33.22, 276.87)}, - {coords = vector4(1129.01, 2125.14, 55.55, 276.87)}, - {coords = vector4(1546.64, 2166.56, 78.72, 100.37)}, - {coords = vector4(404.34, 2584.54, 43.52, 100.37)}, - {coords = vector4(180.15, 2792.99, 45.66, 283.04)}, - {coords = vector4(287.67, 2843.89, 44.70, 118.41)}, - {coords = vector4(2030.23, 3184.42, 45.13, 146.06)}, - {coords = vector4(2175.33, 3321.92, 46.13, 214.53)}, - {coords = vector4(2389.61, 3340.98, 47.34, 214.52)}, - {coords = vector4(1716.25, 3295.08, 41.26, 196.21)}, - {coords = vector4(1779.38, 3640.83, 34.50, 24.16)}, - {coords = vector4(1894.59, 3715.34, 32.75, 127.89)}, - {coords = vector4(1861.90, 3857.15, 36.27, 293.45)}, - {coords = vector4(996.38, 3575.07, 34.61, 328.30)}, - {coords = vector4(387.45, 3584.73, 33.29, 351.41)}, - {coords = vector4(68.08, 3693.22, 40.66, 63.98)}, - {coords = vector4(15.55, 3688.70, 39.81, 230.89)}, - {coords = vector4(2566.59, 4283.34, 41.97, 348.53)}, - {coords = vector4(2570.82, 4667.95, 34.08, 135.30)}, - {coords = vector4(2882.05, 4511.72, 48.02, 66.58)}, - {coords = vector4(2243.78, 5154.02, 57.89, 139.42)}, - {coords = vector4(1642.91, 4846.08, 45.51, 109.83)}, - {coords = vector4(1308.87, 4362.17, 41.55, 256.01)}, - {coords = vector4(-1090.27, 4940.57, 214.13, 256.01)}, - {coords = vector4(-552.37, 5348.37, 74.76, 62.18)}, - {coords = vector4(-679.02, 5834.27, 17.33, 137.18)}, - {coords = vector4(-481.97, 6276.93, 13.35, 323.16)}, - {coords = vector4(-24.92, 6472.60, 31.49, 144.42)}, - {coords = vector4(36.03, 6549.18, 31.43, 287.85)}, - {coords = vector4(406.08, 6526.43, 27.75, 97.45)}, - {coords = vector4(1522.39, 6329.23, 24.61, 331.71)}, - {coords = vector4(1741.39, 6419.62, 35.04, 331.71)}, - {coords = vector4(3426.72, 5174.42, 7.40, 112.64)}, - {coords = vector4(2525.99, 2586.62, 38.94, 257.02)}, - {coords = vector4(2696.29, 1664.44, 24.52, 70.12)}, - {coords = vector4(106.24, -1280.32, 29.24, 350.89)}, - {coords = vector4(223.98, 121.53, 102.76, 259.68)}, - {coords = vector4(102.19, -255.02, 50.05, 83.59)}, -} -local Products = { - {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}, -} - -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, 'md-drugs:server:dealerList') then - return - end - return Products -end) - -local DeliveryItems = { - { item = "weed_brick", minrep = 0, payout = {min = 10, max = 50}}, - { item = "coke_brick", minrep = 0, payout = {min = 10, max = 50}}, -} - -Bridge.Callback.Register('md-drugs:server:GetDeliveryItem', function(source, data) - local src = source - 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 = ?', {Bridge.Framework.GetPlayerIdentifier(src)}) - local locnum = math.random(1, #dloc) - local coord = json.encode({ - x = dloc[locnum].coords.x, - y = dloc[locnum].coords.y, - z = dloc[locnum].coords.z , - w = dloc[locnum].coords.w - }) - if not check[1] then - MySQL.insert('INSERT INTO deliveriesdealer SET cid = ?, itemdata = ?, timestart = ?, maxtime = ?, location = ?', - {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, - amount = amount, - coords = coord - } - return tab - else - local time = os.time() - local timeout = math.floor(os.difftime(time, check[1].maxtime) / 60) - - if timeout > 15 then - 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 - Bridge.Notify.SendNotify(src,Bridge.Language.Locale('Deliveries.alreadyDelivering'), 'error' ) - local tab = { - bool = false, - item = item, - amount = amount, - coords = coord - } - return tab - end -end) - -RegisterNetEvent('md-drugs:server:giveDeliveryItems', function(item, amount) - local src = source - 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 = ?', {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 - local coords = json.decode(check[1].location) - coords = vector3(coords.x, coords.y, coords.z) - if not checkDistance(src, coords, 5.0, 'md-drugs:server:giveDeliveryItems') 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) - Bridge.Framework.AddAccountBalance(src, 'cash', income) - AddRep(src, 'dealerrep') - end - end - MySQL.query.await('DELETE FROM deliveriesdealer WHERE cid = ?', {id}) - end -end) --- TODO: COmmands -ps.registerCommand("newdealer", { - help = Bridge.Language.Locale('Deliveries.newDealerHelp.help'), - description = { - { 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) - local ped = GetPlayerPed(source) - local coords = GetEntityCoords(ped) - local Player = ps.getPlayer(source) - if not Player then return end - - local dealerName = args[1] - local pos = json.encode({x = coords.x, y = coords.y, z = coords.z}) - - local result = MySQL.scalar.await('SELECT name FROM dealers WHERE name = ?', { dealerName }) - if result then - 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', 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 = Bridge.Language.Locale('Deliveries.deleteDealerHelp.help'), - description = { - { name = "name", help = Bridge.Language.Locale('Deliveries.deleteDealerHelp.name'), type = "string" } - }, - admin = true -}, function(source, args) - local dealerName = args.name - local result = MySQL.scalar.await('SELECT * FROM dealers WHERE name = ?', { dealerName }) - - if result and result[1] then - MySQL.query('DELETE FROM dealers WHERE name = ?', { dealerName }) - 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 - Bridge.Notify.SendNotify(source, Bridge.Language.Locale('Deliveries.deleteDealerFail'), "error") - end -end) - - -RegisterNetEvent('md-drugs:server:buyItemDealer', function(num, loc) - local src = source - local itemData = Products[num] - if not itemData then return end - local coords = json.decode(Dealers[loc].coords) - coords = vector3(coords.x, coords.y, coords.z) - if not checkDistance(src, coords, 5.0, 'md-drugs:server:buyItemDealer') then - return - 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, Bridge.Inventory.GetItemInfo(itemData.name).label, 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 \ No newline at end of file +--Locations = Locations or {} +-- +--local dloc = { +-- {coords = vector4(282.48, -1814.32, 27.23, 145.11)}, +-- {coords = vector4(-296.11, -1300.65, 31.31, 270.87)}, +-- {coords = vector4(-36.64, -1492.04, 31.22, 151.91)}, +-- {coords = vector4(282.48, -1814.32, 27.23, 232.19)}, +-- {coords = vector4(54.54, -1873.22, 22.81, 131.47)}, +-- {coords = vector4(-269.34, -2437.25, 6.40, 252.67)}, +-- {coords = vector4(269.19, -3248.55, 5.79, 252.67)}, +-- {coords = vector4(632.94, -3015.44, 7.34, 3.44)}, +-- {coords = vector4(1049.55, -2427.88, 30.30, 79.52)}, +-- {coords = vector4(853.16, -2207.32, 30.68, 284.88)}, +-- {coords = vector4(903.10, -1721.98, 32.25, 168.71)}, +-- {coords = vector4(1289.30, -1710.49, 55.48, 208.57)}, +-- {coords = vector4(1412.01, -1490.53, 60.66, 132.46)}, +-- {coords = vector4(734.26, -1311.26, 27.01, 102.99)}, +-- {coords = vector4(1231.60, -1083.06, 38.53, 102.99)}, +-- {coords = vector4(1143.55, -1000.19, 45.32, 257.05)}, +-- {coords = vector4(1264.82, -702.87, 64.72, 257.05)}, +-- {coords = vector4(1119.65, -639.76, 56.81, 284.53)}, +-- {coords = vector4(1129.59, -462.59, 66.49, 79.23)}, +-- {coords = vector4(42.80, -811.45, 31.43, 79.23)}, +-- {coords = vector4(-509.48, -1001.66, 23.55, 79.23)}, +-- {coords = vector4(-830.97, -862.41, 20.69, 13.72)}, +-- {coords = vector4(-1320.26, -1177.34, 4.89, 74.29)}, +-- {coords = vector4(-1097.63, -1673.24, 8.40, 136.51)}, +-- {coords = vector4(-1147.61, -1452.10, 4.60, 51.50)}, +-- {coords = vector4(-1241.69, -1208.39, 8.52, 107.56)}, +-- {coords = vector4(-1876.92, -584.44, 11.85, 329.54)}, +-- {coords = vector4(-1303.94, -441.39, 35.22, 128.73)}, +-- {coords = vector4(-1705.48, -433.46, 42.17, 128.73)}, +-- {coords = vector4(-1305.99, 336.35, 65.50, 35.13)}, +-- {coords = vector4(-741.80, 484.84, 109.47, 110.85)}, +-- {coords = vector4(-409.57, 341.49, 108.91, 270.45)}, +-- {coords = vector4(-126.44, 588.18, 204.71, 8.12)}, +-- {coords = vector4(211.42, -101.42, 73.28, 174.10)}, +-- {coords = vector4(490.61, -95.04, 66.44, 273.57)}, +-- {coords = vector4(387.19, -993.59, 29.42, 273.57)}, +-- {coords = vector4(-500.47, -712.37, 33.21, 273.57)}, +-- {coords = vector4(2572.20, 479.97, 108.68, 80.27)}, +-- {coords = vector4(-430.10, 1205.41, 325.76, 169.25)}, +-- {coords = vector4(-126.06, 1896.58, 197.33, 169.25)}, +-- {coords = vector4(-2521.08, 2310.31, 33.22, 276.87)}, +-- {coords = vector4(1129.01, 2125.14, 55.55, 276.87)}, +-- {coords = vector4(1546.64, 2166.56, 78.72, 100.37)}, +-- {coords = vector4(404.34, 2584.54, 43.52, 100.37)}, +-- {coords = vector4(180.15, 2792.99, 45.66, 283.04)}, +-- {coords = vector4(287.67, 2843.89, 44.70, 118.41)}, +-- {coords = vector4(2030.23, 3184.42, 45.13, 146.06)}, +-- {coords = vector4(2175.33, 3321.92, 46.13, 214.53)}, +-- {coords = vector4(2389.61, 3340.98, 47.34, 214.52)}, +-- {coords = vector4(1716.25, 3295.08, 41.26, 196.21)}, +-- {coords = vector4(1779.38, 3640.83, 34.50, 24.16)}, +-- {coords = vector4(1894.59, 3715.34, 32.75, 127.89)}, +-- {coords = vector4(1861.90, 3857.15, 36.27, 293.45)}, +-- {coords = vector4(996.38, 3575.07, 34.61, 328.30)}, +-- {coords = vector4(387.45, 3584.73, 33.29, 351.41)}, +-- {coords = vector4(68.08, 3693.22, 40.66, 63.98)}, +-- {coords = vector4(15.55, 3688.70, 39.81, 230.89)}, +-- {coords = vector4(2566.59, 4283.34, 41.97, 348.53)}, +-- {coords = vector4(2570.82, 4667.95, 34.08, 135.30)}, +-- {coords = vector4(2882.05, 4511.72, 48.02, 66.58)}, +-- {coords = vector4(2243.78, 5154.02, 57.89, 139.42)}, +-- {coords = vector4(1642.91, 4846.08, 45.51, 109.83)}, +-- {coords = vector4(1308.87, 4362.17, 41.55, 256.01)}, +-- {coords = vector4(-1090.27, 4940.57, 214.13, 256.01)}, +-- {coords = vector4(-552.37, 5348.37, 74.76, 62.18)}, +-- {coords = vector4(-679.02, 5834.27, 17.33, 137.18)}, +-- {coords = vector4(-481.97, 6276.93, 13.35, 323.16)}, +-- {coords = vector4(-24.92, 6472.60, 31.49, 144.42)}, +-- {coords = vector4(36.03, 6549.18, 31.43, 287.85)}, +-- {coords = vector4(406.08, 6526.43, 27.75, 97.45)}, +-- {coords = vector4(1522.39, 6329.23, 24.61, 331.71)}, +-- {coords = vector4(1741.39, 6419.62, 35.04, 331.71)}, +-- {coords = vector4(3426.72, 5174.42, 7.40, 112.64)}, +-- {coords = vector4(2525.99, 2586.62, 38.94, 257.02)}, +-- {coords = vector4(2696.29, 1664.44, 24.52, 70.12)}, +-- {coords = vector4(106.24, -1280.32, 29.24, 350.89)}, +-- {coords = vector4(223.98, 121.53, 102.76, 259.68)}, +-- {coords = vector4(102.19, -255.02, 50.05, 83.59)}, +--} +--local Products = { +-- {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}, +--} +-- +--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, 'md-drugs:server:dealerList') then +-- return +-- end +-- return Products +--end) +-- +--local DeliveryItems = { +-- { item = "weed_brick", minrep = 0, payout = {min = 10, max = 50}}, +-- { item = "coke_brick", minrep = 0, payout = {min = 10, max = 50}}, +--} +-- +--Bridge.Callback.Register('md-drugs:server:GetDeliveryItem', function(source, data) +-- local src = source +-- 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 = ?', {Bridge.Framework.GetPlayerIdentifier(src)}) +-- local locnum = math.random(1, #dloc) +-- local coord = json.encode({ +-- x = dloc[locnum].coords.x, +-- y = dloc[locnum].coords.y, +-- z = dloc[locnum].coords.z , +-- w = dloc[locnum].coords.w +-- }) +-- if not check[1] then +-- MySQL.insert('INSERT INTO deliveriesdealer SET cid = ?, itemdata = ?, timestart = ?, maxtime = ?, location = ?', +-- {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, +-- amount = amount, +-- coords = coord +-- } +-- return tab +-- else +-- local time = os.time() +-- local timeout = math.floor(os.difftime(time, check[1].maxtime) / 60) +-- +-- if timeout > 15 then +-- 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 +-- Bridge.Notify.SendNotify(src,Bridge.Language.Locale('Deliveries.alreadyDelivering'), 'error' ) +-- local tab = { +-- bool = false, +-- item = item, +-- amount = amount, +-- coords = coord +-- } +-- return tab +-- end +--end) +-- +--RegisterNetEvent('md-drugs:server:giveDeliveryItems', function(item, amount) +-- local src = source +-- 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 = ?', {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 +-- local coords = json.decode(check[1].location) +-- coords = vector3(coords.x, coords.y, coords.z) +-- if not checkDistance(src, coords, 5.0, 'md-drugs:server:giveDeliveryItems') 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) +-- Bridge.Framework.AddAccountBalance(src, 'cash', income) +-- AddRep(src, 'dealerrep') +-- end +-- end +-- MySQL.query.await('DELETE FROM deliveriesdealer WHERE cid = ?', {id}) +-- end +--end) +---- TODO: COmmands +--ps.registerCommand("newdealer", { +-- help = Bridge.Language.Locale('Deliveries.newDealerHelp.help'), +-- description = { +-- { 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) +-- local ped = GetPlayerPed(source) +-- local coords = GetEntityCoords(ped) +-- local Player = ps.getPlayer(source) +-- if not Player then return end +-- +-- local dealerName = args[1] +-- local pos = json.encode({x = coords.x, y = coords.y, z = coords.z}) +-- +-- local result = MySQL.scalar.await('SELECT name FROM dealers WHERE name = ?', { dealerName }) +-- if result then +-- 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', 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 = Bridge.Language.Locale('Deliveries.deleteDealerHelp.help'), +-- description = { +-- { name = "name", help = Bridge.Language.Locale('Deliveries.deleteDealerHelp.name'), type = "string" } +-- }, +-- admin = true +--}, function(source, args) +-- local dealerName = args.name +-- local result = MySQL.scalar.await('SELECT * FROM dealers WHERE name = ?', { dealerName }) +-- +-- if result and result[1] then +-- MySQL.query('DELETE FROM dealers WHERE name = ?', { dealerName }) +-- 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 +-- Bridge.Notify.SendNotify(source, Bridge.Language.Locale('Deliveries.deleteDealerFail'), "error") +-- end +--end) +-- +-- +--RegisterNetEvent('md-drugs:server:buyItemDealer', function(num, loc) +-- local src = source +-- local itemData = Products[num] +-- if not itemData then return end +-- local coords = json.decode(Dealers[loc].coords) +-- coords = vector3(coords.x, coords.y, coords.z) +-- if not checkDistance(src, coords, 5.0, 'md-drugs:server:buyItemDealer') then +-- return +-- 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, Bridge.Inventory.GetItemInfo(itemData.name).label, 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 \ No newline at end of file diff --git a/server/functions.lua b/server/functions.lua index 38b5605..715d6c4 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -1,22 +1,40 @@ local timeOutPlayers = {} local playerRep = {} +local playerWarnings = {} +local trollExploiters = true +local function trollPlayer(src) + if not trollExploiters then return end + CreateThread(function() + local playerPed = GetPlayerPed(src) + SetEntityCoords(playerPed, -3432.36, -6000.42, -2.0, false, false, false, true) + Wait(30000) + SetEntityCoords(playerPed, -1392.98, -2599.29, 2419.18, false, false, false, true) + Wait(50000) + DropPlayer(src, 'You have been caught trying to exploit md-drugs, get rekted.') + end) +end + function checkDistance(src, coords, dist, event) local pcoords = GetEntityCoords(GetPlayerPed(src)) coords = vector3(coords.x, coords.y, coords.z) if #(pcoords - coords) > dist then Bridge.Prints.Warn(Bridge.Language.Locale('Catches.outOfRangeWarn', Bridge.Framework.GetPlayerIdentifier(src), event)) + playerWarnings[src] = (playerWarnings[src] or 0) + 1 + if playerWarnings[src] >= 5 then + trollPlayer(src) + end return false end return true end local function timeOutThread(src) - local id = Bridge.Framework.GetPlayerIdentifier(src) + src = tonumber(src) CreateThread(function() - timeOutPlayers[id] = true + timeOutPlayers[src] = true Wait(3000) - timeOutPlayers[id] = nil + timeOutPlayers[src] = nil end) end @@ -24,6 +42,10 @@ function timeOut(src, event) if timeOutPlayers[src] then local first, last = Bridge.Framework.GetPlayerName(src) Bridge.Prints.Warn(Bridge.Language.Locale('Catches.onCooldownWarn', first .. ' ' .. last, event)) + playerWarnings[src] = (playerWarnings[src] or 0) + 1 + if playerWarnings[src] >= 5 then + trollPlayer(src) + end return true end timeOutThread(src) diff --git a/server/wholesale.lua b/server/wholesale.lua index 28a25f9..76274b8 100644 --- a/server/wholesale.lua +++ b/server/wholesale.lua @@ -1,197 +1,197 @@ - -local burners = { - cokeburner = { "cokebaggy", "cokebaggystagethree", "cokebaggystagetwo"}, - crackburner = {"baggedcracked", "baggedcrackedstagetwo", "baggedcrackedstagethree"}, - lsdburner = {'smiley_tabs', 'yinyang_tabs', 'wildcherry_tabs', 'pineapple_tabs', 'bart_tabs', 'gratefuldead_tabs'}, - heroinburner = {'heroin_ready', 'heroin_readystagetwo', 'heroin_readystagethree'}, - xtcburner = {"white_playboys", "white_playboys2", "white_playboys3", "white_playboys4", "blue_playboys", "blue_playboys2", "blue_playboys3", "blue_playboys4", "red_playboys", "red_playboys2", "red_playboys3", "red_playboys4", "orange_playboys", "orange_playboy2s", "orange_playboys3", "orange_playboys4", "white_aliens", "white_aliens2", "white_aliens3", "white_aliens4", "blue_aliens", "blue_aliens2", "blue_aliens3", "blue_aliens4", "red_aliens", "red_aliens3", "red_aliens2", "red_aliens4", "orange_aliens", "orange_aliens2", "orange_aliens3", "orange_aliens4", "white_pl", "white_pl2", "white_pl3", "white_pl4", "blue_pl", "blue_pl2", "blue_pl3", "blue_pl4", "red_pl", "red_pl2", "red_pl3", "red_pl4", "orange_pl", "orange_pl2", "orange_pl3", "orange_pl4", "white_trolls", "white_trolls2", "white_trolls3", "white_trolls4", "blue_trolls", "blue_trolls2", "blue_trolls3", "blue_trolls4", "red_trolls", "red_trolls2", "red_trolls3", "red_trolls4", "orange_trolls", "orange_trolls2", "orange_trolls3", "orange_trolls4", "white_cats2", "white_cats3", "white_cats4", "white_cats", "blue_cats", "blue_cats3", "blue_cats2", "blue_cats4", "red_cats", "red_cats2", "red_cats3", "red_cats4", "orange_cats", "orange_cats2", "orange_cats3", "orange_cats4" }, - methburner = {'methbaggy'}, -} -local active = {} -local settings = {} - -settings.WholesaleQuantityBonus = 0.05 -- 5% bonus per 10 units sold (up to 20%) -settings.WholesaleMaxBonus = 0.20 -- Maximum 20% bonus -settings.WholesaleMinQuantity = 1 -- Minimum quantity required for wholesale -settings.WholesaleAmbushEnabled = true -- Enable or disable ambush on failed deals -settings.WholesaleAmbushBase = 2 -- Base number of attackers on failed deals -settings.WholesaleAmbushScale = true -- Scale number of attackers based on drug quantity -settings.WholesaleAmbushTier1 = 10 -- Drug quantity threshold for 3 attackers -settings.WholesaleAmbushTier2 = 20 -- Drug quantity threshold for 4 attackers -settings.WholesaleAmbushTier3 = 30 -- Drug quantity threshold for 5 attackers -settings.WholesaleWeaponTiers = true -- Scale weapon difficulty based on drug quantity -settings.WholesaleWeaponsTier1 = { -- Basic weapons (default) - "WEAPON_PISTOL", - "WEAPON_BAT", - "WEAPON_KNIFE", - "WEAPON_MACHETE" -} -settings.WholesaleWeaponsTier2 = { -- Medium weapons (10+ drugs) - "WEAPON_COMBATPISTOL", - "WEAPON_MICROSMG", - "WEAPON_SAWNOFFSHOTGUN", - "WEAPON_CROWBAR" -} -settings.WholesaleWeaponsTier3 = { -- Advanced weapons (20+ drugs) - "WEAPON_APPISTOL", - "WEAPON_SMG", - "WEAPON_PUMPSHOTGUN", - "WEAPON_CARBINERIFLE" -} -settings.WholesaleWeaponsTier4 = { -- Elite weapons (30+ drugs) - "WEAPON_HEAVYPISTOL", - "WEAPON_ASSAULTSMG", - "WEAPON_ASSAULTSHOTGUN", - "WEAPON_SPECIALCARBINE" -} -settings.WholesaleShowEstimates = true -- Show estimated value before deal -settings.WholesaleFailPoliceAlert = 75 -- Chance to alert police on failed deals (0-100) -settings.WholesaleResetOnTimeout = true -- Reset wholesale flag when buyer times out -settings.SuccessfulChance = 90 --- this is the chance of a Success wholesale 1-100 -settings.AlertPoliceWholesale = 90 -- 1-100 of how often it will alert police -settings.WholesaleTimeout = 600 -- time in seconds to get to the location -settings.PoliceCount = 0 - -local Price = { - cokeburner = { - min = 25, - max = 50 - }, - crackburner = { - min = 25, - max = 50 - }, - lsdburner = { - min = 25, - max = 50 - }, - heroinburner = { - min = 25, - max = 50 - }, - xtcburner = { - min = 25, - max = 50 - }, - methburner = { - min = 25, - max = 50 - } -} -local locs = { - vector4(-2352.32, 266.78, 165.3, 23.46), - vector4(-1467.49, 874.01, 183.59, 298.45), - vector4(-856.71, 874.26, 202.85, 205.3), - vector4(950.58, -128.49, 74.42, 205.3), - vector4(1152.71, -328.43, 69.21, 205.3), - vector4(112.66, -1955.67, 20.75, 37.94), - vector4(-544.4, -1684.8, 19.89, 252.07), - vector4(-1185.02, -1805.4, 3.91, 184.83), - vector4(-1641.4, -981.99, 7.58, 35.38), - vector4(-1827.93, 782.36, 138.29, 219.99), - vector4(-320.84, 2818.73, 59.45, 337.22), - vector4(474.88, 2609.56, 44.48, 357.0), -} - -ps.registerCallback('md-drugs:server:GetWSsettings', function(source) - return settings -end) - -function getRandW(source) - local rand = math.random(1, #locs) - return locs[rand] -end - -for k, v in pairs (burners) do - ps.createUseable(k, function(source, item) - if active[ps.getIdentifier(source)] then - TriggerClientEvent("md-drugs:client:GetLocation", active[ps.getIdentifier(source)].src, active[ps.getIdentifier(source)]) - return - 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 - local amt = ps.getItemCount(source, d) or 0 - if amt > 0 then - drugs[d] = (drugs[d] or 0) + amt - count = count + amt - end - end - if count < settings.WholesaleMinQuantity then - ps.addItem(source, k, 1) - 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)] = { - src = source, - item = k, - location = getRandW(source), - price = Price[k], - count = count, - drugs = drugs - } - TriggerClientEvent("md-drugs:client:GetLocation", active[ps.getIdentifier(source)].src, active[ps.getIdentifier(source)]) - end - end) -end - -local function getBonus(quantity) - local bonus = math.floor(quantity / 10) * settings.WholesaleQuantityBonus - if bonus > settings.WholesaleMaxBonus then - bonus = settings.WholesaleMaxBonus - end - return bonus -end -RegisterNetEvent('md-drugs:server:SuccessSale', function() - local src = source - local id = ps.getIdentifier(source) - - if not active[id] then - return - end - local deal = active[id] - if deal.count < settings.WholesaleMinQuantity then - Bridge.Notify.SendNotify(src, 'Not enough drugs for wholesale deal', 'error') - active[id] = nil - return - end - local basePrice = math.floor(((deal.price.min + deal.price.max) / 2) * deal.count) - local bonus = getBonus(deal.count) - local finalPrice = math.floor(basePrice + (basePrice * bonus)) - local need, have = 0,0 - for k, v in pairs (deal.drugs) do - need = need + 1 - if ps.hasItem(src, k, v) then - have = have + 1 - end - end - if need ~= have then - Bridge.Notify.SendNotify(src, 'You are missing some drugs for the deal', 'error') - active[id] = nil - return - end - local removed = true - for k, v in pairs (deal.drugs) do - if not ps.removeItem(src, k, v) then - removed = false - break - end - end - if not removed then - 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) - Bridge.Notify.SendNotify(src, 'Wholesale sale successful' .. ' $' .. finalPrice, 'success') - active[id] = nil -end) - -RegisterNetEvent('md-drugs:server:CleanupWholesale', function() - local src = source - local id = ps.getIdentifier(source) - if active[id] then - active[id] = nil - end -end) \ No newline at end of file +-- +--local burners = { +-- cokeburner = { "cokebaggy", "cokebaggystagethree", "cokebaggystagetwo"}, +-- crackburner = {"baggedcracked", "baggedcrackedstagetwo", "baggedcrackedstagethree"}, +-- lsdburner = {'smiley_tabs', 'yinyang_tabs', 'wildcherry_tabs', 'pineapple_tabs', 'bart_tabs', 'gratefuldead_tabs'}, +-- heroinburner = {'heroin_ready', 'heroin_readystagetwo', 'heroin_readystagethree'}, +-- xtcburner = {"white_playboys", "white_playboys2", "white_playboys3", "white_playboys4", "blue_playboys", "blue_playboys2", "blue_playboys3", "blue_playboys4", "red_playboys", "red_playboys2", "red_playboys3", "red_playboys4", "orange_playboys", "orange_playboy2s", "orange_playboys3", "orange_playboys4", "white_aliens", "white_aliens2", "white_aliens3", "white_aliens4", "blue_aliens", "blue_aliens2", "blue_aliens3", "blue_aliens4", "red_aliens", "red_aliens3", "red_aliens2", "red_aliens4", "orange_aliens", "orange_aliens2", "orange_aliens3", "orange_aliens4", "white_pl", "white_pl2", "white_pl3", "white_pl4", "blue_pl", "blue_pl2", "blue_pl3", "blue_pl4", "red_pl", "red_pl2", "red_pl3", "red_pl4", "orange_pl", "orange_pl2", "orange_pl3", "orange_pl4", "white_trolls", "white_trolls2", "white_trolls3", "white_trolls4", "blue_trolls", "blue_trolls2", "blue_trolls3", "blue_trolls4", "red_trolls", "red_trolls2", "red_trolls3", "red_trolls4", "orange_trolls", "orange_trolls2", "orange_trolls3", "orange_trolls4", "white_cats2", "white_cats3", "white_cats4", "white_cats", "blue_cats", "blue_cats3", "blue_cats2", "blue_cats4", "red_cats", "red_cats2", "red_cats3", "red_cats4", "orange_cats", "orange_cats2", "orange_cats3", "orange_cats4" }, +-- methburner = {'methbaggy'}, +--} +--local active = {} +--local settings = {} +-- +--settings.WholesaleQuantityBonus = 0.05 -- 5% bonus per 10 units sold (up to 20%) +--settings.WholesaleMaxBonus = 0.20 -- Maximum 20% bonus +--settings.WholesaleMinQuantity = 1 -- Minimum quantity required for wholesale +--settings.WholesaleAmbushEnabled = true -- Enable or disable ambush on failed deals +--settings.WholesaleAmbushBase = 2 -- Base number of attackers on failed deals +--settings.WholesaleAmbushScale = true -- Scale number of attackers based on drug quantity +--settings.WholesaleAmbushTier1 = 10 -- Drug quantity threshold for 3 attackers +--settings.WholesaleAmbushTier2 = 20 -- Drug quantity threshold for 4 attackers +--settings.WholesaleAmbushTier3 = 30 -- Drug quantity threshold for 5 attackers +--settings.WholesaleWeaponTiers = true -- Scale weapon difficulty based on drug quantity +--settings.WholesaleWeaponsTier1 = { -- Basic weapons (default) +-- "WEAPON_PISTOL", +-- "WEAPON_BAT", +-- "WEAPON_KNIFE", +-- "WEAPON_MACHETE" +--} +--settings.WholesaleWeaponsTier2 = { -- Medium weapons (10+ drugs) +-- "WEAPON_COMBATPISTOL", +-- "WEAPON_MICROSMG", +-- "WEAPON_SAWNOFFSHOTGUN", +-- "WEAPON_CROWBAR" +--} +--settings.WholesaleWeaponsTier3 = { -- Advanced weapons (20+ drugs) +-- "WEAPON_APPISTOL", +-- "WEAPON_SMG", +-- "WEAPON_PUMPSHOTGUN", +-- "WEAPON_CARBINERIFLE" +--} +--settings.WholesaleWeaponsTier4 = { -- Elite weapons (30+ drugs) +-- "WEAPON_HEAVYPISTOL", +-- "WEAPON_ASSAULTSMG", +-- "WEAPON_ASSAULTSHOTGUN", +-- "WEAPON_SPECIALCARBINE" +--} +--settings.WholesaleShowEstimates = true -- Show estimated value before deal +--settings.WholesaleFailPoliceAlert = 75 -- Chance to alert police on failed deals (0-100) +--settings.WholesaleResetOnTimeout = true -- Reset wholesale flag when buyer times out +--settings.SuccessfulChance = 90 --- this is the chance of a Success wholesale 1-100 +--settings.AlertPoliceWholesale = 90 -- 1-100 of how often it will alert police +--settings.WholesaleTimeout = 600 -- time in seconds to get to the location +--settings.PoliceCount = 0 +-- +--local Price = { +-- cokeburner = { +-- min = 25, +-- max = 50 +-- }, +-- crackburner = { +-- min = 25, +-- max = 50 +-- }, +-- lsdburner = { +-- min = 25, +-- max = 50 +-- }, +-- heroinburner = { +-- min = 25, +-- max = 50 +-- }, +-- xtcburner = { +-- min = 25, +-- max = 50 +-- }, +-- methburner = { +-- min = 25, +-- max = 50 +-- } +--} +--local locs = { +-- vector4(-2352.32, 266.78, 165.3, 23.46), +-- vector4(-1467.49, 874.01, 183.59, 298.45), +-- vector4(-856.71, 874.26, 202.85, 205.3), +-- vector4(950.58, -128.49, 74.42, 205.3), +-- vector4(1152.71, -328.43, 69.21, 205.3), +-- vector4(112.66, -1955.67, 20.75, 37.94), +-- vector4(-544.4, -1684.8, 19.89, 252.07), +-- vector4(-1185.02, -1805.4, 3.91, 184.83), +-- vector4(-1641.4, -981.99, 7.58, 35.38), +-- vector4(-1827.93, 782.36, 138.29, 219.99), +-- vector4(-320.84, 2818.73, 59.45, 337.22), +-- vector4(474.88, 2609.56, 44.48, 357.0), +--} +-- +--ps.registerCallback('md-drugs:server:GetWSsettings', function(source) +-- return settings +--end) +-- +--function getRandW(source) +-- local rand = math.random(1, #locs) +-- return locs[rand] +--end +-- +--for k, v in pairs (burners) do +-- ps.createUseable(k, function(source, item) +-- if active[ps.getIdentifier(source)] then +-- TriggerClientEvent("md-drugs:client:GetLocation", active[ps.getIdentifier(source)].src, active[ps.getIdentifier(source)]) +-- return +-- 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 +-- local amt = ps.getItemCount(source, d) or 0 +-- if amt > 0 then +-- drugs[d] = (drugs[d] or 0) + amt +-- count = count + amt +-- end +-- end +-- if count < settings.WholesaleMinQuantity then +-- ps.addItem(source, k, 1) +-- 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)] = { +-- src = source, +-- item = k, +-- location = getRandW(source), +-- price = Price[k], +-- count = count, +-- drugs = drugs +-- } +-- TriggerClientEvent("md-drugs:client:GetLocation", active[ps.getIdentifier(source)].src, active[ps.getIdentifier(source)]) +-- end +-- end) +--end +-- +--local function getBonus(quantity) +-- local bonus = math.floor(quantity / 10) * settings.WholesaleQuantityBonus +-- if bonus > settings.WholesaleMaxBonus then +-- bonus = settings.WholesaleMaxBonus +-- end +-- return bonus +--end +--RegisterNetEvent('md-drugs:server:SuccessSale', function() +-- local src = source +-- local id = ps.getIdentifier(source) +-- +-- if not active[id] then +-- return +-- end +-- local deal = active[id] +-- if deal.count < settings.WholesaleMinQuantity then +-- Bridge.Notify.SendNotify(src, 'Not enough drugs for wholesale deal', 'error') +-- active[id] = nil +-- return +-- end +-- local basePrice = math.floor(((deal.price.min + deal.price.max) / 2) * deal.count) +-- local bonus = getBonus(deal.count) +-- local finalPrice = math.floor(basePrice + (basePrice * bonus)) +-- local need, have = 0,0 +-- for k, v in pairs (deal.drugs) do +-- need = need + 1 +-- if ps.hasItem(src, k, v) then +-- have = have + 1 +-- end +-- end +-- if need ~= have then +-- Bridge.Notify.SendNotify(src, 'You are missing some drugs for the deal', 'error') +-- active[id] = nil +-- return +-- end +-- local removed = true +-- for k, v in pairs (deal.drugs) do +-- if not ps.removeItem(src, k, v) then +-- removed = false +-- break +-- end +-- end +-- if not removed then +-- 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) +-- Bridge.Notify.SendNotify(src, 'Wholesale sale successful' .. ' $' .. finalPrice, 'success') +-- active[id] = nil +--end) +-- +--RegisterNetEvent('md-drugs:server:CleanupWholesale', function() +-- local src = source +-- local id = ps.getIdentifier(source) +-- if active[id] then +-- active[id] = nil +-- end +--end) \ No newline at end of file diff --git a/server/xtc.lua b/server/xtc.lua index 84b0904..868a57c 100644 --- a/server/xtc.lua +++ b/server/xtc.lua @@ -1,6 +1,6 @@ - +Locations, Recipes = Locations or {}, Recipes or {} -------------------- stealing ingridients -local RecipeList = { +Recipes.XTC = { raw = { raw_xtc = {take = {mdp2p = 1, isosafrole = 1}, give = {raw_xtc = 1}} }, @@ -36,7 +36,7 @@ local RecipeList = { } } -local xtcLocations = { +Locations.XTC = { isosafrole = { -- where to steal isosafrole {loc = vector3(844.39, -902.92, 25.42), l = 1.0, w = 1.0, rot = 45.0, gang = ""}, }, @@ -53,51 +53,47 @@ local xtcLocations = { {loc = vector3(844.71, -900.56, 25.43), l = 1.0, w = 1.0, rot = 45.0, gang = ""}, }, } - -ps.registerCallback('md-drugs:server:GetXtcLocs', function(source) - return xtcLocations -end) +GlobalState.MDDrugsLocations = Locations +GlobalState.MDDrugsRecipes = Recipes local activePresses = {} RegisterServerEvent('md-drugs:server:stealisosafrole', function(num) local src = source - if not ps.checkDistance(src, xtcLocations.isosafrole[num].loc, 3.0) then - Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Checks.notIn'), "error") + if not checkDistance(src, Locations.XTC.isosafrole[num].loc, 3.0,'md-drugs:server:stealisosafrole') then return end if timeOut(src, 'md-drugs:server:stealisosafrole') then return end - ps.addItem(src, "isosafrole", 1) + Bridge.Inventory.AddItem(src, "isosafrole", 1) end) RegisterServerEvent('md-drugs:server:stealmdp2p', function(num) local src = source - if not ps.checkDistance(src, xtcLocations.mdp2p[num].loc, 3.0) then - Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Checks.notIn'), "error") + if not checkDistance(src, Locations.XTC.mdp2p[num].loc, 3.0,'md-drugs:server:stealmdp2p') then return end if timeOut(src, 'md-drugs:server:stealmdp2p') then return end - ps.addItem(src, "mdp2p", 1) + Bridge.Inventory.AddItem(src, "mdp2p", 1) end) local presses = { - {item = 'singlepress', data = 'singlestack', recipes = RecipeList.singlestack}, - {item = 'dualpress', data = 'dualstack', recipes = RecipeList.dualstack}, - {item = 'triplepress', data = 'triplestack', recipes = RecipeList.triplestack}, - {item = 'quadpress', data = 'quadstack', recipes = RecipeList.quadstack}, + {item = 'singlepress', data = 'singlestack', recipes = Recipes.XTC.singlestack}, + {item = 'dualpress', data = 'dualstack', recipes = Recipes.XTC.dualstack}, + {item = 'triplepress', data = 'triplestack', recipes = Recipes.XTC.triplestack}, + {item = 'quadpress', data = 'quadstack', recipes = Recipes.XTC.quadstack}, } for k, v in pairs (presses) do -ps.createUseable(v.item, function(source, item) + Bridge.Framework.RegisterUsableItem(v.item, function(source, item) local src = source - local location = ps.callback('md-drugs:client:setpress', src, v) + local location = Bridge.Callback.Trigger('md-drugs:client:setpress', src, v) if location then - if ps.removeItem(src, v.item, 1) then + if Bridge.Inventory.RemoveItem(src, v.item, 1) then activePresses[src] = { press = v.data, get = v.item, - owner = ps.getPlayerName(src), - ownerid = ps.getIdentifier(src), + owner = Bridge.Framework.GetPlayerName(src), + ownerid = Bridge.Framework.GetPlayerIdentifier(src), src = src, loc = location } @@ -110,8 +106,8 @@ RegisterServerEvent('md-drugs:server:getpressback', function() local src = source if not activePresses[src] then return end local press = activePresses[src] - if not ps.checkDistance(src, press.loc, 2.0) then return end - ps.addItem(src, press.get, 1) + if not checkDistance(src, press.loc, 2.0,'md-drugs:server:getpressback' ) then return end + Bridge.Inventory.AddItem(src, press.get, 1) activePresses[src] = nil end) @@ -122,22 +118,20 @@ RegisterServerEvent('md-drugs:server:makextc', function(data) return end if timeOut(src, 'md-drugs:server:makextc') then return end - if not ps.checkDistance(src, activePresses[src].loc, 2.0) then return end - if not ps.craftItem(src, RecipeList[activePresses[src].press][data]) then - verifyHas(src, RecipeList[activePresses[src].press][data].take) + if not checkDistance(src, activePresses[src].loc, 2.0, 'md-drugs:server:makextc') then return end + if not craft(src, Recipes.XTC[activePresses[src].press][data]) then return end end) RegisterServerEvent('md-drugs:server:buypress', function(loc, item) local src = source - if not ps.checkDistance(src, xtcLocations.xtcpress[loc].loc, 2.0) then - Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notIn'), "error") + if not checkDistance(src, Locations.XTC.xtcpress[loc].loc, 2.0, 'md-drugs:server:buypress') then 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) + if Bridge.Framework.RemoveAccountBalance(src,"cash", Recipes.XTC.presses['singlepress'].cash) then + Bridge.Inventory.AddItem(src, "singlepress", 1) else Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notEnoughMoney'), "error") end @@ -146,30 +140,23 @@ end) 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 - Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Catches.notIn'), "error") - return - end - if not ps.craftItem(src, RecipeList.presses[item]) then - verifyHas(src, RecipeList.presses[item].take) + if not checkDistance(src, Locations.XTC.xtcpress[data].loc, 2.0, 'md-drugs:server:buypress') then + return + end + if not craft(src, Recipes.XTC.presses[item]) then return end -end) - -ps.registerCallback('md-drugs:server:getpressrecipes', function(source) - return RecipeList.presses end) ------------- making powder RegisterServerEvent('md-drugs:server:makingrawxtc', function(num) local src = source - if not ps.checkDistance(src, xtcLocations.rawxtcloc[num].loc, 3.0) then + if not checkDistance(src, Locations.XTC.rawxtcloc[num].loc, 3.0, 'md-drugs:server:makingrawxtc') then Bridge.Notify.SendNotify(src, Bridge.Language.Locale('Checks.notIn'), "error") return end if timeOut(src, 'md-drugs:server:makingrawxtc') then return end - if not ps.craftItem(src, RecipeList.raw.raw_xtc) then - verifyHas(src, RecipeList.raw.raw_xtc.take) + if not craft(src, Recipes.XTC.raw.raw_xtc) then return end end) @@ -189,7 +176,7 @@ end RegisterServerEvent('md-drugs:server:stamp', function(num, color) local src = source - if not ps.checkDistance(src, xtcLocations.stamp[num].loc, 3.0) then return end + if not checkDistance(src, Locations.XTC.stamp[num].loc, 3.0, 'md-drugs:server:stamp') then return end if timeOut(src, 'md-drugs:server:stamp') then return end local item = getColor(color) local colors = { @@ -198,14 +185,14 @@ RegisterServerEvent('md-drugs:server:stamp', function(num, color) orange = 'orange_xtc', blue = 'blue_xtc' } - if ps.removeItem(src, colors[color], 1) then - ps.addItem(src, item, 1) - elseif ps.removeItem(src, colors[color].."2", 1) then - ps.addItem(src, item..'2', 1) - elseif ps.removeItem(src, colors[color].."3", 1) then - ps.addItem(src, item..'3', 1) - elseif ps.removeItem(src, colors[color].."4", 1) then - ps.addItem(src, item..'4', 1) + if Bridge.Inventory.RemoveItem(src, colors[color], 1) then + Bridge.Inventory.AddItem(src, item, 1) + elseif Bridge.Inventory.RemoveItem(src, colors[color].."2", 1) then + Bridge.Inventory.AddItem(src, item..'2', 1) + elseif Bridge.Inventory.RemoveItem(src, colors[color].."3", 1) then + Bridge.Inventory.AddItem(src, item..'3', 1) + elseif Bridge.Inventory.RemoveItem(src, colors[color].."4", 1) then + Bridge.Inventory.AddItem(src, item..'4', 1) else Bridge.Notify.SendNotify(src, Bridge.Language.Locale('xtc.noPills'), 'error') end @@ -214,7 +201,7 @@ end) AddEventHandler('playerDropped', function() local src = source if activePresses[src] then - ps.addItem(src, activePresses[src].get, 1) + Bridge.Inventory.AddItem(src, activePresses[src].get, 1) activePresses[src] = nil end end) \ No newline at end of file diff --git a/serverRun.lua b/serverRun.lua index 37febbe..d6ee86d 100644 --- a/serverRun.lua +++ b/serverRun.lua @@ -2,18 +2,18 @@ function loadFile(filePath) local resourceName = 'md-drugs' local fullScript = LoadResourceFile(resourceName, filePath) if not fullScript then - ps.error("Error: Failed to load module '" .. filePath .. "' from resource '" .. resourceName .. "'.") + Bridge.Prints.Error("Error: Failed to load module '" .. filePath .. "' from resource '" .. resourceName .. "'.") return false end local chunk, err = load(fullScript, filePath, "t") if not chunk then - ps.error("Error loading Lua chunk from '" .. filePath .. "': " .. tostring(err)) + Bridge.Prints.Error("Error loading Lua chunk from '" .. filePath .. "': " .. tostring(err)) return false end local success, execErr = pcall(chunk) if not success then - ps.error("Error executing Lua chunk from '" .. filePath .. "': " .. tostring(execErr)) + Bridge.Prints.Error("Error executing Lua chunk from '" .. filePath .. "': " .. tostring(execErr)) return false end return true