57 lines
No EOL
1.7 KiB
Lua
57 lines
No EOL
1.7 KiB
Lua
QBCore = exports['qb-core']:GetCoreObject()
|
|
isBusy = false
|
|
|
|
RegisterNetEvent("drteddy:requestDoctor", function()
|
|
local src = source
|
|
if isBusy then
|
|
TriggerClientEvent('drteddy:notify', src, "Wartezeit", "Dr. Teddy ist noch beschäftigt. Bitte etwas Geduld.", "error")
|
|
return
|
|
end
|
|
|
|
isBusy = true
|
|
TriggerClientEvent("drteddy:startDoctor", src)
|
|
end)
|
|
|
|
RegisterServerEvent('drteddy:setBusy')
|
|
AddEventHandler('drteddy:setBusy', function(state)
|
|
isBusy = state
|
|
end)
|
|
|
|
AddEventHandler('drteddy:delallmedics')
|
|
RegisterServerEvent('drteddy:delallmedics', function()
|
|
isBusy = false
|
|
TriggerClientEvent("drteddy:despawn", -1)
|
|
end)
|
|
|
|
QBCore.Functions.CreateCallback("drteddy:checkMoney", function(source, cb)
|
|
local Player = QBCore.Functions.GetPlayer(source)
|
|
|
|
if Player then
|
|
local hascash = Player.Functions.GetMoney('cash')
|
|
local hasbank = Player.Functions.GetMoney('bank')
|
|
|
|
if hascash >= Config.TreatmentPrice then
|
|
Player.Functions.RemoveMoney('cash', Config.TreatmentPrice)
|
|
cb({status = true, type = 'cash'})
|
|
elseif hasbank >= Config.TreatmentPrice then
|
|
Player.Functions.RemoveMoney('bank', Config.TreatmentPrice)
|
|
cb({status = true, type = 'bank'})
|
|
else
|
|
cb({status = false, type = 'noMoney'})
|
|
end
|
|
else
|
|
cb({status = false, type = 'noPlayer'})
|
|
end
|
|
end)
|
|
|
|
QBCore.Functions.CreateCallback('drteddy:ceckJob', function(source, cb)
|
|
local Players, Amount = QBCore.Functions.GetPlayersOnDuty('ambulance')
|
|
|
|
print(json.encode(Players))
|
|
print(Amount)
|
|
if Amount > 0 then
|
|
cb(true)
|
|
else
|
|
cb(false)
|
|
end
|
|
end) |