mirror of
https://github.com/jimathy/jim-consumables.git
synced 2026-08-17 06:26:03 +01:00
Version Bump 1.1 - Optimizations, Tidy, Fixes
This commit is contained in:
@@ -15,6 +15,7 @@ To add an item, you only need to add a new item table in the Config.Consumables
|
|||||||
```lua
|
```lua
|
||||||
["heartstopper"] = {
|
["heartstopper"] = {
|
||||||
emote = "burger", -- Select an emote from below, it has to be in here
|
emote = "burger", -- Select an emote from below, it has to be in here
|
||||||
|
time = math.random(5000, 6000), -- Amount of time it takes to consume the item
|
||||||
stress = math.random(1,2), -- Amount of stress relief, can be 0
|
stress = math.random(1,2), -- Amount of stress relief, can be 0
|
||||||
heal = 0, -- Set amount to heal by after consuming
|
heal = 0, -- Set amount to heal by after consuming
|
||||||
armor = 5, -- Amount of armor to add
|
armor = 5, -- Amount of armor to add
|
||||||
|
|||||||
@@ -1,37 +1,50 @@
|
|||||||
local QBCore = exports['qb-core']:GetCoreObject()
|
local QBCore = exports['qb-core']:GetCoreObject()
|
||||||
|
|
||||||
PlayerJob = {}
|
PlayerJob = {}
|
||||||
local onDuty = false
|
|
||||||
local alcoholCount = 0
|
local alcoholCount = 0
|
||||||
local drugCount = 0
|
local drugCount = 0
|
||||||
|
|
||||||
local function loadAnimDict(dict) while (not HasAnimDictLoaded(dict)) do RequestAnimDict(dict) Wait(5) end end
|
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
|
||||||
|
|
||||||
--Alcohol Effects
|
--Alcohol Effects
|
||||||
|
local alienEffect = false
|
||||||
function AlienEffect()
|
function AlienEffect()
|
||||||
|
if alienEffect then return end
|
||||||
|
alienEffect = true
|
||||||
|
if Config.Debug then print("^5Debug^7: ^3AlienEffect^7() ^2activated") end
|
||||||
StartScreenEffect("DrugsMichaelAliensFightIn", 3.0, 0)
|
StartScreenEffect("DrugsMichaelAliensFightIn", 3.0, 0)
|
||||||
Wait(math.random(5000, 8000))
|
Wait(math.random(5000, 8000))
|
||||||
local ped = PlayerPedId()
|
local Ped = PlayerPedId()
|
||||||
RequestAnimSet("MOVE_M@DRUNK@VERYDRUNK")
|
local animDict = "MOVE_M@DRUNK@VERYDRUNK"
|
||||||
while not HasAnimSetLoaded("MOVE_M@DRUNK@VERYDRUNK") do
|
loadAnimDict(animDict)
|
||||||
Citizen.Wait(0)
|
SetPedCanRagdoll(Ped, true)
|
||||||
end
|
|
||||||
SetPedCanRagdoll( ped, true )
|
|
||||||
ShakeGameplayCam('DRUNK_SHAKE', 2.80)
|
ShakeGameplayCam('DRUNK_SHAKE', 2.80)
|
||||||
SetTimecycleModifier("Drunk")
|
SetTimecycleModifier("Drunk")
|
||||||
SetPedMovementClipset(ped, "MOVE_M@DRUNK@VERYDRUNK", true)
|
SetPedMovementClipset(Ped, animDict, 1)
|
||||||
SetPedMotionBlur(ped, true)
|
SetPedMotionBlur(Ped, true)
|
||||||
SetPedIsDrunk(ped, true)
|
SetPedIsDrunk(Ped, true)
|
||||||
Wait(1500)
|
Wait(1500)
|
||||||
SetPedToRagdoll(ped, 5000, 1000, 1, false, false, false )
|
SetPedToRagdoll(Ped, 5000, 1000, 1, 0, 0, 0)
|
||||||
Wait(13500)
|
Wait(13500)
|
||||||
SetPedToRagdoll(ped, 5000, 1000, 1, false, false, false )
|
SetPedToRagdoll(Ped, 5000, 1000, 1, 0, 0, 0)
|
||||||
Wait(120500)
|
Wait(120500)
|
||||||
ClearTimecycleModifier()
|
ClearTimecycleModifier()
|
||||||
ResetScenarioTypesEnabled()
|
ResetScenarioTypesEnabled()
|
||||||
ResetPedMovementClipset(ped, 0)
|
ResetPedMovementClipset(Ped, 0)
|
||||||
SetPedIsDrunk(ped, false)
|
SetPedIsDrunk(Ped, false)
|
||||||
SetPedMotionBlur(ped, false)
|
SetPedMotionBlur(Ped, false)
|
||||||
AnimpostfxStopAll()
|
AnimpostfxStopAll()
|
||||||
ShakeGameplayCam('DRUNK_SHAKE', 0.0)
|
ShakeGameplayCam('DRUNK_SHAKE', 0.0)
|
||||||
StartScreenEffect("DrugsMichaelAliensFight", 3.0, 0)
|
StartScreenEffect("DrugsMichaelAliensFight", 3.0, 0)
|
||||||
@@ -40,9 +53,15 @@ function AlienEffect()
|
|||||||
StopScreenEffect("DrugsMichaelAliensFightIn")
|
StopScreenEffect("DrugsMichaelAliensFightIn")
|
||||||
StopScreenEffect("DrugsMichaelAliensFight")
|
StopScreenEffect("DrugsMichaelAliensFight")
|
||||||
StopScreenEffect("DrugsMichaelAliensFightOut")
|
StopScreenEffect("DrugsMichaelAliensFightOut")
|
||||||
|
alienEffect = false
|
||||||
|
if Config.Debug then print("^5Debug^7: ^3AlienEffect^7() ^2stopped") end
|
||||||
end
|
end
|
||||||
--Weed Effects
|
--Weed Effects
|
||||||
|
local weedEffect = false
|
||||||
function WeedEffect()
|
function WeedEffect()
|
||||||
|
if weedEffect then return end
|
||||||
|
weedEffect = true
|
||||||
|
if Config.Debug then print("^5Debug^7: ^3WeedEffect^7() ^2activated") end
|
||||||
StartScreenEffect("DrugsMichaelAliensFightIn", 3.0, 0)
|
StartScreenEffect("DrugsMichaelAliensFightIn", 3.0, 0)
|
||||||
Wait(math.random(3000, 20000))
|
Wait(math.random(3000, 20000))
|
||||||
StartScreenEffect("DrugsMichaelAliensFight", 3.0, 0)
|
StartScreenEffect("DrugsMichaelAliensFight", 3.0, 0)
|
||||||
@@ -51,9 +70,15 @@ function WeedEffect()
|
|||||||
StopScreenEffect("DrugsMichaelAliensFightIn")
|
StopScreenEffect("DrugsMichaelAliensFightIn")
|
||||||
StopScreenEffect("DrugsMichaelAliensFight")
|
StopScreenEffect("DrugsMichaelAliensFight")
|
||||||
StopScreenEffect("DrugsMichaelAliensFightOut")
|
StopScreenEffect("DrugsMichaelAliensFightOut")
|
||||||
|
weedEffect = false
|
||||||
|
if Config.Debug then print("^5Debug^7: ^3WeedEffect^7() ^2stopped") end
|
||||||
end
|
end
|
||||||
--Other Effects
|
--Other Effects
|
||||||
|
local trevorEffect = false
|
||||||
function TrevorEffect()
|
function TrevorEffect()
|
||||||
|
if trevorEffect then return end
|
||||||
|
if Config.Debug then print("^5Debug^7: ^3TrevorEffect^7() ^2activated") end
|
||||||
|
trevorEffect = true
|
||||||
StartScreenEffect("DrugsTrevorClownsFightIn", 3.0, 0)
|
StartScreenEffect("DrugsTrevorClownsFightIn", 3.0, 0)
|
||||||
Wait(3000)
|
Wait(3000)
|
||||||
StartScreenEffect("DrugsTrevorClownsFight", 3.0, 0)
|
StartScreenEffect("DrugsTrevorClownsFight", 3.0, 0)
|
||||||
@@ -62,30 +87,45 @@ function TrevorEffect()
|
|||||||
StopScreenEffect("DrugsTrevorClownsFight")
|
StopScreenEffect("DrugsTrevorClownsFight")
|
||||||
StopScreenEffect("DrugsTrevorClownsFightIn")
|
StopScreenEffect("DrugsTrevorClownsFightIn")
|
||||||
StopScreenEffect("DrugsTrevorClownsFightOut")
|
StopScreenEffect("DrugsTrevorClownsFightOut")
|
||||||
|
trevorEffect = false
|
||||||
|
if Config.Debug then print("^5Debug^7: ^3TrevorEffect^7() ^2stopped") end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local healEffectDouble = false
|
||||||
function HealEffectDouble()
|
function HealEffectDouble()
|
||||||
if not healing then healing = true else return end
|
if healEffectDouble then return end
|
||||||
|
if Config.Debug then print("^5Debug^7: ^3HealEffectDouble^7() ^2activated") end
|
||||||
|
healEffectDouble = true
|
||||||
local count = 9
|
local count = 9
|
||||||
while count > 0 do
|
while count > 0 do
|
||||||
Wait(1000)
|
Wait(1000)
|
||||||
count = count - 1
|
count = count - 1
|
||||||
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) + 6)
|
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) + 6)
|
||||||
end
|
end
|
||||||
healing = false
|
healEffectDouble = false
|
||||||
|
if Config.Debug then print("^5Debug^7: ^3HealEffectDouble^7() ^2stopped") end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local healEffect = false
|
||||||
function HealEffect()
|
function HealEffect()
|
||||||
if not healing then healing = true else return end
|
if healEffect then return end
|
||||||
|
if Config.Debug then print("^5Debug^7: ^3HealEffect^7() ^2activated") end
|
||||||
|
healEffect = true
|
||||||
local count = 4
|
local count = 4
|
||||||
while count > 0 do
|
while count > 0 do
|
||||||
Wait(1000)
|
Wait(1000)
|
||||||
count = count - 1
|
count = count - 1
|
||||||
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) + 6)
|
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) + 6)
|
||||||
end
|
end
|
||||||
healing = false
|
healEffect = false
|
||||||
|
if Config.Debug then print("^5Debug^7: ^3HealEffect^7() ^2stopped") end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local staminaEffect = false
|
||||||
function StaminaEffect()
|
function StaminaEffect()
|
||||||
|
if staminaEffect then return end
|
||||||
|
if Config.Debug then print("^5Debug^7: ^3StaminaEffect^7() ^2activated") end
|
||||||
|
staminaEffect = true
|
||||||
local startStamina = 8
|
local startStamina = 8
|
||||||
SetRunSprintMultiplierForPlayer(PlayerId(), 1.49)
|
SetRunSprintMultiplierForPlayer(PlayerId(), 1.49)
|
||||||
while startStamina > 0 do
|
while startStamina > 0 do
|
||||||
@@ -96,6 +136,25 @@ function StaminaEffect()
|
|||||||
end
|
end
|
||||||
startStamina = 0
|
startStamina = 0
|
||||||
SetRunSprintMultiplierForPlayer(PlayerId(), 1.0)
|
SetRunSprintMultiplierForPlayer(PlayerId(), 1.0)
|
||||||
|
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)
|
||||||
|
StopScreenEffect("DrugsMichaelAliensFightIn")
|
||||||
|
StopScreenEffect("DrugsMichaelAliensFight")
|
||||||
|
StopScreenEffect("DrugsMichaelAliensFightOut")
|
||||||
|
StopScreenEffect("DrugsTrevorClownsFight")
|
||||||
|
StopScreenEffect("DrugsTrevorClownsFightIn")
|
||||||
|
StopScreenEffect("DrugsTrevorClownsFightOut")
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[function EcstasyEffect()
|
--[[function EcstasyEffect()
|
||||||
@@ -174,29 +233,31 @@ local consuming = false
|
|||||||
local cancelled = false
|
local cancelled = false
|
||||||
|
|
||||||
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
|
||||||
LocalPlayer.state:set("inv_busy", true, true)
|
LocalPlayer.state:set("inv_busy", true, true)
|
||||||
local time = math.random(5000, 6000) -- How long it takes to consume something
|
|
||||||
local Player = PlayerPedId()
|
local Player = PlayerPedId()
|
||||||
local emote = Config.Emotes[Config.Consumables[itemName].emote]
|
local emote = Config.Emotes[Config.Consumables[itemName].emote]
|
||||||
local animDict = tostring(emote[1])
|
local animDict = tostring(emote[1])
|
||||||
local anim = tostring(emote[2])
|
local anim = tostring(emote[2])
|
||||||
local model, bone, drugeffect, stress = nil
|
local model, bone, 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 = 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 = tostring(emote.AnimationOptions.Prop)
|
model = emote.AnimationOptions.Prop
|
||||||
bone = GetPedBoneIndex(PlayerPedId(), emote.AnimationOptions.PropBone)
|
bone = GetPedBoneIndex(PlayerPedId(), emote.AnimationOptions.PropBone)
|
||||||
P1, P2, P3, P4, P5, P6 = table.unpack(emote.AnimationOptions.PropPlacement)
|
P1, P2, P3, P4, P5, P6 = table.unpack(emote.AnimationOptions.PropPlacement)
|
||||||
end
|
end
|
||||||
local type = Config.Consumables[itemName].type
|
local time = Config.Consumables[itemName].time or math.random(5000, 6000)
|
||||||
local stress = Config.Consumables[itemName].stress
|
local type = Config.Consumables[itemName].type or "food"
|
||||||
local heal = Config.Consumables[itemName].heal
|
local stress = Config.Consumables[itemName].stress or 0
|
||||||
local armor = Config.Consumables[itemName].armor
|
local heal = Config.Consumables[itemName].heal or 0
|
||||||
|
local armor = Config.Consumables[itemName].armor or 0
|
||||||
if type == "drink" or type == "alcohol" then string = "Drinking " end
|
if type == "drink" or type == "alcohol" then string = "Drinking " end
|
||||||
if type == "food" then string = "Eating " end
|
if type == "food" then string = "Eating " end
|
||||||
if type == "drug" then string = "Using " end
|
if type == "drug" then string = "Using " end
|
||||||
|
|
||||||
if consuming then
|
if consuming then
|
||||||
cancelled = true
|
cancelled = true
|
||||||
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Event already started^7, ^1Cancelling^7.") end
|
||||||
LocalPlayer.state:set("inv_busy", false, true)
|
LocalPlayer.state:set("inv_busy", false, true)
|
||||||
TriggerEvent("QBCore:Notify", "Stopped "..string, "error")
|
TriggerEvent("QBCore:Notify", "Stopped "..string, "error")
|
||||||
consuming = not consuming
|
consuming = not consuming
|
||||||
@@ -204,6 +265,7 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--Emote Stuff
|
--Emote Stuff
|
||||||
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Grabbing Emote Animation Options^7...") end
|
||||||
if emote.AnimationOptions then
|
if emote.AnimationOptions then
|
||||||
if emote.AnimationOptions.EmoteLoop then MovementType = 1
|
if emote.AnimationOptions.EmoteLoop then MovementType = 1
|
||||||
if emote.AnimationOptions.EmoteMoving then MovementType = 51
|
if emote.AnimationOptions.EmoteMoving then MovementType = 51
|
||||||
@@ -214,31 +276,27 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
|||||||
end
|
end
|
||||||
|
|
||||||
else MovementType = 0 end
|
else MovementType = 0 end
|
||||||
InVehicle = IsPedInAnyVehicle(PlayerPedId(), true)
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Checking if player is in a vehicle^7...") end
|
||||||
|
local InVehicle = IsPedInAnyVehicle(PlayerPedId(), true)
|
||||||
if InVehicle == 1 then MovementType = 51 end
|
if InVehicle == 1 then MovementType = 51 end
|
||||||
|
|
||||||
--Load and Start animation
|
--Load and Start animation
|
||||||
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Playing Animation^7...") end
|
||||||
loadAnimDict(animDict)
|
loadAnimDict(animDict)
|
||||||
TaskPlayAnim(Player, animDict, anim, 1.0, 1.0, -1, MovementType, 0, 0, 0, 0)
|
TaskPlayAnim(PlayerPedId(), animDict, anim, 1.0, 1.0, -1, MovementType, 0, 0, 0, 0)
|
||||||
|
|
||||||
TriggerEvent("QBCore:Notify", string..QBCore.Shared.Items[itemName].label.."..", "success", (time + 1000))
|
TriggerEvent("QBCore:Notify", string..QBCore.Shared.Items[itemName].label.."..", "success", (time + 1000))
|
||||||
consuming = true
|
consuming = true
|
||||||
|
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
--Prop Spawning
|
--Prop Spawning
|
||||||
if model then
|
if model then
|
||||||
RequestModel(GetHashKey(model))
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Spawning consumable prop^7.") end
|
||||||
while not HasModelLoaded(GetHashKey(model)) do Citizen.Wait(1) end
|
loadModel(model)
|
||||||
local attachProp = CreateObject(GetHashKey(model), 1.0, 1.0, 1.0, 1, 1, 0)
|
local attachProp = CreateObject(model, 1.0, 1.0, 1.0, 1, 1, 0)
|
||||||
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)
|
||||||
while consuming do
|
while consuming do Wait(100) end
|
||||||
Wait(10)
|
destroyProp(attachProp)
|
||||||
end
|
|
||||||
DeleteObject(attachProp)
|
|
||||||
DetachEntity(attachProp, 0, 0)
|
|
||||||
SetEntityAsMissionEntity(attachProp, true, true)
|
|
||||||
Wait(100)
|
|
||||||
DeleteEntity(attachProp)
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -253,11 +311,12 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
|||||||
time = time - 10
|
time = time - 10
|
||||||
end
|
end
|
||||||
|
|
||||||
StopEntityAnim(Player, anim, animDict, 1.0)
|
StopEntityAnim(PlayerPedId(), anim, animDict, 1.0)
|
||||||
|
unloadAnimDict(animDict)
|
||||||
|
|
||||||
if not cancelled then
|
if not cancelled then
|
||||||
TriggerEvent("inventory:client:ItemBox", QBCore.Shared.Items[itemName], "remove", 1)
|
|
||||||
TriggerServerEvent("QBCore:Server:RemoveItem", itemName, 1)
|
TriggerServerEvent("QBCore:Server:RemoveItem", itemName, 1)
|
||||||
|
TriggerEvent("inventory:client:ItemBox", QBCore.Shared.Items[itemName], "remove", 1)
|
||||||
|
|
||||||
if QBCore.Shared.Items[itemName].thirst then
|
if QBCore.Shared.Items[itemName].thirst then
|
||||||
TriggerServerEvent("QBCore:Server:SetMetaData", "thirst", QBCore.Functions.GetPlayerData().metadata["thirst"] + QBCore.Shared.Items[itemName].thirst) end
|
TriggerServerEvent("QBCore:Server:SetMetaData", "thirst", QBCore.Functions.GetPlayerData().metadata["thirst"] + QBCore.Shared.Items[itemName].thirst) end
|
||||||
@@ -275,52 +334,78 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if stress then TriggerServerEvent('hud:server:RelieveStress', stress) end
|
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
|
||||||
|
|
||||||
if heal then SetEntityHealth(Player, GetEntityHealth(Player) + heal) end
|
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
|
||||||
|
|
||||||
if armor then TriggerServerEvent('hospital:server:SetArmor', (GetPedArmour(Player) + armor)) SetPedArmour(Player, (GetPedArmour(Player) + armor)) end
|
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
|
||||||
|
|
||||||
if type == "alcohol" then
|
if type == "alcohol" then
|
||||||
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Current ^4alcoholCount^7: ^6"..(alcoholCount + 1)) end
|
||||||
alcoholCount = alcoholCount + 1
|
alcoholCount = alcoholCount + 1
|
||||||
if alcoholCount > 1 and alcoholCount < 4 then
|
if alcoholCount > 1 and alcoholCount < 4 then
|
||||||
TriggerEvent("evidence:client:SetStatus", "alcohol", 200)
|
TriggerEvent("evidence:client:SetStatus", "alcohol", 200)
|
||||||
elseif alcoholCount >= 4 then
|
elseif alcoholCount >= 4 then
|
||||||
TriggerEvent("evidence:client:SetStatus", "heavyalcohol", 200)
|
TriggerEvent("evidence:client:SetStatus", "heavyalcohol", 200)
|
||||||
AlienEffect()
|
CreateThread(function()
|
||||||
end
|
AlienEffect()
|
||||||
|
end)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
effect = Config.Consumables[itemName].effect
|
stats = Config.Consumables[itemName].stats or nil
|
||||||
|
|
||||||
if effect ~= nil then
|
if Config.Consumables[itemName].stats then
|
||||||
if effect.canOD then
|
if stats.canOD then
|
||||||
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Current ^4drugCount^7: ^6"..(drugCount + 1)) end
|
||||||
drugCount = drugCount + 1
|
drugCount = 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
|
||||||
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) - math.random(10,15))
|
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) - math.random(10,15))
|
||||||
if drugCount >= 6 then
|
if drugCount >= 6 then
|
||||||
AlienEffect()
|
CreateThread(function()
|
||||||
|
AlienEffect()
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if effect.effect == "weed" then
|
if stats.effect == "weed" then
|
||||||
if drugCount >= 2 then
|
if drugCount >= 2 then
|
||||||
TrevorEffect()
|
CreateThread(function()
|
||||||
|
TrevorEffect()
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if effect.effect == "heal" then
|
if stats.effect == "heal" then
|
||||||
HealEffect()
|
CreateThread(function()
|
||||||
|
HealEffect()
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
if effect.effect == "healdouble" then
|
if stats.effect == "healdouble" then
|
||||||
HealEffect()
|
CreateThread(function()
|
||||||
|
HealEffect()
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
if effect.effect == "stamina" then
|
if stats.effect == "stamina" then
|
||||||
StaminaEffect()
|
CreateThread(function()
|
||||||
if drugCount >= 4 then
|
StaminaEffect()
|
||||||
|
end)
|
||||||
|
if drugCount >= 4 then
|
||||||
|
CreateThread(function()
|
||||||
TrevorEffect()
|
TrevorEffect()
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if effect.widepupils then
|
if stats.widepupils then
|
||||||
TriggerEvent("evidence:client:SetStatus", "widepupils", 200)
|
TriggerEvent("evidence:client:SetStatus", "widepupils", 200)
|
||||||
--EcstasyEffect()
|
--EcstasyEffect()
|
||||||
end
|
end
|
||||||
@@ -330,16 +415,7 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
|||||||
cancelled = false
|
cancelled = false
|
||||||
consuming = false
|
consuming = false
|
||||||
|
|
||||||
--[[for k, v in pairs(GetGamePool('CObject')) do
|
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Finished, unlocking inventory^7..") end
|
||||||
if IsEntityAttachedToEntity(PlayerPedId(), v) then
|
|
||||||
DeleteObject(v)
|
|
||||||
DetachEntity(v, 0, 0)
|
|
||||||
SetEntityAsMissionEntity(v, true, true)
|
|
||||||
Wait(100)
|
|
||||||
DeleteEntity(v)
|
|
||||||
end
|
|
||||||
end]]
|
|
||||||
|
|
||||||
LocalPlayer.state:set("inv_busy", false, true)
|
LocalPlayer.state:set("inv_busy", false, true)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -365,3 +441,7 @@ CreateThread(function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
AddEventHandler('onResourceStop', function(r) if r ~= GetCurrentResourceName() then return end
|
||||||
|
StopEffects()
|
||||||
|
end)
|
||||||
48
config.lua
48
config.lua
@@ -1,4 +1,4 @@
|
|||||||
print("Jim-Consumables v1.0 - Consumables Script by Jimathy")
|
print("^2Jim^7-^2Consumables v^41^7.^41 ^7- ^2Consumables Script by ^1Jimathy^7")
|
||||||
|
|
||||||
-- If you need support I now have a discord available, it helps me keep track of issues and give better support.
|
-- If you need support I now have a discord available, it helps me keep track of issues and give better support.
|
||||||
|
|
||||||
@@ -8,40 +8,40 @@ Config = {
|
|||||||
Debug = false,
|
Debug = false,
|
||||||
Consumables = {
|
Consumables = {
|
||||||
-- Default QB food and drink item override
|
-- Default QB food and drink item override
|
||||||
["vodka"] = { emote = "vodkab", stress = math.random(2, 4), heal = 0, armor = 0, type = "alcohol", stats = { thirst = math.random(10,20), }},
|
["vodka"] = { emote = "vodkab", time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "alcohol", stats = { thirst = math.random(10,20), canOD = true }},
|
||||||
["beer"] = { emote = "beer", stress = math.random(2, 4), heal = 0, armor = 0, type = "alcohol", stats = { thirst = math.random(10,20), }},
|
["beer"] = { emote = "beer", time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "alcohol", stats = { thirst = math.random(10,20), canOD = true }},
|
||||||
["whiskey"] = { emote = "whiskey", stress = math.random(2, 4), heal = 0, armor = 0, type = "alcohol", stats = { thirst = math.random(10,20), }},
|
["whiskey"] = { emote = "whiskey", time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "alcohol", stats = { thirst = math.random(10,20), canOD = true }},
|
||||||
|
|
||||||
["sandwich"] = { emote = "sandwich", stress = math.random(2, 4), heal = 0, armor = 0, type = "food", stats = { hunger = math.random(10,20), }},
|
["sandwich"] = { emote = "sandwich", time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "food", stats = { hunger = math.random(10,20), }},
|
||||||
["twerks_candy"] = { emote = "egobar", stress = math.random(2, 4), heal = 0, armor = 0, type = "food", stats = { hunger = math.random(10,20), }},
|
["twerks_candy"] = { emote = "egobar", time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "food", stats = { hunger = math.random(10,20), }},
|
||||||
["snikkel_candy"] = { emote = "egobar", stress = math.random(2, 4), heal = 0, armor = 0, type = "food", stats = { hunger = math.random(10,20), }},
|
["snikkel_candy"] = { emote = "egobar", time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "food", stats = { hunger = math.random(10,20), }},
|
||||||
["tosti"] = { emote = "sandwich", stress = math.random(2, 4), heal = 0, armor = 0, type = "food", stats = { hunger = math.random(10,20), }},
|
["tosti"] = { emote = "sandwich", time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "food", stats = { hunger = math.random(10,20), }},
|
||||||
|
|
||||||
["coffee"] = { emote = "coffee", stress = math.random(2, 4), heal = 0, armor = 0, type = "drink", stats = { thirst = math.random(10,20), }},
|
["coffee"] = { emote = "coffee", time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "drink", stats = { thirst = math.random(10,20), }},
|
||||||
["water_bottle"] = { emote = "drink", stress = math.random(2, 4), heal = 0, armor = 0, type = "drink", stats = { thirst = math.random(10,20), }},
|
["water_bottle"] = { emote = "drink", time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "drink", stats = { thirst = math.random(10,20), }},
|
||||||
["kurkakola"] = { emote = "ecola", stress = math.random(2, 4), heal = 0, armor = 0, type = "drink", stats = { thirst = math.random(10,20), }},
|
["kurkakola"] = { emote = "ecola", time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "drink", stats = { thirst = math.random(10,20), }},
|
||||||
|
|
||||||
|
--[[----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
-- Items that effect status changes, like bleeding can cause problems as they are all handled in their own scripts
|
-- Items that effect status changes, like bleeding can cause problems as they are all handled in their own scripts
|
||||||
--[[--Testing these but they may be best left handled by default scripts
|
-- Testing these but they may be best left handled by default scripts
|
||||||
["ifaks"] = { emote = "oxy", stress = math.random(12, 24), heal = 10, armor = 0, type = "drug", },
|
["ifaks"] = { emote = "oxy", time = math.random(5000, 6000), stress = math.random(12, 24), heal = 10, armor = 0, type = "drug", },
|
||||||
["bandage"] = { emote = "oxy", stress = 0, heal = 10, armor = 0, type = "drug", },
|
["bandage"] = { emote = "oxy", time = math.random(5000, 6000), stress = 0, heal = 10, armor = 0, type = "drug", },
|
||||||
|
|
||||||
--Testing effects & armor with small functionality to drugs - This may be another one left to default scripts
|
--Testing effects & armor with small functionality to drugs - This may be another one left to default scripts
|
||||||
["joint"] = { emote = "smoke3", stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", effect = { effect = "weed", widepupils = false, canOD = false } },
|
["joint"] = { emote = "smoke3", time = math.random(5000, 6000), stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", stats = { effect = "weed", widepupils = false, canOD = false } },
|
||||||
|
|
||||||
["cokebaggy"] = { emote = "coke", stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", effect = { effect = "stamina", widepupils = false, canOD = true } },
|
["cokebaggy"] = { emote = "coke", time = math.random(5000, 6000), stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", stats = { effect = "stamina", widepupils = false, canOD = true } },
|
||||||
--["crackbaggy"] = { emote = "coke", stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", effect = { effect = "heal", widepupils = false, canOD = true } },
|
["crackbaggy"] = { emote = "coke", time = math.random(5000, 6000), stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", stats = { effect = "heal", widepupils = false, canOD = true } },
|
||||||
["xtcbaggy"] = { emote = "oxy", stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", effect = { effect = "stamina", widepupils = true, canOD = true } },
|
["xtcbaggy"] = { emote = "oxy", time = math.random(5000, 6000), stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", stats = { effect = "stamina", widepupils = true, canOD = true } },
|
||||||
["oxy"] = { emote = "oxy", stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", effect = { effect = "heal", widepupils = false, canOD = false } },
|
["oxy"] = { emote = "oxy", time = math.random(5000, 6000), stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", stats = { effect = "heal", widepupils = false, canOD = false } },
|
||||||
["meth"] = { emote = "coke", stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", effect = { effect = "stamina", widepupils = false, canOD = true } },]]
|
["meth"] = { emote = "coke", time = math.random(5000, 6000), stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", stats = { effect = "stamina", widepupils = false, canOD = true } },
|
||||||
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------]]
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Example item
|
Example item
|
||||||
--["heartstopper"] = {
|
["heartstopper"] = {
|
||||||
emote = "burger", -- Select an emote from below, it has to be in here
|
emote = "burger", -- Select an emote from below, it has to be in here
|
||||||
|
time = math.random(5000, 6000), -- Amount of time it takes to consume the item (if nil, this is the default)
|
||||||
stress = math.random(1,2), -- Amount of stress relief, can be 0
|
stress = math.random(1,2), -- Amount of stress relief, can be 0
|
||||||
heal = 0, -- Set amount to heal by after consuming
|
heal = 0, -- Set amount to heal by after consuming
|
||||||
armor = 5, -- Amount of armor to add
|
armor = 5, -- Amount of armor to add
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name "Jim-Consumables"
|
name "Jim-Consumables"
|
||||||
author "Jimathy"
|
author "Jimathy"
|
||||||
version "v1.0"
|
version "v1.1"
|
||||||
description "Consumable Script By Jimathy"
|
description "Consumable Script By Jimathy"
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
game "gta5"
|
game "gta5"
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ local QBCore = exports['qb-core']:GetCoreObject()
|
|||||||
|
|
||||||
--Consumables
|
--Consumables
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
for k,v in pairs(Config.Consumables) do
|
for k in pairs(Config.Consumables) do
|
||||||
QBCore.Functions.CreateUseableItem(k, function(source, item)
|
QBCore.Functions.CreateUseableItem(k, function(source, item)
|
||||||
TriggerClientEvent('jim-consumables:Consume', source, item.name)
|
TriggerClientEvent('jim-consumables:Consume', source, item.name)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
for k,v in pairs(Config.Consumables) do
|
for k, v in pairs(Config.Consumables) do
|
||||||
QBCore.Functions.CreateUseableItem(k, function(source, item) TriggerClientEvent('jim-consumables:Consume', source, item.name) end)
|
QBCore.Functions.CreateUseableItem(k, function(source, item) TriggerClientEvent('jim-consumables:Consume', source, item.name) end)
|
||||||
if not QBCore.Shared.Items[k] then print("Item check - '"..k.."' not found in the shared lua") end
|
if not QBCore.Shared.Items[k] then print("Item check - '"..k.."' not found in the shared lua") end
|
||||||
if not Config.Emotes[v.emote] then print("Emote check - '"..k.."' requested emote '"..v.emote.."' - not found in config.lua") end
|
if not Config.Emotes[v.emote] then print("Emote check - '"..k.."' requested emote '"..v.emote.."' - not found in config.lua") end
|
||||||
|
|||||||
Reference in New Issue
Block a user