2024-09-24 15:07:41 -07:00
|
|
|
local isActive = false
|
2024-11-23 01:58:57 -08:00
|
|
|
local dealer = {}
|
2024-11-24 01:25:09 -08:00
|
|
|
|
2024-03-17 20:03:35 -07:00
|
|
|
RegisterNetEvent('md-drugs:client:opendealermenu', function()
|
2024-10-23 16:04:09 -07:00
|
|
|
local rep = GetRep()
|
2024-10-24 19:45:39 -07:00
|
|
|
makeMenu('dealermenu', rep)
|
2024-03-17 20:03:35 -07:00
|
|
|
lib.showContext('dealermenu')
|
2024-01-13 22:23:17 -08:00
|
|
|
end)
|
|
|
|
|
|
2024-11-23 01:58:57 -08:00
|
|
|
local function SpawnDealer()
|
2025-07-01 03:09:46 -07:00
|
|
|
local getDealers = ps.callback('md-drugs:server:getDealers')
|
2024-11-25 19:57:26 -08:00
|
|
|
for k,v in pairs(getDealers) do
|
2024-09-24 15:07:41 -07:00
|
|
|
local Ped = "g_m_y_famdnf_01"
|
|
|
|
|
lib.requestModel(Ped, Config.RequestModelTime)
|
|
|
|
|
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)
|
2024-11-12 17:08:02 -08:00
|
|
|
AddMultiModel(dealer[k], {
|
|
|
|
|
{ icon = 'fas fa-user-secret', label = string.format(Lang.targets.Delivery.Deliver, v.name),
|
|
|
|
|
action = function()
|
2025-07-01 03:09:46 -07:00
|
|
|
local bool, item, amount, coords = ps.callback('md-drugs:server:GetDeliveryItem', false, k)
|
2024-11-12 17:08:02 -08:00
|
|
|
if bool then
|
|
|
|
|
Email(Lang.Delivery.emailn, Lang.Delivery.emailsub, string.format(Lang.Delivery.emailcon, amount, GetLabel(item)))
|
|
|
|
|
TriggerEvent('md-drugs:client:setLocation', {bool = bool, item = item, amount = amount, coords = coords})
|
|
|
|
|
end
|
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
{ icon = "fa-solid fa-store", label = string.format(Lang.targets.Delivery.open, v.name),
|
|
|
|
|
action = function() TriggerEvent('md-drugs:client:opendealermenu') end,
|
|
|
|
|
}}, dealer[k])
|
2024-11-25 19:57:26 -08:00
|
|
|
end
|
2024-11-23 01:58:57 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
RegisterNetEvent('md-drugs:client:RefreshDealers', function()
|
|
|
|
|
SpawnDealer()
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
CreateThread(function()
|
|
|
|
|
SpawnDealer()
|
2024-01-13 22:23:17 -08:00
|
|
|
end)
|
2024-10-23 17:44:46 -07:00
|
|
|
|
2024-09-24 15:07:41 -07:00
|
|
|
RegisterNetEvent('md-drugs:client:setLocation', function(data)
|
|
|
|
|
local coord = json.decode(data.coords)
|
2024-10-25 01:55:35 -07:00
|
|
|
SetNewWaypoint(coord.x, coord.y)
|
2024-10-23 17:44:46 -07:00
|
|
|
if isActive then return end
|
2024-09-24 15:07:41 -07:00
|
|
|
isActive = true
|
2024-11-23 15:33:17 -08:00
|
|
|
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)
|
2024-10-25 01:55:35 -07:00
|
|
|
AddSingleModel(Buyer, {
|
|
|
|
|
icon = 'fas fa-user-secret',
|
|
|
|
|
label = Lang.targets.Delivery.hand,
|
|
|
|
|
action = function()
|
|
|
|
|
if not progressbar(Lang.Delivery.pack, 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
|
2024-09-24 15:07:41 -07:00
|
|
|
end
|
2024-10-25 01:55:35 -07:00
|
|
|
end
|
|
|
|
|
}, nil)
|
2024-11-23 01:58:57 -08:00
|
|
|
end)
|