2022-04-13 20:01:09 +01:00
|
|
|
local QBCore = exports['qb-core']:GetCoreObject()
|
|
|
|
|
|
|
|
|
|
PlayerJob = {}
|
|
|
|
|
local alcoholCount = 0
|
|
|
|
|
local drugCount = 0
|
|
|
|
|
|
2022-07-20 15:51:38 +01:00
|
|
|
local time = 40
|
|
|
|
|
function loadModel(model) if not HasModelLoaded(model) then if Config.Debug then print("^5Debug^7: ^2Loading Model^7: '^6"..model.."^7'") end while not HasModelLoaded(model) do if time > 0 then time = time - 1 RequestModel(model) else time = 40 break end Wait(10) end end end
|
|
|
|
|
function unloadModel(model) if Config.Debug then print("^5Debug^7: ^2Removing Model^7: '^6"..model.."^7'") end SetModelAsNoLongerNeeded(model) end
|
|
|
|
|
function loadAnimDict(dict) if Config.Debug then print("^5Debug^7: ^2Loading Anim Dictionary^7: '^6"..dict.."^7'") end while not HasAnimDictLoaded(dict) do RequestAnimDict(dict) Wait(5) end end
|
|
|
|
|
function unloadAnimDict(dict) if Config.Debug then print("^5Debug^7: ^2Removing Anim Dictionary^7: '^6"..dict.."^7'") end RemoveAnimDict(dict) end
|
|
|
|
|
function destroyProp(entity) if Config.Debug then print("^5Debug^7: ^2Destroying Prop^7: '^6"..entity.."^7'") end SetEntityAsMissionEntity(entity) Wait(5) DetachEntity(entity, true, true) Wait(5) DeleteObject(entity) end
|
|
|
|
|
|
|
|
|
|
--Convert Prop Model Names to Model HashKeys now to be more optimized when loading later
|
|
|
|
|
for k in pairs(Config.Emotes) do
|
|
|
|
|
if Config.Emotes[k].AnimationOptions.Prop then
|
|
|
|
|
Config.Emotes[k].AnimationOptions.Prop = GetHashKey(Config.Emotes[k].AnimationOptions.Prop)
|
|
|
|
|
end
|
|
|
|
|
end
|
2022-04-13 20:01:09 +01:00
|
|
|
|
2022-07-21 17:23:47 +01:00
|
|
|
--Screen Effects
|
2022-07-20 15:51:38 +01:00
|
|
|
local alienEffect = false
|
2022-04-13 20:01:09 +01:00
|
|
|
function AlienEffect()
|
2022-07-20 15:51:38 +01:00
|
|
|
if alienEffect then return end
|
|
|
|
|
alienEffect = true
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^3AlienEffect^7() ^2activated") end
|
2022-07-21 17:23:47 +01:00
|
|
|
AnimpostfxPlay("DrugsMichaelAliensFightIn", 3.0, 0)
|
2022-04-13 20:01:09 +01:00
|
|
|
Wait(math.random(5000, 8000))
|
2022-07-20 15:51:38 +01:00
|
|
|
local Ped = PlayerPedId()
|
|
|
|
|
local animDict = "MOVE_M@DRUNK@VERYDRUNK"
|
|
|
|
|
loadAnimDict(animDict)
|
|
|
|
|
SetPedCanRagdoll(Ped, true)
|
2022-04-13 20:01:09 +01:00
|
|
|
ShakeGameplayCam('DRUNK_SHAKE', 2.80)
|
|
|
|
|
SetTimecycleModifier("Drunk")
|
2022-07-20 15:51:38 +01:00
|
|
|
SetPedMovementClipset(Ped, animDict, 1)
|
|
|
|
|
SetPedMotionBlur(Ped, true)
|
|
|
|
|
SetPedIsDrunk(Ped, true)
|
2022-04-13 20:01:09 +01:00
|
|
|
Wait(1500)
|
2022-07-20 15:51:38 +01:00
|
|
|
SetPedToRagdoll(Ped, 5000, 1000, 1, 0, 0, 0)
|
2022-04-13 20:01:09 +01:00
|
|
|
Wait(13500)
|
2022-07-20 15:51:38 +01:00
|
|
|
SetPedToRagdoll(Ped, 5000, 1000, 1, 0, 0, 0)
|
2022-04-13 20:01:09 +01:00
|
|
|
Wait(120500)
|
|
|
|
|
ClearTimecycleModifier()
|
|
|
|
|
ResetScenarioTypesEnabled()
|
2022-07-20 15:51:38 +01:00
|
|
|
ResetPedMovementClipset(Ped, 0)
|
|
|
|
|
SetPedIsDrunk(Ped, false)
|
|
|
|
|
SetPedMotionBlur(Ped, false)
|
2022-04-13 20:01:09 +01:00
|
|
|
AnimpostfxStopAll()
|
|
|
|
|
ShakeGameplayCam('DRUNK_SHAKE', 0.0)
|
2022-07-21 17:23:47 +01:00
|
|
|
AnimpostfxPlay("DrugsMichaelAliensFight", 3.0, 0)
|
2022-07-05 23:14:01 +01:00
|
|
|
Wait(math.random(45000, 60000))
|
2022-07-21 17:23:47 +01:00
|
|
|
AnimpostfxPlay("DrugsMichaelAliensFightOut", 3.0, 0)
|
|
|
|
|
AnimpostfxStop("DrugsMichaelAliensFightIn")
|
|
|
|
|
AnimpostfxStop("DrugsMichaelAliensFight")
|
|
|
|
|
AnimpostfxStop("DrugsMichaelAliensFightOut")
|
2022-07-20 15:51:38 +01:00
|
|
|
alienEffect = false
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^3AlienEffect^7() ^2stopped") end
|
2022-04-13 20:01:09 +01:00
|
|
|
end
|
2022-07-20 15:51:38 +01:00
|
|
|
local weedEffect = false
|
2022-04-18 19:55:54 +01:00
|
|
|
function WeedEffect()
|
2022-07-20 15:51:38 +01:00
|
|
|
if weedEffect then return end
|
|
|
|
|
weedEffect = true
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^3WeedEffect^7() ^2activated") end
|
2022-07-21 17:23:47 +01:00
|
|
|
AnimpostfxPlay("DrugsMichaelAliensFightIn", 3.0, 0)
|
2022-04-18 19:55:54 +01:00
|
|
|
Wait(math.random(3000, 20000))
|
2022-07-21 17:23:47 +01:00
|
|
|
AnimpostfxPlay("DrugsMichaelAliensFight", 3.0, 0)
|
2022-04-18 19:55:54 +01:00
|
|
|
Wait(math.random(15000, 20000))
|
2022-07-21 17:23:47 +01:00
|
|
|
AnimpostfxPlay("DrugsMichaelAliensFightOut", 3.0, 0)
|
|
|
|
|
AnimpostfxStop("DrugsMichaelAliensFightIn")
|
|
|
|
|
AnimpostfxStop("DrugsMichaelAliensFight")
|
|
|
|
|
AnimpostfxStop("DrugsMichaelAliensFightOut")
|
2022-07-20 15:51:38 +01:00
|
|
|
weedEffect = false
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^3WeedEffect^7() ^2stopped") end
|
2022-04-18 19:55:54 +01:00
|
|
|
end
|
2022-07-20 15:51:38 +01:00
|
|
|
local trevorEffect = false
|
2022-04-18 19:55:54 +01:00
|
|
|
function TrevorEffect()
|
2022-07-20 15:51:38 +01:00
|
|
|
if trevorEffect then return end
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^3TrevorEffect^7() ^2activated") end
|
|
|
|
|
trevorEffect = true
|
2022-07-21 17:23:47 +01:00
|
|
|
AnimpostfxPlay("DrugsTrevorClownsFightIn", 3.0, 0)
|
2022-04-18 19:55:54 +01:00
|
|
|
Wait(3000)
|
2022-07-21 17:23:47 +01:00
|
|
|
AnimpostfxPlay("DrugsTrevorClownsFight", 3.0, 0)
|
2022-04-18 19:55:54 +01:00
|
|
|
Wait(30000)
|
2022-07-21 17:23:47 +01:00
|
|
|
AnimpostfxPlay("DrugsTrevorClownsFightOut", 3.0, 0)
|
|
|
|
|
AnimpostfxStop("DrugsTrevorClownsFight")
|
|
|
|
|
AnimpostfxStop("DrugsTrevorClownsFightIn")
|
|
|
|
|
AnimpostfxStop("DrugsTrevorClownsFightOut")
|
2022-07-20 15:51:38 +01:00
|
|
|
trevorEffect = false
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^3TrevorEffect^7() ^2stopped") end
|
2022-04-18 19:55:54 +01:00
|
|
|
end
|
2022-07-21 17:23:47 +01:00
|
|
|
local turboEffect = false
|
|
|
|
|
function TurboEffect()
|
|
|
|
|
if turboEffect then return end
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^3TurboEffect^7() ^2activated") end
|
|
|
|
|
turboEffect = true
|
|
|
|
|
AnimpostfxPlay('RaceTurbo', 0, true)
|
|
|
|
|
SetTimecycleModifier('rply_motionblur')
|
|
|
|
|
ShakeGameplayCam('SKY_DIVING_SHAKE', 0.25)
|
|
|
|
|
Wait(30000)
|
|
|
|
|
StopGameplayCamShaking(true)
|
|
|
|
|
SetTransitionTimecycleModifier('default', 0.35)
|
|
|
|
|
Wait(1000)
|
|
|
|
|
ClearTimecycleModifier()
|
|
|
|
|
AnimpostfxStop('RaceTurbo')
|
|
|
|
|
turboEffect = false
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^3TurboEffect^7() ^2stopped") end
|
|
|
|
|
end
|
|
|
|
|
local rampageEffect = false
|
|
|
|
|
function RampageEffect()
|
|
|
|
|
if rampageEffect then return end
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^3RampageEffect^7() ^2activated") end
|
|
|
|
|
rampageEffect = true
|
|
|
|
|
AnimpostfxPlay('Rampage', 0, true)
|
|
|
|
|
SetTimecycleModifier('rply_motionblur')
|
|
|
|
|
ShakeGameplayCam('SKY_DIVING_SHAKE', 0.25)
|
|
|
|
|
Wait(30000)
|
|
|
|
|
StopGameplayCamShaking(true)
|
|
|
|
|
SetTransitionTimecycleModifier('default', 0.35)
|
|
|
|
|
Wait(1000)
|
|
|
|
|
ClearTimecycleModifier()
|
|
|
|
|
AnimpostfxStop('Rampage')
|
|
|
|
|
rampageEffect = false
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^3RampageEffect^7() ^2stopped") end
|
|
|
|
|
end
|
|
|
|
|
local focusEffect = false
|
|
|
|
|
function FocusEffect()
|
|
|
|
|
if focusEffect then return end
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^3FocusEffect^7() ^2activated") end
|
|
|
|
|
focusEffect = true
|
|
|
|
|
AnimpostfxPlay('FocusIn', 0, true)
|
|
|
|
|
Wait(30000)
|
|
|
|
|
Wait(1000)
|
|
|
|
|
AnimpostfxStop('FocusIn')
|
|
|
|
|
focusEffect = false
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^3FocusEffect^7() ^2stopped") end
|
2022-04-13 20:01:09 +01:00
|
|
|
end
|
2022-07-20 15:51:38 +01:00
|
|
|
|
2022-07-21 17:23:47 +01:00
|
|
|
--Built-in Buff effects
|
2022-07-20 15:51:38 +01:00
|
|
|
local healEffect = false
|
2022-07-21 17:23:47 +01:00
|
|
|
function HealEffect(data)
|
2022-07-20 15:51:38 +01:00
|
|
|
if healEffect then return end
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^3HealEffect^7() ^2activated") end
|
|
|
|
|
healEffect = true
|
2022-07-21 17:23:47 +01:00
|
|
|
local count = (data[1] / 1000)
|
2022-05-25 10:23:19 +01:00
|
|
|
while count > 0 do
|
|
|
|
|
Wait(1000)
|
|
|
|
|
count = count - 1
|
2022-07-21 17:23:47 +01:00
|
|
|
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) + data[2])
|
2022-05-25 10:23:19 +01:00
|
|
|
end
|
2022-07-20 15:51:38 +01:00
|
|
|
healEffect = false
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^3HealEffect^7() ^2stopped") end
|
2022-05-25 10:23:19 +01:00
|
|
|
end
|
2022-04-13 20:01:09 +01:00
|
|
|
|
2022-07-20 15:51:38 +01:00
|
|
|
local staminaEffect = false
|
2022-07-21 17:23:47 +01:00
|
|
|
function StaminaEffect(data)
|
2022-07-20 15:51:38 +01:00
|
|
|
if staminaEffect then return end
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^3StaminaEffect^7() ^2activated") end
|
|
|
|
|
staminaEffect = true
|
2022-07-21 17:23:47 +01:00
|
|
|
local startStamina = (data[1] / 1000)
|
2022-04-13 20:01:09 +01:00
|
|
|
SetRunSprintMultiplierForPlayer(PlayerId(), 1.49)
|
|
|
|
|
while startStamina > 0 do
|
|
|
|
|
Wait(1000)
|
2022-07-21 17:23:47 +01:00
|
|
|
if math.random(5, 100) < 10 then RestorePlayerStamina(PlayerId(), data[2]) end
|
2022-04-13 20:01:09 +01:00
|
|
|
startStamina = startStamina - 1
|
2022-04-18 19:55:54 +01:00
|
|
|
if math.random(5, 100) < 51 then end
|
2022-04-13 20:01:09 +01:00
|
|
|
end
|
|
|
|
|
startStamina = 0
|
|
|
|
|
SetRunSprintMultiplierForPlayer(PlayerId(), 1.0)
|
2022-07-20 15:51:38 +01:00
|
|
|
staminaEffect = false
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^3StaminaEffect^7() ^2stopped") end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function StopEffects()
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^2All screen effects stopped") end
|
|
|
|
|
ShakeGameplayCam('DRUNK_SHAKE', 0.0)
|
|
|
|
|
SetPedToRagdoll(PlayerPedId(), 5000, 1000, 1, 0, 0, 0)
|
|
|
|
|
ClearTimecycleModifier()
|
|
|
|
|
ResetScenarioTypesEnabled()
|
|
|
|
|
ResetPedMovementClipset(PlayerPedId(), 0)
|
|
|
|
|
SetPedIsDrunk(PlayerPedId(), false)
|
|
|
|
|
SetPedMotionBlur(PlayerPedId(), false)
|
2022-07-21 17:23:47 +01:00
|
|
|
AnimpostfxStop("DrugsMichaelAliensFightIn")
|
|
|
|
|
AnimpostfxStop("DrugsMichaelAliensFight")
|
|
|
|
|
AnimpostfxStop("DrugsMichaelAliensFightOut")
|
|
|
|
|
AnimpostfxStop("DrugsTrevorClownsFight")
|
|
|
|
|
AnimpostfxStop("DrugsTrevorClownsFightIn")
|
|
|
|
|
AnimpostfxStop("DrugsTrevorClownsFightOut")
|
|
|
|
|
AnimpostfxStop('RaceTurbo')
|
|
|
|
|
AnimpostfxStop('FocusIn')
|
|
|
|
|
AnimpostfxStop('Rampage')
|
2022-04-13 20:01:09 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local consuming = false
|
|
|
|
|
local cancelled = false
|
|
|
|
|
|
2022-04-18 19:55:54 +01:00
|
|
|
RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
2022-07-20 15:51:38 +01:00
|
|
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Starting event, locking inventory and grabbing data^7..") end
|
2022-07-14 15:25:20 +01:00
|
|
|
LocalPlayer.state:set("inv_busy", true, true)
|
2022-04-13 20:01:09 +01:00
|
|
|
local Player = PlayerPedId()
|
|
|
|
|
local emote = Config.Emotes[Config.Consumables[itemName].emote]
|
|
|
|
|
local animDict = tostring(emote[1])
|
|
|
|
|
local anim = tostring(emote[2])
|
2022-07-20 15:51:38 +01:00
|
|
|
local model, bone, drugeffect, stress
|
2022-04-13 20:01:09 +01:00
|
|
|
local P1, P2, P3, P4, P5, P6 = table.unpack({0.0, 0.0, 0.0, 0.0, 0.0, 0.0})
|
|
|
|
|
if emote.AnimationOptions.Prop then
|
2022-07-20 15:51:38 +01:00
|
|
|
model = emote.AnimationOptions.Prop
|
2022-04-13 20:01:09 +01:00
|
|
|
bone = GetPedBoneIndex(PlayerPedId(), emote.AnimationOptions.PropBone)
|
|
|
|
|
P1, P2, P3, P4, P5, P6 = table.unpack(emote.AnimationOptions.PropPlacement)
|
|
|
|
|
end
|
2022-07-20 15:51:38 +01:00
|
|
|
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
|
|
|
|
|
local heal = Config.Consumables[itemName].heal or 0
|
|
|
|
|
local armor = Config.Consumables[itemName].armor or 0
|
2022-04-13 20:01:09 +01:00
|
|
|
if type == "drink" or type == "alcohol" then string = "Drinking " end
|
|
|
|
|
if type == "food" then string = "Eating " end
|
|
|
|
|
if type == "drug" then string = "Using " end
|
2022-07-05 23:14:01 +01:00
|
|
|
|
2022-04-13 20:01:09 +01:00
|
|
|
if consuming then
|
|
|
|
|
cancelled = true
|
2022-07-20 15:51:38 +01:00
|
|
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Event already started^7, ^1Cancelling^7.") end
|
2022-07-14 15:25:20 +01:00
|
|
|
LocalPlayer.state:set("inv_busy", false, true)
|
2022-04-13 20:01:09 +01:00
|
|
|
TriggerEvent("QBCore:Notify", "Stopped "..string, "error")
|
|
|
|
|
consuming = not consuming
|
|
|
|
|
return
|
|
|
|
|
end
|
2022-07-05 23:14:01 +01:00
|
|
|
|
2022-05-25 10:23:19 +01:00
|
|
|
--Emote Stuff
|
2022-07-20 15:51:38 +01:00
|
|
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Grabbing Emote Animation Options^7...") end
|
2022-04-13 20:01:09 +01:00
|
|
|
if emote.AnimationOptions then
|
|
|
|
|
if emote.AnimationOptions.EmoteLoop then MovementType = 1
|
|
|
|
|
if emote.AnimationOptions.EmoteMoving then MovementType = 51
|
|
|
|
|
end
|
|
|
|
|
elseif emote.AnimationOptions.EmoteMoving then MovementType = 51
|
|
|
|
|
elseif emote.AnimationOptions.EmoteMoving == false then MovementType = 0
|
|
|
|
|
elseif emote.AnimationOptions.EmoteStuck then MovementType = 50
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
else MovementType = 0 end
|
2022-07-20 15:51:38 +01:00
|
|
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Checking if player is in a vehicle^7...") end
|
|
|
|
|
local InVehicle = IsPedInAnyVehicle(PlayerPedId(), true)
|
2022-04-13 20:01:09 +01:00
|
|
|
if InVehicle == 1 then MovementType = 51 end
|
|
|
|
|
|
2022-05-25 10:23:19 +01:00
|
|
|
--Load and Start animation
|
2022-07-20 15:51:38 +01:00
|
|
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Playing Animation^7...") end
|
2022-04-13 20:01:09 +01:00
|
|
|
loadAnimDict(animDict)
|
2022-07-20 15:51:38 +01:00
|
|
|
TaskPlayAnim(PlayerPedId(), animDict, anim, 1.0, 1.0, -1, MovementType, 0, 0, 0, 0)
|
|
|
|
|
|
2022-04-13 20:01:09 +01:00
|
|
|
TriggerEvent("QBCore:Notify", string..QBCore.Shared.Items[itemName].label.."..", "success", (time + 1000))
|
|
|
|
|
consuming = true
|
2022-07-20 13:43:17 +01:00
|
|
|
|
|
|
|
|
CreateThread(function()
|
|
|
|
|
--Prop Spawning
|
|
|
|
|
if model then
|
2022-07-20 15:51:38 +01:00
|
|
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Spawning consumable prop^7.") end
|
|
|
|
|
loadModel(model)
|
|
|
|
|
local attachProp = CreateObject(model, 1.0, 1.0, 1.0, 1, 1, 0)
|
2022-07-20 13:43:17 +01:00
|
|
|
AttachEntityToEntity(attachProp, PlayerPedId(), bone, P1, P2, P3, P4, P5, P6, true, true, false, true, 1, true)
|
2022-07-20 15:51:38 +01:00
|
|
|
while consuming do Wait(100) end
|
|
|
|
|
destroyProp(attachProp)
|
2022-07-20 13:43:17 +01:00
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
2022-04-13 20:01:09 +01:00
|
|
|
while consuming do
|
2022-04-18 19:55:54 +01:00
|
|
|
if time <= 0 then consuming = false end
|
2022-04-13 20:01:09 +01:00
|
|
|
if IsControlJustPressed(0, 21) then
|
|
|
|
|
consuming = false
|
|
|
|
|
cancelled = true
|
2022-07-14 15:25:20 +01:00
|
|
|
LocalPlayer.state:set("inv_busy", false, true)
|
2022-04-13 20:01:09 +01:00
|
|
|
end
|
|
|
|
|
Wait(10)
|
|
|
|
|
time = time - 10
|
|
|
|
|
end
|
2022-07-05 23:14:01 +01:00
|
|
|
|
2022-07-20 15:51:38 +01:00
|
|
|
StopEntityAnim(PlayerPedId(), anim, animDict, 1.0)
|
|
|
|
|
unloadAnimDict(animDict)
|
2022-07-05 23:14:01 +01:00
|
|
|
|
2022-04-13 20:01:09 +01:00
|
|
|
if not cancelled then
|
|
|
|
|
TriggerServerEvent("QBCore:Server:RemoveItem", itemName, 1)
|
2022-07-20 15:51:38 +01:00
|
|
|
TriggerEvent("inventory:client:ItemBox", QBCore.Shared.Items[itemName], "remove", 1)
|
2022-04-13 20:01:09 +01:00
|
|
|
|
2022-07-05 23:14:01 +01:00
|
|
|
if QBCore.Shared.Items[itemName].thirst then
|
2022-04-13 20:01:09 +01:00
|
|
|
TriggerServerEvent("QBCore:Server:SetMetaData", "thirst", QBCore.Functions.GetPlayerData().metadata["thirst"] + QBCore.Shared.Items[itemName].thirst) end
|
2022-07-05 23:14:01 +01:00
|
|
|
if QBCore.Shared.Items[itemName].hunger then
|
2022-04-13 20:01:09 +01:00
|
|
|
TriggerServerEvent("QBCore:Server:SetMetaData", "hunger", QBCore.Functions.GetPlayerData().metadata["hunger"] + QBCore.Shared.Items[itemName].hunger) end
|
|
|
|
|
|
|
|
|
|
if not QBCore.Shared.Items[itemName].thirst and not QBCore.Shared.Items[itemName].hunger then
|
2022-05-25 10:23:19 +01:00
|
|
|
local hunger = 0
|
|
|
|
|
local thirst = 0
|
2022-07-06 20:48:08 +01:00
|
|
|
if Config.Consumables[itemName].stats then
|
2022-07-05 23:14:01 +01:00
|
|
|
if Config.Consumables[itemName].stats.hunger then hunger = Config.Consumables[itemName].stats.hunger end
|
|
|
|
|
TriggerServerEvent("QBCore:Server:SetMetaData", "hunger", QBCore.Functions.GetPlayerData().metadata["hunger"] + hunger)
|
|
|
|
|
if Config.Consumables[itemName].stats.thirst then thirst = Config.Consumables[itemName].stats.thirst end
|
|
|
|
|
TriggerServerEvent("QBCore:Server:SetMetaData", "thirst", QBCore.Functions.GetPlayerData().metadata["thirst"] + thirst)
|
|
|
|
|
end
|
2022-04-13 20:01:09 +01:00
|
|
|
end
|
2022-07-05 23:14:01 +01:00
|
|
|
|
2022-07-20 15:51:38 +01:00
|
|
|
if stress and stress ~= 0 then
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Reliving ^6"..stress.." ^2stress^7.") end
|
|
|
|
|
TriggerServerEvent('hud:server:RelieveStress', stress)
|
|
|
|
|
end
|
2022-07-05 23:14:01 +01:00
|
|
|
|
2022-07-20 15:51:38 +01:00
|
|
|
if heal and heal ~= 0 then
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Healing player by^7: ^6"..heal) end
|
|
|
|
|
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) + heal)
|
|
|
|
|
end
|
2022-07-05 23:14:01 +01:00
|
|
|
|
2022-07-20 15:51:38 +01:00
|
|
|
if armor and armor ~= 0 then
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Adding ^6"..armor.." ^2armour^7.") end
|
|
|
|
|
TriggerServerEvent('hospital:server:SetArmor', (GetPedArmour(PlayerPedId()) + armor)) SetPedArmour(PlayerPedId(), (GetPedArmour(PlayerPedId()) + armor))
|
|
|
|
|
end
|
2022-04-18 19:55:54 +01:00
|
|
|
|
2022-04-13 20:01:09 +01:00
|
|
|
if type == "alcohol" then
|
2022-07-20 15:51:38 +01:00
|
|
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Current ^4alcoholCount^7: ^6"..(alcoholCount + 1)) end
|
2022-04-13 20:01:09 +01:00
|
|
|
alcoholCount = alcoholCount + 1
|
|
|
|
|
if alcoholCount > 1 and alcoholCount < 4 then
|
|
|
|
|
TriggerEvent("evidence:client:SetStatus", "alcohol", 200)
|
|
|
|
|
elseif alcoholCount >= 4 then
|
|
|
|
|
TriggerEvent("evidence:client:SetStatus", "heavyalcohol", 200)
|
2022-07-21 17:23:47 +01:00
|
|
|
CreateThread(function() AlienEffect() end) -- Used as overdosing/too drunk effect
|
2022-07-20 15:51:38 +01:00
|
|
|
end
|
2022-04-13 20:01:09 +01:00
|
|
|
end
|
2022-07-05 23:14:01 +01:00
|
|
|
|
2022-07-21 17:23:47 +01:00
|
|
|
stats = Config.Consumables[itemName].stats or nil
|
|
|
|
|
|
|
|
|
|
if Config.Consumables[itemName].stats then
|
|
|
|
|
if stats.screen then -- Screen effect activation
|
|
|
|
|
if stats.screen == "turbo" then CreateThread(function() TurboEffect() end) end
|
|
|
|
|
if stats.screen == "focus" then CreateThread(function() FocusEffect() end) end
|
|
|
|
|
if stats.screen == "rampage" then CreateThread(function() RampageEffect() end) end
|
|
|
|
|
if stats.screen == "weed" then CreateThread(function() WeedEffect() end) end
|
|
|
|
|
if stats.screen == "trevor" then CreateThread(function() TrevorEffect() end) end
|
|
|
|
|
end
|
2022-04-13 20:01:09 +01:00
|
|
|
|
2022-07-20 15:51:38 +01:00
|
|
|
if stats.canOD then
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Current ^4drugCount^7: ^6"..(drugCount + 1)) end
|
2022-04-18 19:55:54 +01:00
|
|
|
drugCount = drugCount + 1
|
2022-04-13 20:01:09 +01:00
|
|
|
if drugCount >= 4 then
|
2022-07-20 15:51:38 +01:00
|
|
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Current ^4drugCount^7: ^6"..drugCount.."^7 - ^2 removing health") end
|
2022-04-18 19:55:54 +01:00
|
|
|
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) - math.random(10,15))
|
2022-07-21 17:23:47 +01:00
|
|
|
if drugCount >= 7 then
|
|
|
|
|
CreateThread(function() AlienEffect() end) -- If too many drugs, if not dead will make you stumble
|
2022-04-13 20:01:09 +01:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2022-07-20 15:51:38 +01:00
|
|
|
if stats.effect == "heal" then
|
2022-07-21 17:23:47 +01:00
|
|
|
if GetResourceState("ps-buffs") == "started" then exports["ps-buffs"]:AddHealthBuff((stats.effect.time or 10000), (stats.amount or 6))
|
|
|
|
|
else CreateThread(function() HealEffect({(stats.effect.time or 10000), (stats.amount or 6)}) end) end
|
|
|
|
|
end
|
2022-07-20 15:51:38 +01:00
|
|
|
if stats.effect == "stamina" then
|
2022-07-21 17:23:47 +01:00
|
|
|
if GetResourceState("ps-buffs") == "started" then exports["ps-buffs"]:StaminaBuffEffect((stats.effect.time or 10000), (stats.amount or 6))
|
|
|
|
|
else CreateThread(function() StaminaEffect({(stats.effect.time or 10000), (stats.amount or 6)}) end) end
|
2022-04-13 20:01:09 +01:00
|
|
|
end
|
2022-07-21 17:23:47 +01:00
|
|
|
if GetResourceState("ps-buffs") == "started" then --PS-BUFFS ONLY
|
|
|
|
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^4PS^7-^4Buffs ^2found^7, ^2hooking in to get buffs") end
|
|
|
|
|
if stats.effect == "armor" then exports["ps-buffs"]:AddArmorBuff((stats.effect.time or 10000), (stats.amount or 6)) end
|
|
|
|
|
if stats.effect == "stress" then exports["ps-buffs"]:AddStressBuff((stats.time or 10000), (stats.amount or 6)) end
|
|
|
|
|
if stats.effect == "swimming" then exports["ps-buffs"]:SwimmingBuffEffect((stats.effect.time or 10000), (stats.amount or 6)) end
|
|
|
|
|
if stats.effect == "hacking" then exports["ps-buffs"]:AddBuff("hacking", (stats.effect.time or 10000)) end
|
|
|
|
|
if stats.effect == "intelligence" then exports["ps-buffs"]:AddBuff("intelligence", (stats.effect.time or 10000)) end
|
|
|
|
|
if stats.effect == "luck" then exports["ps-buffs"]:AddBuff("luck", (stats.time or 10000)) end
|
|
|
|
|
if stats.effect == "strength" then exports["ps-buffs"]:AddBuff("strength", (stats.time or 10000)) end
|
|
|
|
|
end
|
|
|
|
|
if stats.widepupils then TriggerEvent("evidence:client:SetStatus", "widepupils", 200) end
|
2022-04-18 19:55:54 +01:00
|
|
|
end
|
2022-04-13 20:01:09 +01:00
|
|
|
end
|
|
|
|
|
cancelled = false
|
|
|
|
|
consuming = false
|
2022-07-20 13:43:17 +01:00
|
|
|
|
2022-07-20 15:51:38 +01:00
|
|
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Finished, unlocking inventory^7..") end
|
2022-07-14 15:25:20 +01:00
|
|
|
LocalPlayer.state:set("inv_busy", false, true)
|
2022-04-13 20:01:09 +01:00
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
CreateThread(function()
|
|
|
|
|
while true do
|
|
|
|
|
Wait(10)
|
|
|
|
|
if alcoholCount > 0 then
|
|
|
|
|
Wait(1000 * 60 * 15)
|
|
|
|
|
alcoholCount = alcoholCount - 1
|
|
|
|
|
else
|
|
|
|
|
Wait(2000)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end)
|
2022-04-18 19:55:54 +01:00
|
|
|
CreateThread(function()
|
2022-04-13 20:01:09 +01:00
|
|
|
while true do
|
|
|
|
|
Wait(10)
|
|
|
|
|
if drugCount > 0 then
|
|
|
|
|
Wait(1000 * 60 * 15)
|
|
|
|
|
drugCount = drugCount - 1
|
|
|
|
|
else
|
|
|
|
|
Wait(2000)
|
|
|
|
|
end
|
|
|
|
|
end
|
2022-07-06 20:48:08 +01:00
|
|
|
end)
|
2022-07-20 15:51:38 +01:00
|
|
|
|
|
|
|
|
AddEventHandler('onResourceStop', function(r) if r ~= GetCurrentResourceName() then return end
|
|
|
|
|
StopEffects()
|
|
|
|
|
end)
|