mirror of
https://github.com/jimathy/jim-consumables.git
synced 2026-08-19 07:26:04 +01:00
Tidy + upgrade
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
local QBCore = exports['qb-core']:GetCoreObject()
|
local QBCore = exports['qb-core']:GetCoreObject()
|
||||||
|
|
||||||
PlayerJob = {}
|
|
||||||
local alcoholCount = 0
|
local alcoholCount = 0
|
||||||
local drugCount = 0
|
local drugCount = 0
|
||||||
|
|
||||||
@@ -16,7 +15,6 @@ end
|
|||||||
|
|
||||||
local consuming = false
|
local consuming = false
|
||||||
local cancelled = false
|
local cancelled = false
|
||||||
local attachProp, attachProp2
|
|
||||||
|
|
||||||
RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
||||||
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Starting event, locking inventory and grabbing data^7..") end
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Starting event, locking inventory and grabbing data^7..") end
|
||||||
@@ -26,8 +24,7 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
|||||||
local animDict = tostring(emote[1])
|
local animDict = tostring(emote[1])
|
||||||
local anim = tostring(emote[2])
|
local anim = tostring(emote[2])
|
||||||
local model, model2, bone, bone2, drugeffect, stress
|
local model, model2, bone, bone2, drugeffect, stress
|
||||||
local P1, P2, P3, P4, P5, P6 = table.unpack({0.0, 0.0, 0.0, 0.0, 0.0, 0.0})
|
local P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12 = table.unpack({0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}) -- Default placement coord cariable
|
||||||
local P12, P22, P32, P42, P52, P62 = table.unpack({0.0, 0.0, 0.0, 0.0, 0.0, 0.0})
|
|
||||||
if emote.AnimationOptions.Prop then
|
if emote.AnimationOptions.Prop then
|
||||||
model = emote.AnimationOptions.Prop
|
model = emote.AnimationOptions.Prop
|
||||||
bone = GetPedBoneIndex(PlayerPedId(), emote.AnimationOptions.PropBone)
|
bone = GetPedBoneIndex(PlayerPedId(), emote.AnimationOptions.PropBone)
|
||||||
@@ -35,7 +32,7 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
|||||||
if emote.AnimationOptions.SecondProp then
|
if emote.AnimationOptions.SecondProp then
|
||||||
model2 = emote.AnimationOptions.SecondProp
|
model2 = emote.AnimationOptions.SecondProp
|
||||||
bone2 = GetPedBoneIndex(PlayerPedId(), emote.AnimationOptions.SecondPropBone)
|
bone2 = GetPedBoneIndex(PlayerPedId(), emote.AnimationOptions.SecondPropBone)
|
||||||
P12, P22, P32, P42, P52, P62 = table.unpack(emote.AnimationOptions.SecondPropPlacement)
|
P7, P8, P9, P10, P11, P12 = table.unpack(emote.AnimationOptions.SecondPropPlacement)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local time = Config.Consumables[itemName].time or math.random(5000, 6000)
|
local time = Config.Consumables[itemName].time or math.random(5000, 6000)
|
||||||
@@ -86,18 +83,18 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
|||||||
consuming = true
|
consuming = true
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
--Prop Spawning
|
--Prop Spawning
|
||||||
if model then
|
if model and IsModelValid(model) == 1 then
|
||||||
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Spawning consumable prop^7.") end
|
if Config.Debug then print("^5Debug^7: ^3PropSpawn^7: ^2Spawning consumable prop^7.") end
|
||||||
attachProp = makeProp({ prop = model, coords = vector4(0.0,0.0,0.0,0.0)}, 1, 1)
|
attachProp = makeProp({ prop = model, coords = vector4(0.0,0.0,0.0,0.0)}, 1, 1)
|
||||||
AttachEntityToEntity(attachProp, PlayerPedId(), bone, P1, P2, P3, P4, P5, P6, true, true, false, true, 1, true)
|
AttachEntityToEntity(attachProp, PlayerPedId(), bone, P1, P2, P3, P4, P5, P6, true, true, false, true, 1, true)
|
||||||
if model2 then
|
if model2 and IsModelValid(model2) == 1 then
|
||||||
attachProp2 = makeProp({ prop = model2, coords = vector4(0.0,0.0,0.0,0.0)}, 1, 1)
|
attachProp2 = makeProp({ prop = model2, coords = vector4(0.0,0.0,0.0,0.0)}, 1, 1)
|
||||||
AttachEntityToEntity(attachProp2, PlayerPedId(), bone2, P12, P22, P32, P42, P52, P62, true, true, false, true, 1, true)
|
AttachEntityToEntity(attachProp2, PlayerPedId(), bone2, P7, P8, P9, P10, P11, P12, true, true, false, true, 1, true)
|
||||||
end
|
else print("^5Debug^7: ^3Consume^7: ^2Second prop model isn't valid/found^7.") end
|
||||||
while consuming do Wait(100) end
|
while consuming do Wait(50) end
|
||||||
destroyProp(attachProp)
|
if DoesEntityExist(attachProp) then destroyProp(attachProp) attachProp = nil end
|
||||||
if model2 then destroyProp(attachProp2) end
|
if DoesEntityExist(attachProp2) then destroyProp(attachProp2) attackProp = nil end
|
||||||
end
|
else print("^5Debug^7: ^3PropSpawnstop^7: ^2Prop model isn't valid/found^7.") end
|
||||||
end)
|
end)
|
||||||
while consuming do
|
while consuming do
|
||||||
if time <= 0 then consuming = false end
|
if time <= 0 then consuming = false end
|
||||||
@@ -168,7 +165,7 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
|||||||
end
|
end
|
||||||
if stats.canOD then
|
if stats.canOD then
|
||||||
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Current ^4drugCount^7: ^6"..(drugCount + 1)) end
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Current ^4drugCount^7: ^6"..(drugCount + 1)) end
|
||||||
drugCount = drugCount + 1
|
drugCount += 1
|
||||||
if drugCount >= 4 then
|
if drugCount >= 4 then
|
||||||
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Current ^4drugCount^7: ^6"..drugCount.."^7 - ^2 removing health") end
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Current ^4drugCount^7: ^6"..drugCount.."^7 - ^2 removing health") end
|
||||||
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) - math.random(10,15))
|
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) - math.random(10,15))
|
||||||
|
|||||||
Reference in New Issue
Block a user