mirror of
https://github.com/jimathy/jim-consumables.git
synced 2026-08-17 06:26:03 +01:00
Fixes + remove default drugs and healing
This commit is contained in:
@@ -64,7 +64,7 @@ function TrevorEffect()
|
||||
StopScreenEffect("DrugsTrevorClownsFightOut")
|
||||
end
|
||||
|
||||
function HealEffect()
|
||||
function HealEffectDouble()
|
||||
if not healing then healing = true else return end
|
||||
local count = 9
|
||||
while count > 0 do
|
||||
@@ -74,6 +74,16 @@ function HealEffect()
|
||||
end
|
||||
healing = false
|
||||
end
|
||||
function HealEffect()
|
||||
if not healing then healing = true else return end
|
||||
local count = 4
|
||||
while count > 0 do
|
||||
Wait(1000)
|
||||
count = count - 1
|
||||
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) + 6)
|
||||
end
|
||||
healing = false
|
||||
end
|
||||
|
||||
function StaminaEffect()
|
||||
local startStamina = 8
|
||||
@@ -88,8 +98,6 @@ function StaminaEffect()
|
||||
SetRunSprintMultiplierForPlayer(PlayerId(), 1.0)
|
||||
end
|
||||
|
||||
|
||||
|
||||
--[[function EcstasyEffect()
|
||||
local startStamina = 30
|
||||
SetFlash(0, 0, 500, 7000, 500)
|
||||
@@ -162,10 +170,11 @@ function CokeBaggyEffect()
|
||||
SetRunSprintMultiplierForPlayer(PlayerId(), 1.0)
|
||||
end]]
|
||||
|
||||
|
||||
local consuming = false
|
||||
local cancelled = false
|
||||
|
||||
local time = math.random(5000, 6000) -- Hpw long it takes to consume something
|
||||
|
||||
RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
||||
local Player = PlayerPedId()
|
||||
local emote = Config.Emotes[Config.Consumables[itemName].emote]
|
||||
@@ -193,6 +202,7 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
||||
return
|
||||
end
|
||||
|
||||
--Emote Stuff
|
||||
if emote.AnimationOptions then
|
||||
if emote.AnimationOptions.EmoteLoop then MovementType = 1
|
||||
if emote.AnimationOptions.EmoteMoving then MovementType = 51
|
||||
@@ -206,18 +216,20 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
||||
InVehicle = IsPedInAnyVehicle(PlayerPedId(), true)
|
||||
if InVehicle == 1 then MovementType = 51 end
|
||||
|
||||
--Load and Start animation
|
||||
loadAnimDict(animDict)
|
||||
|
||||
TaskPlayAnim(Player, animDict, anim, 1.0, 1.0, -1, MovementType, 0, 0, 0, 0)
|
||||
|
||||
--Prop Spawning
|
||||
local attachProp = CreateObject(GetHashKey(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)
|
||||
|
||||
local time = math.random(1000, 2000)
|
||||
--Prop Spawning
|
||||
if model then
|
||||
RequestModel(GetHashKey(model))
|
||||
while not HasModelLoaded(GetHashKey(model)) do Citizen.Wait(1) end
|
||||
local attachProp = CreateObject(GetHashKey(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)
|
||||
end
|
||||
|
||||
|
||||
TriggerEvent("QBCore:Notify", string..QBCore.Shared.Items[itemName].label.."..", "success", (time + 1000))
|
||||
|
||||
consuming = true
|
||||
while consuming do
|
||||
if time <= 0 then consuming = false end
|
||||
@@ -242,8 +254,12 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
||||
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
|
||||
if type == "food" then TriggerServerEvent("QBCore:Server:SetMetaData", "hunger", QBCore.Functions.GetPlayerData().metadata["hunger"] + math.random(10,20)) end
|
||||
if type == "drink" then TriggerServerEvent("QBCore:Server:SetMetaData", "thirst", QBCore.Functions.GetPlayerData().metadata["thirst"] + math.random(10,20)) end
|
||||
local hunger = 0
|
||||
local thirst = 0
|
||||
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
|
||||
|
||||
if stress then TriggerServerEvent('hud:server:RelieveStress', stress) end
|
||||
@@ -281,6 +297,9 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
||||
end
|
||||
if effect.effect == "heal" then
|
||||
HealEffect()
|
||||
end
|
||||
if effect.effect == "healdouble" then
|
||||
HealEffect()
|
||||
end
|
||||
if effect.effect == "stamina" then
|
||||
StaminaEffect()
|
||||
@@ -297,6 +316,15 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
|
||||
end
|
||||
cancelled = false
|
||||
consuming = false
|
||||
for k, v in pairs(GetGamePool('CObject')) do
|
||||
if IsEntityAttachedToEntity(PlayerPedId(), v) then
|
||||
DeleteObject(v)
|
||||
DetachEntity(v, 0, 0)
|
||||
SetEntityAsMissionEntity(v, true, true)
|
||||
Wait(100)
|
||||
DeleteEntity(v)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
CreateThread(function()
|
||||
|
||||
84
config.lua
84
config.lua
@@ -9,57 +9,69 @@ Config = {}
|
||||
Config.Debug = false -- false to remove green boxes
|
||||
|
||||
Config.Consumables = {
|
||||
-- Default QB food item override
|
||||
["vodka"] = { emote = "vodkab", stress = math.random(2, 4), heal = 0, armor = 0, type = "alcohol", },
|
||||
["beer"] = { emote = "beer", stress = math.random(2, 4), heal = 0, armor = 0, type = "alcohol", },
|
||||
["whiskey"] = { emote = "whiskey", stress = math.random(2, 4), heal = 0, armor = 0, type = "alcohol", },
|
||||
-- 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), }},
|
||||
["beer"] = { emote = "beer", stress = math.random(2, 4), heal = 0, armor = 0, type = "alcohol", stats = { thirst = math.random(10,20), }},
|
||||
["whiskey"] = { emote = "whiskey", stress = math.random(2, 4), heal = 0, armor = 0, type = "alcohol", stats = { thirst = math.random(10,20), }},
|
||||
|
||||
["sandwich"] = { emote = "sandwich", stress = math.random(2, 4), heal = 0, armor = 0, type = "food", },
|
||||
["twerks_candy"] = { emote = "egobar", stress = math.random(2, 4), heal = 0, armor = 0, type = "food", },
|
||||
["snikkel_candy"] = { emote = "egobar", stress = math.random(2, 4), heal = 0, armor = 0, type = "food", },
|
||||
["tosti"] = { emote = "sandwich", stress = math.random(2, 4), heal = 0, armor = 0, type = "food", },
|
||||
["sandwich"] = { emote = "sandwich", 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), }},
|
||||
["snikkel_candy"] = { emote = "egobar", 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), }},
|
||||
|
||||
["coffee"] = { emote = "coffee", stress = math.random(2, 4), heal = 0, armor = 0, type = "drink", },
|
||||
["water_bottle"] = { emote = "drink", stress = math.random(2, 4), heal = 0, armor = 0, type = "drink", },
|
||||
["kurkakola"] = { emote = "ecola", stress = math.random(2, 4), heal = 0, armor = 0, type = "drink", },
|
||||
["coffee"] = { emote = "coffee", 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), }},
|
||||
["kurkakola"] = { emote = "ecola", stress = math.random(2, 4), heal = 0, armor = 0, type = "drink", stats = { thirst = math.random(10,20), }},
|
||||
|
||||
--Testing these but they may be best left handled by default 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
|
||||
["ifaks"] = { emote = "oxy", stress = math.random(12, 24), heal = 10, armor = 0, type = "drug", },
|
||||
["bandage"] = { emote = "oxy", stress = 0, heal = 10, armor = 0, type = "drug", },
|
||||
|
||||
--Testing effects & armor with small functionality to drugs
|
||||
["joint"] = { emote = "smoke3", stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", effect = { effect = "weed", stamina = false, widepupils = false, canOD = true } },
|
||||
--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 } },
|
||||
|
||||
["cokebaggy"] = { emote = "coke", stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", effect = { 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 } },
|
||||
["xtcbaggy"] = { emote = "oxy", stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", effect = { 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 } },
|
||||
["meth"] = { emote = "coke", stress = math.random(12, 24), heal = 0, armor = 10, type = "drug", effect = { effect = "stamina", widepupils = false, canOD = true } },]]
|
||||
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--[[ Not working yet
|
||||
--Drugs
|
||||
["cokebaggy"] = { emote = "coke", stress = math.random(2, 4), heal = 0, armor = 0, type = "drug", effect = { armor = false, health = false, stamina = false, widepupils = false, canOD = true, screen = 1 } },
|
||||
["crackbaggy"] = { emote = "coke", stress = math.random(2, 4), heal = 0, armor = 0, type = "drug", effect = { armor = false, health = false, stamina = false, widepupils = false, canOD = true, screen = 1 } },
|
||||
["xtcbaggy"] = { emote = "oxy", stress = math.random(2, 4), heal = 0, armor = 0, type = "drug", effect = { armor = false, health = false, stamina = true, widepupils = false, canOD = true, screen = 1 } },
|
||||
["oxy"] = { emote = "oxy", stress = math.random(2, 4), heal = 0, armor = 0, type = "drug", effect = { armor = false, health = true, stamina = false, widepupils = false, canOD = false, screen = 1 } },
|
||||
["meth"] = { emote = "coke", stress = math.random(2, 4), heal = 0, armor = 0, type = "drug", effect = { armor = false, health = false, stamina = true, widepupils = false, canOD = true, screen = 1 } },
|
||||
--["joint"] = { emote = "joint", stress = math.random(2, 4), heal = 0, armor = 0, type = "drug", effect = { armor = true, health = false, stamina = false, widepupils = false, canOD = true, screen = 1 } },
|
||||
]]
|
||||
--[[
|
||||
Example item
|
||||
--["heartstopper"] = {
|
||||
emote = "burger", -- Select an emote from below, it has to be in here
|
||||
stress = math.random(1,2), -- Amount of stress relief, can be 0
|
||||
heal = 0, -- Set amount to heal by after consuming
|
||||
armor = 5, -- Amount of armor to add
|
||||
type = "food", -- Type: "alcohol" / "drink" / "food"
|
||||
effect = { effect = "healdouble", }, -- The status effect given by the item, "heal" / "healdouble" / "stamina"
|
||||
stats = { hunger = math.random(10,20), }, -- The stats of the item, if not found in the items.lua
|
||||
},
|
||||
]]
|
||||
}
|
||||
|
||||
Config.Emotes = {
|
||||
["drink"] = {"mp_player_inteat@pnq", "loop", "Drink", AnimationOptions =
|
||||
{ EmoteMoving = true, EmoteDuration = 2500, }},
|
||||
["whiskeyb"] = {"anim@amb@nightclub@mini@drinking@drinking_shots@ped_b@normal@", "glass_hold", "Whiskey Bottle", AnimationOptions =
|
||||
{ Prop = "prop_cs_whiskey_bottle", PropBone = 60309, PropPlacement = {0.08, 0.0, 0.05, 240.0, -60.0},
|
||||
["whiskeyb"] = {"mp_player_intdrink", "loop_bottle", "(Don't Use) Whiskey Bottle", AnimationOptions =
|
||||
{ Prop = "prop_cs_whiskey_bottle", PropBone = 60309, PropPlacement = {0.0, 0.0, 0.0, 0.0, 0.0},
|
||||
EmoteMoving = true, EmoteLoop = true }},
|
||||
["rumb"] = {"mp_player_intdrink", "loop_bottle", "(Don't Use) Rum Bottle", AnimationOptions =
|
||||
{ Prop = "prop_rum_bottle", PropBone = 18905, PropPlacement = {0.03, -0.18, 0.10, 240.0, -60.0},
|
||||
EmoteMoving = true, EmoteLoop = true }},
|
||||
["icream"] = {"mp_player_intdrink", "loop_bottle", "Irish Cream Bottle", AnimationOptions =
|
||||
{ Prop = "prop_bottle_brandy", PropBone = 18905, PropPlacement = {0.00, -0.26, 0.10, 240.0, -60.0},
|
||||
EmoteMoving = true, EmoteLoop = true }},
|
||||
["rumb"] = {"anim@amb@nightclub@mini@drinking@drinking_shots@ped_b@normal@", "glass_hold", "Rum Bottle", AnimationOptions =
|
||||
{ Prop = "prop_rum_bottle", PropBone = 60309, PropPlacement = {-0.04, -0.18, 0.12, 240.0, -60.0},
|
||||
["ginb"] = {"mp_player_intdrink", "loop_bottle", "(Don't Use) Gin Bottle", AnimationOptions =
|
||||
{ Prop = "prop_tequila_bottle", PropBone = 18905, PropPlacement = {0.00, -0.26, 0.10, 240.0, -60.0},
|
||||
EmoteMoving = true, EmoteLoop = true }},
|
||||
["icream"] = {"anim@amb@nightclub@mini@drinking@drinking_shots@ped_b@normal@", "glass_hold", "Irish Cream Bottle", AnimationOptions =
|
||||
{ Prop = "prop_bottle_brandy", PropBone = 60309, PropPlacement = {-0.04, -0.18, 0.12, 240.0, -60.0},
|
||||
EmoteMoving = true, EmoteLoop = true }},
|
||||
["ginb"] = {"anim@amb@nightclub@mini@drinking@drinking_shots@ped_b@normal@", "glass_hold", "Gin Bottle", AnimationOptions =
|
||||
{ Prop = "prop_tequila_bottle", PropBone = 60309, PropPlacement = {-0.04, -0.18, 0.12, 240.0, -60.0},
|
||||
EmoteMoving = true, EmoteLoop = true }},
|
||||
["vodkab"] = {"anim@amb@nightclub@mini@drinking@drinking_shots@ped_b@normal@", "glass_hold", "Vodka Bottle", AnimationOptions =
|
||||
{ Prop = 'prop_vodka_bottle', PropBone = 60309, PropPlacement = {-0.04, -0.18, 0.12, 240.0, -60.0},
|
||||
EmoteMoving = true, EmoteLoop = true }},
|
||||
["vodkab"] = {"mp_player_intdrink", "loop_bottle", "(Don't Use) Vodka Bottle", AnimationOptions =
|
||||
{ Prop = 'prop_vodka_bottle', PropBone = 18905, PropPlacement = {0.00, -0.26, 0.10, 240.0, -60.0},
|
||||
EmoteMoving = true, EmoteLoop = true }},
|
||||
["crisps"] = {"amb@world_human_drinking@coffee@male@idle_a", "idle_c", "Chrisps", AnimationOptions =
|
||||
{ Prop = 'v_ret_ml_chips2', PropBone = 28422, PropPlacement = {0.01, -0.05, -0.1, 0.0, 0.0, 90.0},
|
||||
EmoteLoop = true, EmoteMoving = true, }},
|
||||
|
||||
Reference in New Issue
Block a user