Files
md-drugs/client/deliveries.lua
T

59 lines
2.3 KiB
Lua
Raw Normal View History

2024-05-02 18:34:14 -07:00
local QBCore = exports['qb-core']:GetCoreObject()
local isActive = false
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()
makeMenu('dealermenu', rep)
2024-03-17 20:03:35 -07:00
lib.showContext('dealermenu')
2024-01-13 22:23:17 -08:00
end)
CreateThread(function()
local dealer = {}
local getDealers = lib.callback.await('md-drugs:server:getDealers', false)
for k,v in pairs(getDealers) do
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)
local options = {
{ icon = 'fas fa-user-secret', label = string.format(Lang.targets.Delivery.Deliver, v.name),
action = function()
local bool, item, amount, coords = lib.callback.await('md-drugs:server:GetDeliveryItem', false, k)
if bool then
2024-10-23 16:04:09 -07:00
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 = 'fas fa-user-secret', label = string.format(Lang.targets.Delivery.open, v.name),
2024-10-23 16:04:09 -07:00
action = function() TriggerEvent('md-drugs:client:opendealermenu') end,
2024-01-13 22:23:17 -08:00
}
}
AddMultiModel(dealer[k], options)
2024-01-13 22:23:17 -08:00
end
end)
2024-10-23 17:44:46 -07:00
RegisterNetEvent('md-drugs:client:setLocation', function(data)
local coord = json.decode(data.coords)
SetNewWaypoint(coord.x, coord.y)
2024-10-23 17:44:46 -07:00
if isActive then return end
isActive = true
2024-10-23 17:44:46 -07:00
local Buyer = CreatePed(0, "g_m_y_famdnf_01",coord.x, coord.y, coord.z-1, 180.0, false, false)
Freeze(Buyer, true, 180)
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
end
end
}, nil)
end)