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