55 lines
1.6 KiB
Lua
55 lines
1.6 KiB
Lua
|
local QBCore = exports['qb-core']:GetCoreObject()
|
||
|
|
||
|
local CoolDown = false
|
||
|
|
||
|
RegisterNetEvent("kevin-delivery:server:addTrunkItems", function(plate, items) exports["ps-inventory"]:addTrunkItems(plate, items) end)
|
||
|
RegisterServerEvent('kevin-deliveries:coolout', function()
|
||
|
CoolDown = true
|
||
|
local timer = Config.CoolDown
|
||
|
while timer > 0 do
|
||
|
Wait(1000)
|
||
|
timer = timer - 1000
|
||
|
if timer == 0 then
|
||
|
CoolDown = false
|
||
|
end
|
||
|
end
|
||
|
end)
|
||
|
|
||
|
QBCore.Functions.CreateCallback("kevin-deliveries:coolc",function(source, cb)
|
||
|
if CoolDown then
|
||
|
cb(true)
|
||
|
else
|
||
|
cb(false)
|
||
|
end
|
||
|
end)
|
||
|
|
||
|
QBCore.Functions.CreateCallback('kevin-deliveries:hasPackage', function(source, cb)
|
||
|
local src = source
|
||
|
local Player = QBCore.Functions.GetPlayer(src)
|
||
|
local hasPackage = Player.Functions.GetItemByName("delivery-box")
|
||
|
if hasPackage then
|
||
|
cb(true)
|
||
|
else
|
||
|
cb(false)
|
||
|
end
|
||
|
end)
|
||
|
|
||
|
RegisterServerEvent('kevin-deliveries:RemovePackage', function()
|
||
|
local src = source
|
||
|
local Player = QBCore.Functions.GetPlayer(src)
|
||
|
Player.Functions.RemoveItem("delivery-box", 1, false)
|
||
|
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items["delivery-box"], "remove")
|
||
|
Wait(2500)
|
||
|
end)
|
||
|
|
||
|
RegisterServerEvent('kevin-deliveries:Payouts', function(data)
|
||
|
local src = source
|
||
|
local Player = QBCore.Functions.GetPlayer(src)
|
||
|
local job = Player.PlayerData.job.name
|
||
|
local pay = data.Payment
|
||
|
|
||
|
if job == Config.JobName then
|
||
|
Player.Functions.AddMoney(Config.PaymentMethod, pay, 'UBS Indbetaling')
|
||
|
Wait(2500)
|
||
|
end
|
||
|
end)
|