2026-03-05 00:00:34 -08:00
|
|
|
if not Config.Drugs['oxyruns'] then return end
|
2025-07-18 01:19:12 -07:00
|
|
|
local onRoute = {}
|
2026-01-18 01:20:44 -07:00
|
|
|
local vehicles = {}
|
2026-01-31 02:05:15 -07:00
|
|
|
|
2025-08-06 02:25:06 -06:00
|
|
|
|
2025-08-16 23:43:20 -07:00
|
|
|
|
2026-01-18 01:20:44 -07:00
|
|
|
Bridge.Callback.Register('md-drugs:server:payfortruck', function(source, loc)
|
2023-12-07 15:45:48 -08:00
|
|
|
local src = source
|
2026-01-18 01:20:44 -07:00
|
|
|
if timeOut(src, 'md-drugs:server:payfortruck') then return false end
|
2026-01-23 03:41:19 -07:00
|
|
|
if onRoute[src] then
|
|
|
|
|
return false
|
|
|
|
|
end
|
2026-01-31 02:05:15 -07:00
|
|
|
if not checkDistance(src, Config.Oxy.Locations.OxyPayForTruck[loc].loc, 2.0, 'md-drugs:server:payfortruck') then
|
2026-01-18 01:20:44 -07:00
|
|
|
return false
|
|
|
|
|
end
|
2026-01-31 02:05:15 -07:00
|
|
|
if not Bridge.Framework.RemoveAccountBalance(src, 'cash', Config.Oxy.prices.payfortruck) then
|
2026-01-18 01:20:44 -07:00
|
|
|
Bridge.Notify.SendNotify(src, Bridge.Language.Locale('oxy.notEnoughCash'), "error")
|
2024-09-24 15:07:41 -07:00
|
|
|
return false
|
2023-12-07 15:45:48 -08:00
|
|
|
end
|
2026-01-18 01:20:44 -07:00
|
|
|
onRoute[src] = {
|
2026-01-31 02:05:15 -07:00
|
|
|
amount = math.random(1, #Config.Oxy.Locations.oxylocations),
|
2026-01-18 01:20:44 -07:00
|
|
|
current = 0
|
|
|
|
|
}
|
|
|
|
|
return true
|
2023-12-07 15:45:48 -08:00
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RegisterServerEvent('md-drugs:server:giveoxybox', function()
|
|
|
|
|
local src = source
|
2025-08-16 23:43:20 -07:00
|
|
|
if timeOut(src, 'md-drugs:server:giveoxybox') then return end
|
2025-07-18 01:19:12 -07:00
|
|
|
if not onRoute[src] then
|
2026-01-23 03:41:19 -07:00
|
|
|
Bridge.Prints.Warn(Bridge.Language.Locale('oxy.notOnOxyRun', Bridge.Framework.GetPlayerIdentifier(src)))
|
2025-07-18 01:19:12 -07:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
2026-01-31 02:05:15 -07:00
|
|
|
if not checkDistance(src, Config.Oxy.Locations.oxylocations[onRoute[src].current], 3.5, 'md-drugs:server:giveoxybox') then
|
2025-07-18 01:19:12 -07:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
2026-01-23 03:41:19 -07:00
|
|
|
local vehicle = vehicles[src]
|
|
|
|
|
if not vehicle or GetEntityModel(vehicle) ~= GetHashKey("burrito3") then
|
2026-01-30 00:45:03 -07:00
|
|
|
Bridge.Prints.Warn(Bridge.Language.Locale('oxy.mismatchOxyVan', Bridge.Framework.GetPlayerIdentifier(src), vehicle))
|
2026-01-18 01:20:44 -07:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
2026-01-23 03:41:19 -07:00
|
|
|
if not checkDistance(src, GetEntityCoords(vehicle), 35.0, 'md-drugs:server:giveoxybox') then
|
2026-01-18 01:20:44 -07:00
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
2025-07-18 01:19:12 -07:00
|
|
|
local cash = math.random(50, 200)
|
2023-12-07 15:45:48 -08:00
|
|
|
local itemchance = math.random(1,100)
|
2026-01-31 02:05:15 -07:00
|
|
|
local item = Config.Oxy.itemList[math.random(1, #Config.Oxy.itemList)]
|
2026-01-18 01:20:44 -07:00
|
|
|
Bridge.Framework.AddAccountBalance(src, 'cash', cash)
|
2026-01-31 02:05:15 -07:00
|
|
|
if itemchance <= Config.Oxy.prices.itemChance then
|
2026-01-30 00:45:03 -07:00
|
|
|
Bridge.Inventory.AddItem(src, item.item, item.amount)
|
2025-07-18 01:19:12 -07:00
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
2026-01-18 01:20:44 -07:00
|
|
|
Bridge.Callback.Register('md-drugs:server:getRoute', function(source)
|
2025-07-18 01:19:12 -07:00
|
|
|
if not onRoute[source] then return false end
|
2026-01-18 01:20:44 -07:00
|
|
|
if onRoute[source].amount == 0 then
|
2025-07-18 01:19:12 -07:00
|
|
|
onRoute[source] = nil
|
2026-01-18 01:20:44 -07:00
|
|
|
vehicles[source] = nil
|
2025-07-18 01:19:12 -07:00
|
|
|
return false
|
2023-12-07 15:45:48 -08:00
|
|
|
end
|
2026-01-31 02:05:15 -07:00
|
|
|
onRoute[source].current = math.random(1, #Config.Oxy.Locations.oxylocations)
|
2026-01-18 01:20:44 -07:00
|
|
|
onRoute[source].amount = onRoute[source].amount - 1
|
|
|
|
|
return onRoute[source].current
|
2023-12-07 15:45:48 -08:00
|
|
|
end)
|
|
|
|
|
|
2026-01-18 01:20:44 -07:00
|
|
|
RegisterNetEvent('md-drugs:server:startOxyRun', function(netId)
|
|
|
|
|
local src = source
|
|
|
|
|
if not onRoute[src] then return end
|
|
|
|
|
local veh = NetworkGetEntityFromNetworkId(netId)
|
|
|
|
|
if not veh or GetEntityModel(veh) ~= GetHashKey("burrito3") then return end
|
|
|
|
|
vehicles[src] = veh
|
|
|
|
|
|
|
|
|
|
end)
|