diff --git a/client/pharma.lua b/client/pharma.lua index 404cd07..4a6ca40 100644 --- a/client/pharma.lua +++ b/client/pharma.lua @@ -1,27 +1,17 @@ local QBCore = exports['qb-core']:GetCoreObject() -RegisterNetEvent("md-drugs:client:prescriptionpad", function(args) -local icon, event = 'fa-solid fa-file-prescription', 'md-drugs:client:writeprescription' -if QBCore.Functions.GetPlayerData().job.type == Config.PharmaJob then - lib.registerContext({ - id = 'prescriptionpad', - title = "Prescription Pad", - options = { - {title = 'Give Vics', description = 'Give Vics ', icon = icon, event = event, args = {item = 'vicodin_prescription'}}, - {title = 'Give Madderal', description = 'Give Madderal ', icon = icon, event = event, args = {item = 'adderal_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'} }, - } - }) - 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) +lib.callback.register("md-drugs:client:prescriptionpad", function(data) + if not QBCore.Functions.GetPlayerData().job.type == 'ems' then return end + local input = lib.inputDialog('Who To Give A Prescription To?',{ + {type = 'select', label = 'Player Name', options = data}, + {type = 'select', label = 'Prescription', options = { + {label = 'Vicodin', value = 'vicodin_prescription'}, + {label = 'Adderal', value = 'adderal_prescription'}, + {label = 'Morphine', value = 'morphine_prescription'}, + {label = 'Xanax', value = 'xanax_prescription'} + }}}) + if not progressbar(Lang.Pharma.write, 4000, 'notepad') then return end + return {who = input[1], what = input[2]} end) RegisterNetEvent("md-drugs:client:fillprescription", function(data) diff --git a/server/pharma.lua b/server/pharma.lua index 0c80fc9..5453820 100644 --- a/server/pharma.lua +++ b/server/pharma.lua @@ -12,17 +12,22 @@ end QBCore.Functions.CreateUseableItem('prescription_pad', function(source, item) local src = source - if GetJob(src) then - TriggerClientEvent("md-drugs:client:prescriptionpad", src, item) - end -end) + local Player = getPlayer(src) + local name = GetName(src) + local near = {} -RegisterServerEvent('md-drugs:server:giveprescription', function(item) - local src = source - if GetJob(src) then - AddItem(src, item, 1) - Log(GetName(src) .. ' Made A Prescription Of ' .. item .. '!', 'pharma') - end + if GetJob(src) then + for k, v in pairs (QBCore.Functions.GetQBPlayers()) do + 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) RegisterServerEvent('md-drugs:server:unbottle', function(item)