- fix deliveries
This commit is contained in:
1 parent
69879dd0df
commit
52c6eaec91
2 files changed
+37
-22
No files matched your search
+19
-16
@@ -14,9 +14,10 @@ local function SpawnDealer()
|
|||||||
icon = 'fas fa-user-secret',
|
icon = 'fas fa-user-secret',
|
||||||
label = ps.lang('Deliveries.targetGetDel'),
|
label = ps.lang('Deliveries.targetGetDel'),
|
||||||
action = function()
|
action = function()
|
||||||
local bool, item, amount, coords = ps.callback('md-drugs:server:GetDeliveryItem', false, k)
|
local data = ps.callback('md-drugs:server:GetDeliveryItem', k)
|
||||||
if bool then
|
ps.debug(data)
|
||||||
TriggerEvent('md-drugs:client:setLocation', {bool = bool, item = item, amount = amount, coords = coords})
|
if type(data) == 'table' and data.coords then
|
||||||
|
TriggerEvent('md-drugs:client:setLocation', data)
|
||||||
end
|
end
|
||||||
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)
|
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)
|
Freeze(Buyer, true, coord.w)
|
||||||
ps.entityTarget(Buyer, {
|
ps.entityTarget(Buyer, {
|
||||||
icon = 'fas fa-user-secret',
|
{
|
||||||
label = ps.lang('Deliveries.targetHandOff'),
|
icon = 'fas fa-user-secret',
|
||||||
action = function()
|
label = ps.lang('Deliveries.targetHandOff'),
|
||||||
if not progressbar(ps.lang('Deliveries.delivering'), 4000, 'uncuff') then return end
|
action = function()
|
||||||
isActive = false
|
if not ps.progressbar(ps.lang('Deliveries.delivering'), 4000, 'uncuff') then return end
|
||||||
DeletePed(Buyer)
|
isActive = false
|
||||||
TriggerServerEvent('md-drugs:server:giveDeliveryItems', data.item, data.amount)
|
DeletePed(Buyer)
|
||||||
end,
|
TriggerServerEvent('md-drugs:server:giveDeliveryItems', data.item, data.amount)
|
||||||
canInteract = function()
|
end,
|
||||||
if isActive then
|
canInteract = function()
|
||||||
return true
|
if isActive then
|
||||||
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
}
|
||||||
}, nil)
|
})
|
||||||
end)
|
end)
|
||||||
+18
-6
@@ -117,7 +117,7 @@ ps.registerCallback('md-drugs:server:GetDeliveryItem', function(source, data)
|
|||||||
local itemnum = math.random(1, #DeliveryItems)
|
local itemnum = math.random(1, #DeliveryItems)
|
||||||
local item = DeliveryItems[itemnum].item
|
local item = DeliveryItems[itemnum].item
|
||||||
local amount = math.random(1,4)
|
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 locnum = math.random(1, #dloc)
|
||||||
local coord = json.encode({
|
local coord = json.encode({
|
||||||
x = dloc[locnum].coords.x,
|
x = dloc[locnum].coords.x,
|
||||||
@@ -129,18 +129,30 @@ ps.registerCallback('md-drugs:server:GetDeliveryItem', function(source, data)
|
|||||||
MySQL.insert('INSERT INTO deliveriesdealer SET cid = ?, itemdata = ?, timestart = ?, maxtime = ?, location = ?',
|
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.getIdentifier(src), json.encode({item = item, amount = amount}), os.time(), os.time() + (15 * 60), coord })
|
||||||
ps.addItem(src, item, amount)
|
ps.addItem(src, item, amount)
|
||||||
return true, item, amount, coord
|
local tab = {
|
||||||
|
bool = true,
|
||||||
|
item = item,
|
||||||
|
amount = amount,
|
||||||
|
coords = coord
|
||||||
|
}
|
||||||
|
return tab
|
||||||
else
|
else
|
||||||
local time = os.time()
|
local time = os.time()
|
||||||
local timeout = math.floor(os.difftime(time, check[1].maxtime) / 60)
|
local timeout = math.floor(os.difftime(time, check[1].maxtime) / 60)
|
||||||
|
|
||||||
if timeout > 15 then
|
if timeout > 15 then
|
||||||
MySQL.query.await('DELETE FROM deliveriesdealer WHERE cid = ?', {ps.getIdentifier(src)})
|
MySQL.query.await('DELETE FROM deliveriesdealer WHERE cid = ?', {ps.getIdentifier(src)})
|
||||||
ps.notify(src, ps.lang('Deliveries.slowAf'), 'error' )
|
ps.notify(src, ps.lang('Deliveries.slowAf'), 'error' )
|
||||||
return false
|
return {bool = false}
|
||||||
end
|
end
|
||||||
ps.notify(src,ps.lang('Deliveries.alreadyDelivering'), 'error' )
|
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
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -194,7 +206,7 @@ ps.registerCommand("newdealer", {
|
|||||||
end
|
end
|
||||||
|
|
||||||
MySQL.insert('INSERT INTO dealers (name, coords, time, createdby) VALUES (?, ?, ?, ?)', {
|
MySQL.insert('INSERT INTO dealers (name, coords, time, createdby) VALUES (?, ?, ?, ?)', {
|
||||||
dealerName, pos, 'nil', Player.PlayerData.citizenid
|
dealerName, pos, 'nil', ps.getIdentifier(source)
|
||||||
}, function()
|
}, function()
|
||||||
QBConfig.Dealers[dealerName] = {
|
QBConfig.Dealers[dealerName] = {
|
||||||
name = dealerName,
|
name = dealerName,
|
||||||
|
|||||||
Reference in new issue
Block a user