2026-01-21 01:36:38 -07:00
|
|
|
--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
|
2026-01-21 21:27:08 -07:00
|
|
|
-- if not ps.progressbar(Bridge.Language.Locale('wholesale.wholesaling')) then return end
|
2026-01-21 01:36:38 -07:00
|
|
|
-- TriggerServerEvent("md-drugs:server:SuccessSale", drug)
|
|
|
|
|
-- else
|
2026-01-21 21:27:08 -07:00
|
|
|
-- ps.progressbar("Deal Going Bad")
|
2026-01-21 01:36:38 -07:00
|
|
|
-- 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)
|