patch for pharma, new callback to do animations and progressbar checks
This commit is contained in:
1 parent
f1ed2c0860
commit
cf5cfba909
7 files changed
+63
-68
No files matched your search
+38
-38
@@ -13,64 +13,64 @@ end
|
||||
QBCore.Functions.CreateUseableItem('prescription_pad', function(source, item)
|
||||
local src = source
|
||||
local near = {}
|
||||
|
||||
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})
|
||||
local ped, tped = GetPlayerPed(src), GetPlayerPed(v.PlayerData.source)
|
||||
local dist = #(GetEntityCoords(ped) - GetEntityCoords(tped))
|
||||
if dist < 5.0 then
|
||||
table.insert(near, {label = tname, value = targ.PlayerData.citizenid})
|
||||
end
|
||||
end
|
||||
local data = lib.callback.await('md-drugs:client:prescriptionpad', src, near)
|
||||
local options = { {label = 'Vicodin', value = 'vicodin_prescription'}, {label = 'Adderal', value = 'adderal_prescription'}, {label = 'Morphine', value = 'morphine_prescription'},{label = 'Xanax', value = 'xanax_prescription'}}
|
||||
local data = lib.callback.await('md-drugs:client:prescriptionpad', src, near, options)
|
||||
if type(data) == 'table' then
|
||||
local give = QBCore.Functions.GetPlayerByCitizenId(data.who)
|
||||
AddItem(give.PlayerData.source, data.what, 1)
|
||||
for i = 1, #options do
|
||||
if data.what == options[i].value then
|
||||
AddItem(give.PlayerData.source, data.what, 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('md-drugs:server:unbottle', function(item)
|
||||
local src = source
|
||||
local amount = math.random(10,30)
|
||||
AddItem(src, item, amount)
|
||||
Log(GetName(src) .. ' Unbottled '.. amount .. ' Of ' .. item .. '!', 'pharma')
|
||||
end
|
||||
end)
|
||||
|
||||
local pharmabottle = {'vicodinbottle', 'adderalbottle','morphinebottle','xanaxbottle'}
|
||||
for m, d in pairs (pharmabottle) do
|
||||
QBCore.Functions.CreateUseableItem(d, function(source, item)
|
||||
local src = source
|
||||
if RemoveItem(src, d, 1) then
|
||||
TriggerClientEvent("md-drugs:client:unbottle", src, item)
|
||||
end
|
||||
local Player = getPlayer(src)
|
||||
local check = lib.callback.await("md-drugs:client:unbottle", src)
|
||||
if check then
|
||||
local get = {
|
||||
['vicodinbottle'] = 'vicodin',
|
||||
['adderalbottle'] = 'adderal',
|
||||
['morphinebottle'] = 'morphine',
|
||||
['xanaxbottle'] = 'xanax'
|
||||
}
|
||||
for k, v in pairs (get) do
|
||||
if d == k then
|
||||
RemoveItem(src, d, 1)
|
||||
AddItem(src, v, math.random(10,30))
|
||||
Notifys(src,Lang.Pharma.unbottle, "success")
|
||||
Log(GetName(src) .. ' Unbottled 30 Of ' .. v .. '!', 'pharma')
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
RegisterServerEvent('md-drugs:server:fillprescription', function()
|
||||
local src = source
|
||||
local Player = getPlayer(src)
|
||||
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')
|
||||
if vic then
|
||||
RemoveItem(src,'vicodin_prescription', 1 )
|
||||
AddItem(src,'vicodinbottle', 1)
|
||||
Notifys(src,Lang.Pharma.pills, "success")
|
||||
elseif add then
|
||||
RemoveItem(src,'adderal_prescription', 1 )
|
||||
AddItem(src,'adderalbottle', 1)
|
||||
Notifys(src,Lang.Pharma.pills, "success")
|
||||
elseif mor then
|
||||
RemoveItem(src,'morphine_prescription', 1 )
|
||||
AddItem(src,'morphinebottle', 1)
|
||||
Notifys(src,Lang.Pharma.pills, "success")
|
||||
elseif xan then
|
||||
RemoveItem(src,'xanax_prescription', 1 )
|
||||
AddItem(src,'xanaxbottle', 1)
|
||||
Notifys(src,Lang.Pharma.pills, "success")
|
||||
else
|
||||
Notifys(src,Lang.Pharma.no, "error")
|
||||
local pres = {vicodin_prescription = 'vicodinbottle', adderal_prescription = 'adderalbottle', morphine_prescription = 'morphinebottle', xanax_prescription = 'xanaxbottle'}
|
||||
for k, v in pairs (pres) do
|
||||
if Player.Functions.GetItemByName(k) then
|
||||
RemoveItem(src, k, 1 )
|
||||
AddItem(src,v, 1)
|
||||
break
|
||||
end
|
||||
end
|
||||
Log(GetName(src) .. ' Filled A Prescription!', 'pharma')
|
||||
end)
|
||||
Reference in new issue
Block a user