updated pharma to utilize nearby Players and give them the prescription directly
This commit is contained in:
1 parent
5c5f454207
commit
e83cddd96f
2 files changed
+25
-30
No files matched your search
+12
-22
@@ -1,27 +1,17 @@
|
|||||||
local QBCore = exports['qb-core']:GetCoreObject()
|
local QBCore = exports['qb-core']:GetCoreObject()
|
||||||
|
|
||||||
RegisterNetEvent("md-drugs:client:prescriptionpad", function(args)
|
lib.callback.register("md-drugs:client:prescriptionpad", function(data)
|
||||||
local icon, event = 'fa-solid fa-file-prescription', 'md-drugs:client:writeprescription'
|
if not QBCore.Functions.GetPlayerData().job.type == 'ems' then return end
|
||||||
if QBCore.Functions.GetPlayerData().job.type == Config.PharmaJob then
|
local input = lib.inputDialog('Who To Give A Prescription To?',{
|
||||||
lib.registerContext({
|
{type = 'select', label = 'Player Name', options = data},
|
||||||
id = 'prescriptionpad',
|
{type = 'select', label = 'Prescription', options = {
|
||||||
title = "Prescription Pad",
|
{label = 'Vicodin', value = 'vicodin_prescription'},
|
||||||
options = {
|
{label = 'Adderal', value = 'adderal_prescription'},
|
||||||
{title = 'Give Vics', description = 'Give Vics ', icon = icon, event = event, args = {item = 'vicodin_prescription'}},
|
{label = 'Morphine', value = 'morphine_prescription'},
|
||||||
{title = 'Give Madderal', description = 'Give Madderal ', icon = icon, event = event, args = {item = 'adderal_prescription'}},
|
{label = 'Xanax', value = 'xanax_prescription'}
|
||||||
{title = 'Give Morphin', description = 'Give Morphin ', icon = icon, event = event, args = {item = 'morphine_prescription'}},
|
}}})
|
||||||
{title = 'Give Zany', description = 'Give Zany ', icon = icon, event = event, args = {item = 'xanax_prescription'} },
|
if not progressbar(Lang.Pharma.write, 4000, 'notepad') then return end
|
||||||
}
|
return {who = input[1], what = input[2]}
|
||||||
})
|
|
||||||
lib.showContext('prescriptionpad')
|
|
||||||
else
|
|
||||||
Notify(Lang.Pharma.notems, "error")
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
RegisterNetEvent("md-drugs:client:writeprescription", function(args)
|
|
||||||
if not progressbar(Lang.Pharma.write, 4000, 'notepad') then return end
|
|
||||||
TriggerServerEvent("md-drugs:server:giveprescription", args.item)
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent("md-drugs:client:fillprescription", function(data)
|
RegisterNetEvent("md-drugs:client:fillprescription", function(data)
|
||||||
|
|||||||
+13
-8
@@ -12,16 +12,21 @@ end
|
|||||||
|
|
||||||
QBCore.Functions.CreateUseableItem('prescription_pad', function(source, item)
|
QBCore.Functions.CreateUseableItem('prescription_pad', function(source, item)
|
||||||
local src = source
|
local src = source
|
||||||
if GetJob(src) then
|
local Player = getPlayer(src)
|
||||||
TriggerClientEvent("md-drugs:client:prescriptionpad", src, item)
|
local name = GetName(src)
|
||||||
end
|
local near = {}
|
||||||
end)
|
|
||||||
|
|
||||||
RegisterServerEvent('md-drugs:server:giveprescription', function(item)
|
|
||||||
local src = source
|
|
||||||
if GetJob(src) then
|
if GetJob(src) then
|
||||||
AddItem(src, item, 1)
|
for k, v in pairs (QBCore.Functions.GetQBPlayers()) do
|
||||||
Log(GetName(src) .. ' Made A Prescription Of ' .. item .. '!', 'pharma')
|
local targ = QBCore.Functions.GetPlayerByCitizenId(v.PlayerData.citizenid)
|
||||||
|
local tname = GetName(v.PlayerData.source)
|
||||||
|
table.insert(near, {label = tname, value = targ.PlayerData.citizenid})
|
||||||
|
end
|
||||||
|
local data = lib.callback.await('md-drugs:client:prescriptionpad', src, near)
|
||||||
|
if type(data) == 'table' then
|
||||||
|
local give = QBCore.Functions.GetPlayerByCitizenId(data.who)
|
||||||
|
AddItem(give.PlayerData.source, data.what, 1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user