Files
md-drugs/server/pharma.lua
T

84 lines
2.7 KiB
Lua
Raw Normal View History

2023-12-07 15:45:48 -08:00
local QBCore = exports['qb-core']:GetCoreObject()
local function GetJob(source)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if Player.PlayerData.job.type == 'ems' then
return true
else
return false
end
end
2024-05-02 18:34:49 -07:00
QBCore.Functions.CreateUseableItem('prescription_pad', function(source, item)
2023-12-07 15:45:48 -08:00
local src = source
if GetJob(src) then
2024-05-02 18:34:49 -07:00
TriggerClientEvent("md-drugs:client:prescriptionpad", src, item)
end
2023-12-07 15:45:48 -08:00
end)
2024-05-02 18:34:49 -07:00
RegisterServerEvent('md-drugs:server:giveprescription', function(item)
2023-12-07 15:45:48 -08:00
local src = source
if GetJob(src) then
AddItem(src, item, 1)
Log(GetName(src) .. ' Made A Prescription Of ' .. item .. '!', 'pharma')
end
2023-12-07 15:45:48 -08:00
end)
2024-05-02 18:34:49 -07:00
RegisterServerEvent('md-drugs:server:unbottle', function(item)
2023-12-07 15:45:48 -08:00
local src = source
2024-05-02 18:34:49 -07:00
local amount = math.random(10,30)
AddItem(src, item, amount)
Log(GetName(src) .. ' Unbottled '.. amount .. ' Of ' .. item .. '!', 'pharma')
2023-12-07 15:45:48 -08:00
end)
2024-05-02 18:34:49 -07:00
local pharmabottle = {'vicodinbottle', 'adderalbottle','morphinebottle','xanaxbottle'}
for m, d in pairs (pharmabottle) do
QBCore.Functions.CreateUseableItem(d, function(source, item)
2023-12-07 15:45:48 -08:00
local src = source
if RemoveItem(src, d, 1) then
2024-05-02 18:34:49 -07:00
TriggerClientEvent("md-drugs:client:unbottle", src, item)
end
2023-12-07 15:45:48 -08:00
end)
2024-05-02 18:34:49 -07:00
end
2023-12-07 15:45:48 -08:00
local pharmadrugs = { "adderal", "vicodin", "xanax", "morphine"}
for k, v in pairs (pharmadrugs) do QBCore.Functions.CreateUseableItem(v, function(source, item)
local src = source
if TriggerClientEvent('md-drugs:client:takepharma', src, item.name) then
RemoveItem(src, item.name, 1)
Log(GetName(source) .. ' Took ' .. item.name .. '!', 'pharma')
2023-12-07 15:45:48 -08:00
end
end)
end
2024-05-02 18:34:49 -07:00
RegisterServerEvent('md-drugs:server:fillprescription', function()
local src = source
local Player = QBCore.Functions.GetPlayer(src)
2024-05-18 13:18:25 -07:00
local vic = Player.Functions.GetItemByName('vicodin_prescription')
local add = Player.Functions.GetItemByName('adderal_prescription')
local mor = Player.Functions.GetItemByName('morphine_prescription')
local xan = Player.Functions.GetItemByName('xanax_prescription')
2024-05-17 18:27:56 -07:00
if vic then
RemoveItem(src,'vicodin_prescription', 1 )
AddItem(src,'vicodinbottle', 1)
Notifys(src,Lang.Pharma.pills, "success")
2024-05-17 18:27:56 -07:00
elseif add then
RemoveItem(src,'adderal_prescription', 1 )
AddItem(src,'adderalbottle', 1)
Notifys(src,Lang.Pharma.pills, "success")
2024-05-17 18:27:56 -07:00
elseif mor then
RemoveItem(src,'morphine_prescription', 1 )
AddItem(src,'morphinebottle', 1)
Notifys(src,Lang.Pharma.pills, "success")
2024-05-02 18:34:49 -07:00
2024-05-17 18:27:56 -07:00
elseif xan then
RemoveItem(src,'xanax_prescription', 1 )
AddItem(src,'xanaxbottle', 1)
Notifys(src,Lang.Pharma.pills, "success")
2024-05-02 18:34:49 -07:00
else
Notifys(src,Lang.Pharma.no, "error")
2024-05-02 18:34:49 -07:00
end
Log(GetName(src) .. ' Filled A Prescription!', 'pharma')
2024-05-17 18:27:56 -07:00
end)