Files
md-drugs/server/pharma.lua
T

93 lines
3.2 KiB
Lua
Raw Normal View History

2026-01-18 01:20:44 -07:00
Locations = Locations or {}
Locations.Pharma = {
2025-08-06 02:25:06 -06:00
FillPrescription = { -- where to fill out your prescription
{loc = vector3(2855.62, 4446.73, 48.53), l = 1.0, w = 1.0, rot = 45.0, gang = ""},
},
}
2026-01-18 01:20:44 -07:00
GlobalState.MDDrugsLocations = Locations
2025-08-09 03:10:00 -06:00
2025-07-18 01:19:12 -07:00
local function GetJob(source)
local src = source
2026-01-18 01:20:44 -07:00
local jobName = Bridge.Framework.GetPlayerJob(src)
return jobName == 'ambulance'
end
local function getNearby(src, distance)
local players = Bridge.Framework.GetPlayers()
local nearPlayers = {}
for index, sources in pairs(players) do
--if sources ~= src then
local target = GetEntityCoords(GetPlayerPed(sources))
local you = GetEntityCoords(GetPlayerPed(src))
local distanceBetween = #(you - target)
if distanceBetween <= distance then
table.insert(nearPlayers, {label = Bridge.Framework.GetPlayerName(sources), value = sources})
end
--end
end
return nearPlayers
end
2026-01-18 01:20:44 -07:00
Bridge.Framework.RegisterUsableItem('prescription_pad', function(source, item)
2023-12-07 15:45:48 -08:00
local src = source
local near = {}
2025-07-18 01:19:12 -07:00
if GetJob(src) then
2026-01-18 01:20:44 -07:00
near = getNearby(src, 5.0)
2025-07-18 01:19:12 -07:00
local options = {
2026-01-18 01:20:44 -07:00
{label = Bridge.Inventory.GetItemInfo('vicodin_prescription').label, value = 'vicodin_prescription'},
{label = Bridge.Inventory.GetItemInfo('adderal_prescription').label, value = 'adderal_prescription'},
{label = Bridge.Inventory.GetItemInfo('morphine_prescription').label, value = 'morphine_prescription'},
{label = Bridge.Inventory.GetItemInfo('xanax_prescription').label, value = 'xanax_prescription'}
2025-07-18 01:19:12 -07:00
}
2026-01-18 01:20:44 -07:00
local data = Bridge.Callback.Trigger('md-drugs:client:prescriptionpad', src, near, options)
2026-01-16 02:57:26 -07:00
if not data then return Bridge.Notify.SendNotify(src, Bridge.Language.Locale('pharma.canceled'), "error") end
2026-01-18 01:20:44 -07:00
Bridge.Framework.AddItem(data.who, data.what, 1)
end
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
2026-01-18 01:20:44 -07:00
Bridge.Framework.RegisterUsableItem(d, function(source, item)
2025-07-18 01:19:12 -07:00
local src = source
2026-01-18 01:20:44 -07:00
local check = Bridge.Callback.Trigger("md-drugs:client:unbottle", src)
2025-07-18 01:19:12 -07:00
if check then
local get = {
['vicodinbottle'] = 'vicodin',
['adderalbottle'] = 'adderal',
['morphinebottle'] = 'morphine',
['xanaxbottle'] = 'xanax'
}
for k, v in pairs (get) do
if d == k then
2026-01-18 01:20:44 -07:00
if Bridge.Framework.RemoveItem(src, d, 1) then
Bridge.Framework.AddItem(src, v, math.random(10,30))
2026-01-16 02:57:26 -07:00
Bridge.Notify.SendNotify(src,Bridge.Language.Locale('pharma.unbottle'), "success")
2025-08-06 02:25:06 -06:00
end
2025-07-18 01:19:12 -07:00
end
end
end
2025-07-18 01:19:12 -07:00
end)
2024-05-02 18:34:49 -07:00
end
2023-12-07 15:45:48 -08:00
2025-07-18 01:19:12 -07:00
RegisterServerEvent('md-drugs:server:fillprescription', function(num)
2024-05-02 18:34:49 -07:00
local src = source
2026-01-18 01:20:44 -07:00
if timeOut(src, 'md-drugs:server:fillprescription') then return end
2026-01-19 00:46:49 -07:00
if not checkDistance(src, Locations.Pharma.FillPrescription[num].loc, 3.5, 'md-drugs:server:fillprescription') then
return
2025-07-18 01:19:12 -07:00
end
local pres = {
vicodin_prescription = 'vicodinbottle',
adderal_prescription = 'adderalbottle',
morphine_prescription = 'morphinebottle',
xanax_prescription = 'xanaxbottle'
}
for k, v in pairs (pres) do
2026-01-18 01:20:44 -07:00
if Bridge.Framework.HasItem(src, k, 1) then
Bridge.Framework.RemoveItem(src, k, 1)
Bridge.Framework.AddItem(src, v, 1)
break
end
2024-05-02 18:34:49 -07:00
end
2024-05-17 18:27:56 -07:00
end)