updated pharma to utilize nearby Players and give them the prescription directly

This commit is contained in:
Mustache Dom committed 2024-11-23 02:21:39 -08:00
1 parent 5c5f454207
commit e83cddd96f
2 files changed
+27 -32

No files matched your search

+12 -22
View File
@@ -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)
+15 -10
View File
@@ -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)