Files
md-drugs/server/oxyruns.lua
T

56 lines
1.5 KiB
Lua
Raw Normal View History

2024-11-16 23:39:34 -08:00
local prices = {
payfortruck = 500,
hotchance = 30,
itemChance = 20,
}
2025-07-18 01:19:12 -07:00
local onRoute = {}
ps.registerCallback('md-drugs:server:payfortruck', function(source)
2023-12-07 15:45:48 -08:00
local src = source
2025-07-18 01:19:12 -07:00
if ps.removeMoney(src, 'cash', prices.payfortruck) or ps.removeMoney(src, 'bank', prices.payfortruck) then
onRoute[src] = true
ps.notify(src, ps.lang('oxy.paid') .. prices.payfortruck, "success")
return true
2023-12-07 15:45:48 -08:00
else
2025-07-18 01:19:12 -07:00
ps.notify(src, ps.lang('oxy.broke'), "error")
return false
2023-12-07 15:45:48 -08:00
end
end)
RegisterServerEvent('md-drugs:server:giveoxybox', function()
local src = source
2025-07-18 01:19:12 -07:00
if not onRoute[src] then
ps.notify(src, ps.lang('oxy.notonroute'), "error")
return
end
if not ps.checkDistance(src, GlobalState.MDDrugsLocs.oxylocations[onRoute[src]], 3.5) then
ps.notify(src, ps.lang('oxy.toofar'), "error")
return
end
local cash = math.random(50, 200)
2023-12-07 15:45:48 -08:00
local itemchance = math.random(1,100)
2024-11-12 01:04:42 -08:00
local itemList = {
{item = 'oxy', amount = 2},
2024-11-16 23:39:34 -08:00
{item = 'houselockpick', amount = 1},
2024-11-12 01:04:42 -08:00
}
local item = itemList[math.random(1, #itemList)]
2025-07-18 01:19:12 -07:00
ps.addMoney(src,"cash", cash)
if itemchance <= prices.itemChance then
ps.addItem(src, item.item, item.amount)
end
end)
ps.registerCallback('md-drugs:server:getRoute', function(source)
if not onRoute[source] then return false end
local giveLocation = math.random(1, 10)
if giveLocation == 10 then
onRoute[source] = nil
return false
2023-12-07 15:45:48 -08:00
else
2025-07-18 01:19:12 -07:00
onRoute[source] = math.random(1, #GlobalState.MDDrugsLocs.oxylocations)
return GlobalState.MDDrugsLocs.oxylocations[onRoute[source]]
2023-12-07 15:45:48 -08:00
end
end)