- fix deliveries

This commit is contained in:
Mustache Dom committed 2025-09-15 21:43:22 -07:00
1 parent 69879dd0df
commit 52c6eaec91
2 files changed
+36 -21

No files matched your search

+19 -16
View File
@@ -14,9 +14,10 @@ local function SpawnDealer()
icon = 'fas fa-user-secret',
label = ps.lang('Deliveries.targetGetDel'),
action = function()
local bool, item, amount, coords = ps.callback('md-drugs:server:GetDeliveryItem', false, k)
if bool then
TriggerEvent('md-drugs:client:setLocation', {bool = bool, item = item, amount = amount, coords = coords})
local data = ps.callback('md-drugs:server:GetDeliveryItem', k)
ps.debug(data)
if type(data) == 'table' and data.coords then
TriggerEvent('md-drugs:client:setLocation', data)
end
end,
},
@@ -60,18 +61,20 @@ RegisterNetEvent('md-drugs:client:setLocation', function(data)
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)
ps.entityTarget(Buyer, {
icon = 'fas fa-user-secret',
label = ps.lang('Deliveries.targetHandOff'),
action = function()
if not progressbar(ps.lang('Deliveries.delivering'), 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
{
icon = 'fas fa-user-secret',
label = ps.lang('Deliveries.targetHandOff'),
action = function()
if not ps.progressbar(ps.lang('Deliveries.delivering'), 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
end
}, nil)
}
})
end)
+17 -5
View File
@@ -117,7 +117,7 @@ ps.registerCallback('md-drugs:server:GetDeliveryItem', function(source, data)
local itemnum = math.random(1, #DeliveryItems)
local item = DeliveryItems[itemnum].item
local amount = math.random(1,4)
local check = MySQL.query.await('SELECT * FROM deliveriesdealer WHERE cid = ?', {Player.PlayerData.citizenid})
local check = MySQL.query.await('SELECT * FROM deliveriesdealer WHERE cid = ?', {ps.getIdentifier(src)})
local locnum = math.random(1, #dloc)
local coord = json.encode({
x = dloc[locnum].coords.x,
@@ -129,7 +129,13 @@ ps.registerCallback('md-drugs:server:GetDeliveryItem', function(source, data)
MySQL.insert('INSERT INTO deliveriesdealer SET cid = ?, itemdata = ?, timestart = ?, maxtime = ?, location = ?',
{ps.getIdentifier(src), json.encode({item = item, amount = amount}), os.time(), os.time() + (15 * 60), coord })
ps.addItem(src, item, amount)
return true, item, amount, coord
local tab = {
bool = true,
item = item,
amount = amount,
coords = coord
}
return tab
else
local time = os.time()
local timeout = math.floor(os.difftime(time, check[1].maxtime) / 60)
@@ -137,10 +143,16 @@ ps.registerCallback('md-drugs:server:GetDeliveryItem', function(source, data)
if timeout > 15 then
MySQL.query.await('DELETE FROM deliveriesdealer WHERE cid = ?', {ps.getIdentifier(src)})
ps.notify(src, ps.lang('Deliveries.slowAf'), 'error' )
return false
return {bool = false}
end
ps.notify(src,ps.lang('Deliveries.alreadyDelivering'), 'error' )
return false, item, amount, coord
local tab = {
bool = false,
item = item,
amount = amount,
coords = coord
}
return tab
end
end)
@@ -194,7 +206,7 @@ ps.registerCommand("newdealer", {
end
MySQL.insert('INSERT INTO dealers (name, coords, time, createdby) VALUES (?, ?, ?, ?)', {
dealerName, pos, 'nil', Player.PlayerData.citizenid
dealerName, pos, 'nil', ps.getIdentifier(source)
}, function()
QBConfig.Dealers[dealerName] = {
name = dealerName,