15 Commits

Author SHA1 Message Date
Jim Shield
68b17642a6 Version Bump 2022-09-17 16:49:15 +01:00
Jim Shield
5d084c3046 Tidy + upgrade 2022-09-17 16:48:42 +01:00
Atikur Rahaman Santo
bc585cd9a5 2nd prop and lua54 support 2022-09-17 05:04:13 +06:00
Jim Shield
1f9e16acf1 qs-inventory fix 2022-09-04 18:38:20 +01:00
Jim Shield
9fcc91e2bc ps progressbar support 2022-08-30 22:45:59 +01:00
Jim Shield
00332d0ca3 Progressbar Support
a little updates
2022-08-30 21:57:57 +01:00
Atikur Rahaman Santo
a2d2355757 Merge branch 'main' into conflict-resolve 2022-08-31 02:45:36 +06:00
Atikur Rahaman Santo
de68263240 marge with main 2022-08-31 02:43:43 +06:00
Jim Shield
931ba14933 more buff time fixes 2022-08-29 15:25:21 +01:00
Jim Shield
50f5dab7cb remove useless variable 2022-08-29 10:29:55 +01:00
Jim Shield
f1cf454687 buff time fix + notify fixes + New effects 2022-08-29 10:26:48 +01:00
Atikur Rahaman Santo
da27eb3f89 anothe mistake fix 2022-08-26 21:54:37 +06:00
Atikur Rahaman Santo
35bf894213 a little wait before cancel progbar 2022-08-26 06:19:38 +06:00
Atikur Rahaman Santo
a0c83c0e1f feat: Notify config progressbar config & canrun while consume in config 2022-08-26 06:10:20 +06:00
Jim Shield
a6f6492d5b debug mode. 2022-08-24 09:25:05 +01:00
6 changed files with 148 additions and 100 deletions

View File

@@ -29,7 +29,7 @@ To add an item, you only need to add a new item table in the Config.Consumables
armor = 5, -- Amount of armor to add armor = 5, -- Amount of armor to add
type = "food", -- Type: "alcohol" / "drink" / "food" type = "food", -- Type: "alcohol" / "drink" / "food"
stats = { stats = {
screen = "rampage" -- The screen effect to be played when after consuming the item screen = "rampage", -- The screen effect to be played when after consuming the item
effect = "heal", -- The status effect given by the item, "heal" / "stamina" effect = "heal", -- The status effect given by the item, "heal" / "stamina"
time = 10000, -- How long the effect should last (if not added it will default to 10000) time = 10000, -- How long the effect should last (if not added it will default to 10000)
amount = 2, -- How much the value is changed by per second amount = 2, -- How much the value is changed by per second
@@ -42,12 +42,14 @@ Consuming an item can also manually activate screen effects
The example above uses `rampage` as this is what the effect is named after, you can use it for any item you think best The example above uses `rampage` as this is what the effect is named after, you can use it for any item you think best
```lua ```lua
--The current list of effects are: --The current list of screen effects are:
"turbo" "turbo"
"focus" "focus"
"rampage" "rampage"
"weed" "weed"
"trevor" "trevor"
"nightvision"
"thermal"
``` ```
## PS-Buffs Support ## PS-Buffs Support

View File

@@ -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
@@ -8,6 +7,9 @@ local drugCount = 0
for k in pairs(Config.Emotes) do for k in pairs(Config.Emotes) do
if Config.Emotes[k].AnimationOptions.Prop then if Config.Emotes[k].AnimationOptions.Prop then
Config.Emotes[k].AnimationOptions.Prop = GetHashKey(Config.Emotes[k].AnimationOptions.Prop) Config.Emotes[k].AnimationOptions.Prop = GetHashKey(Config.Emotes[k].AnimationOptions.Prop)
if Config.Emotes[k].AnimationOptions.SecondProp then
Config.Emotes[k].AnimationOptions.SecondProp = GetHashKey(Config.Emotes[k].AnimationOptions.SecondProp)
end
end end
end end
@@ -16,17 +18,22 @@ 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 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) TriggerEvent('inventory:client:busy:status', true) TriggerEvent('canUseInventoryAndHotbar:toggle', true) LocalPlayer.state:set("inv_busy", true, true) TriggerEvent('inventory:client:busy:status', true) TriggerEvent('canUseInventoryAndHotbar:toggle', false)
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 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
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)
P1, P2, P3, P4, P5, P6 = table.unpack(emote.AnimationOptions.PropPlacement) P1, P2, P3, P4, P5, P6 = table.unpack(emote.AnimationOptions.PropPlacement)
if emote.AnimationOptions.SecondProp then
model2 = emote.AnimationOptions.SecondProp
bone2 = GetPedBoneIndex(PlayerPedId(), emote.AnimationOptions.SecondPropBone)
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 time = Config.Consumables[itemName].time or math.random(5000, 6000)
local type = Config.Consumables[itemName].type or "food" local type = Config.Consumables[itemName].type or "food"
@@ -36,16 +43,18 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
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 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)
if Config.UseProgbar then
TriggerEvent("progressbar:client:cancel")
else
triggerNotify(nil, "Stopped "..string, "error") triggerNotify(nil, "Stopped "..string, "error")
end
consuming = not consuming consuming = not consuming
return return
end end
--Emote Stuff --Emote Stuff
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Grabbing Emote Animation Options^7...") end if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Grabbing Emote Animation Options^7...") end
if emote.AnimationOptions then if emote.AnimationOptions then
@@ -56,80 +65,83 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
elseif emote.AnimationOptions.EmoteMoving == false then MovementType = 0 elseif emote.AnimationOptions.EmoteMoving == false then MovementType = 0
elseif emote.AnimationOptions.EmoteStuck then MovementType = 50 elseif emote.AnimationOptions.EmoteStuck then MovementType = 50
end end
else MovementType = 0 end else MovementType = 0 end
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Checking if player is in a vehicle^7...") end if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Checking if player is in a vehicle^7...") end
local InVehicle = IsPedInAnyVehicle(PlayerPedId(), true) 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 if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Playing Animation^7...") end
loadAnimDict(animDict) loadAnimDict(animDict)
TaskPlayAnim(PlayerPedId(), 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)
if Config.UseProgbar then
QBCore.Functions.Progressbar('jimmy_consume_', string..QBCore.Shared.Items[itemName].label.."..", time, false, false, {disableMovement = false,disableCarMovement = false,disableMouse = false,disableCombat = true,}, {}, {}, {}, function() end, function() end, itemName)
else
triggerNotify(nil, string..QBCore.Shared.Items[itemName].label.."..", "success") triggerNotify(nil, string..QBCore.Shared.Items[itemName].label.."..", "success")
consuming = true end
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
local 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)
while consuming do Wait(100) end if model2 and IsModelValid(model2) == 1 then
destroyProp(attachProp) attachProp2 = makeProp({ prop = model2, coords = vector4(0.0,0.0,0.0,0.0)}, 1, 1)
end 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) end)
while consuming do while consuming do
if time <= 0 then consuming = false end if time <= 0 then consuming = false end
if not Config.Consumables[itemName].canRun then
if IsControlJustPressed(0, 21) then if IsControlJustPressed(0, 21) then
consuming = false consuming = false
cancelled = true cancelled = true
LocalPlayer.state:set("inv_busy", false, true) LocalPlayer.state:set("inv_busy", false, true)
if Config.UseProgbar then
Wait(10)
TriggerEvent("progressbar:client:cancel")
else
triggerNotify(nil, "Cancelled "..string, "error")
end
end
end end
Wait(10) Wait(10)
time = time - 10 time -= 10
end end
StopEntityAnim(PlayerPedId(), anim, animDict, 1.0) StopEntityAnim(PlayerPedId(), anim, animDict, 1.0)
unloadAnimDict(animDict) unloadAnimDict(animDict)
if not cancelled then if not cancelled then
toggleItem(false, itemName, 1) toggleItem(false, itemName, 1)
if QBCore.Shared.Items[itemName].thirst then TriggerServerEvent("jim-consumables:server:addThirst", QBCore.Functions.GetPlayerData().metadata["thirst"] + QBCore.Shared.Items[itemName].thirst) end
if QBCore.Shared.Items[itemName].thirst then if QBCore.Shared.Items[itemName].hunger then TriggerServerEvent("jim-consumables:server:addHunger", QBCore.Functions.GetPlayerData().metadata["hunger"] + QBCore.Shared.Items[itemName].hunger) end
TriggerServerEvent("QBCore:Server:SetMetaData", "thirst", QBCore.Functions.GetPlayerData().metadata["thirst"] + QBCore.Shared.Items[itemName].thirst) end
if QBCore.Shared.Items[itemName].hunger then
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 not QBCore.Shared.Items[itemName].thirst and not QBCore.Shared.Items[itemName].hunger then
local hunger = 0 local hunger = 0
local thirst = 0 local thirst = 0
if Config.Consumables[itemName].stats then if Config.Consumables[itemName].stats then
if Config.Consumables[itemName].stats.hunger then hunger = Config.Consumables[itemName].stats.hunger end 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) TriggerServerEvent("jim-consumables:server:addHunger", QBCore.Functions.GetPlayerData().metadata["hunger"] + hunger)
if Config.Consumables[itemName].stats.thirst then thirst = Config.Consumables[itemName].stats.thirst end 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) TriggerServerEvent("jim-consumables:server:addThirst", QBCore.Functions.GetPlayerData().metadata["thirst"] + thirst)
end end
end end
if stress and stress ~= 0 then if stress and stress ~= 0 then
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Reliving ^6"..stress.." ^2stress^7.") end if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Reliving ^6"..stress.." ^2stress^7.") end
TriggerServerEvent('hud:server:RelieveStress', stress) TriggerServerEvent('hud:server:RelieveStress', stress)
end end
if heal and heal ~= 0 then if heal and heal ~= 0 then
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Healing player by^7: ^6"..heal) end if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Healing player by^7: ^6"..heal) end
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) + heal) SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) + heal)
end end
if armor and armor ~= 0 then if armor and armor ~= 0 then
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Adding ^6"..armor.." ^2armour^7.") end 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)) TriggerServerEvent('hospital:server:SetArmor', (GetPedArmour(PlayerPedId()) + armor)) SetPedArmour(PlayerPedId(), (GetPedArmour(PlayerPedId()) + armor))
end 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 if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Current ^4alcoholCount^7: ^6"..(alcoholCount + 1)) end
alcoholCount = alcoholCount + 1 alcoholCount = alcoholCount + 1
@@ -140,9 +152,7 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
CreateThread(function() AlienEffect() end) -- Used as overdosing/too drunk effect CreateThread(function() AlienEffect() end) -- Used as overdosing/too drunk effect
end end
end end
stats = Config.Consumables[itemName].stats or nil stats = Config.Consumables[itemName].stats or nil
if Config.Consumables[itemName].stats then if Config.Consumables[itemName].stats then
if stats.screen then -- Screen effect activation if stats.screen then -- Screen effect activation
if stats.screen == "turbo" then CreateThread(function() TurboEffect() end) end if stats.screen == "turbo" then CreateThread(function() TurboEffect() end) end
@@ -150,11 +160,12 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
if stats.screen == "rampage" then CreateThread(function() RampageEffect() 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 == "weed" then CreateThread(function() WeedEffect() end) end
if stats.screen == "trevor" then CreateThread(function() TrevorEffect() end) end if stats.screen == "trevor" then CreateThread(function() TrevorEffect() end) end
if stats.screen == "nightvision" then CreateThread(function() NightVisionEffect() end) end
if stats.screen == "thermal" then CreateThread(function() ThermalEffect() end) end
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))
@@ -164,20 +175,20 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
end end
end end
if stats.effect == "heal" then if stats.effect == "heal" then
if GetResourceState("ps-buffs") == "started" then exports["ps-buffs"]:AddHealthBuff((stats.effect.time or 10000), (stats.amount or 6)) if GetResourceState("ps-buffs") == "started" then exports["ps-buffs"]:AddHealthBuff((stats.time or 10000), (stats.amount or 6))
else CreateThread(function() HealEffect({(stats.effect.time or 10000), (stats.amount or 6)}) end) end else CreateThread(function() HealEffect({(stats.time or 10000), (stats.amount or 6)}) end) end
end end
if stats.effect == "stamina" then if stats.effect == "stamina" then
if GetResourceState("ps-buffs") == "started" then exports["ps-buffs"]:StaminaBuffEffect((stats.effect.time or 10000), (stats.amount or 6)) if GetResourceState("ps-buffs") == "started" then exports["ps-buffs"]:StaminaBuffEffect((stats.time or 10000), (stats.amount or 6))
else CreateThread(function() StaminaEffect({(stats.effect.time or 10000), (stats.amount or 6)}) end) end else CreateThread(function() StaminaEffect({(stats.time or 10000), (stats.amount or 6)}) end) end
end end
if GetResourceState("ps-buffs") == "started" then --PS-BUFFS ONLY 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 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 == "armor" then exports["ps-buffs"]:AddArmorBuff((stats.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 == "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 == "swimming" then exports["ps-buffs"]:SwimmingBuffEffect((stats.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 == "hacking" then exports["ps-buffs"]:AddBuff("hacking", (stats.time or 10000)) end
if stats.effect == "intelligence" then exports["ps-buffs"]:AddBuff("intelligence", (stats.effect.time or 10000)) end if stats.effect == "intelligence" then exports["ps-buffs"]:AddBuff("intelligence", (stats.time or 10000)) end
if stats.effect == "luck" then exports["ps-buffs"]:AddBuff("luck", (stats.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 if stats.effect == "strength" then exports["ps-buffs"]:AddBuff("strength", (stats.time or 10000)) end
end end
@@ -186,9 +197,8 @@ RegisterNetEvent('jim-consumables:Consume', function(itemName)
end end
cancelled = false cancelled = false
consuming = false consuming = false
if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Finished, unlocking inventory^7...") end if Config.Debug then print("^5Debug^7: ^3Consume^7: ^2Finished, unlocking inventory^7...") end
LocalPlayer.state:set("inv_busy", false, true) TriggerEvent('inventory:client:busy:status', false) TriggerEvent('canUseInventoryAndHotbar:toggle', false) LocalPlayer.state:set("inv_busy", false, true) TriggerEvent('inventory:client:busy:status', false) TriggerEvent('canUseInventoryAndHotbar:toggle', true)
end) end)
CreateThread(function() CreateThread(function()
@@ -196,13 +206,13 @@ CreateThread(function()
Wait(10) Wait(10)
if alcoholCount > 0 then if alcoholCount > 0 then
Wait(1000 * 60 * 15) Wait(1000 * 60 * 15)
alcoholCount = alcoholCount - 1 alcoholCount -= 1
else else
Wait(1000) Wait(1000)
end end
if drugCount > 0 then if drugCount > 0 then
Wait(1000 * 60 * 15) Wait(1000 * 60 * 15)
drugCount = drugCount - 1 drugCount -= 1
else else
Wait(1000) Wait(1000)
end end

View File

@@ -1,27 +1,30 @@
print("^2Jim^7-^2Consumables v^41^7.^43 ^7- ^2Consumables Script by ^1Jimathy^7") print("^2Jim^7-^2Consumables ^7v^41^7.^43^7.^42 ^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.
-- https://discord.gg/xKgQZ6wZvS -- https://discord.gg/xKgQZ6wZvS
Config = { Config = {
Debug = true, Debug = false,
Notify = "qb",
UseProgbar = false,
Consumables = { Consumables = {
-- Default QB food and drink item override -- Default QB food and drink item override
--Effects can be applied here, like stamina on coffee for example --Effects can be applied here, like stamina on coffee for example
["vodka"] = { emote = "vodkab", time = math.random(5000, 6000), stress = 0, heal = 0, armor = 0, type = "alcohol", stats = { effect = "stress", time = 5000, amount = 2, thirst = math.random(10,20), canOD = true }}, ["vodka"] = { emote = "vodkab", canRun = false, time = math.random(5000, 6000), stress = 0, heal = 0, armor = 0, type = "alcohol", stats = { effect = "stress", time = 5000, amount = 2, thirst = math.random(10,20), canOD = true }},
["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 }}, ["beer"] = { emote = "beer", canRun = false, 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", 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", canRun = false, 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", time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "food", stats = { hunger = math.random(10,20), }}, ["sandwich"] = { emote = "sandwich", canRun = false, 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", 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", canRun = true, 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", 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", canRun = true, 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", 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", canRun = false, 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", time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "drink", stats = { effect = "stamina", time = 10000, thirst = math.random(10,20), }}, ["coffee"] = { emote = "coffee", canRun = false, time = math.random(5000, 6000), stress = math.random(2, 4), heal = 0, armor = 0, type = "drink", stats = { effect = "stamina", time = 10000, 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), }}, ["water_bottle"] = { emote = "drink", canRun = false, 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", 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", canRun = false, 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
@@ -40,9 +43,9 @@ Config = {
["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 } }, ["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 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
@@ -50,15 +53,15 @@ Config = {
armor = 5, -- Amount of armor to add armor = 5, -- Amount of armor to add
type = "food", -- Type: "alcohol" / "drink" / "food" type = "food", -- Type: "alcohol" / "drink" / "food"
stats = { stats = {
screen = "rampage" -- The screen effect to be played when after consuming the item screen = "rampage", -- The screen effect to be played when after consuming the item
effect = "heal", -- The status effect given by the item, "heal" / "stamina" effect = "heal", -- The status effect given by the item, "heal" / "stamina"
time = 10000, -- How long the effect should last (if not added it will default to 10000) time = 10000, -- How long the effect should last (if not added it will default to 10000)
amount = 6, -- How much the value is changed by per second amount = 6, -- How much the value is changed by per second
hunger = math.random(10,20), -- The hunger/thirst stats of the item, if not found in the items.lua hunger = math.random(10,20), -- The hunger/thirst stats of the item, if not found in the items.lua
thirst = math.random(10,20), -- The hunger/thirst stats of the item, if not found in the items.lua thirst = math.random(10,20), -- The hunger/thirst stats of the item, if not found in the items.lua
}, },
}, }, ]]
]]
}, },
Emotes = { Emotes = {
["drink"] = {"mp_player_intdrink", "loop_bottle", "Drink", AnimationOptions = ["drink"] = {"mp_player_intdrink", "loop_bottle", "Drink", AnimationOptions =

View File

@@ -1,10 +1,11 @@
name "Jim-Consumables" name "Jim-Consumables"
author "Jimathy" author "Jimathy"
version "v1.3" version "v1.3.2"
description "Consumable Script By Jimathy" description "Consumable Script By Jimathy"
fx_version "cerulean" fx_version "cerulean"
game "gta5" game "gta5"
lua54 'yes'
shared_scripts { 'config.lua', 'shared/*.lua' }
client_scripts { 'client/*.lua', } client_scripts { 'client/*.lua', }
server_scripts { 'server/*.lua' } server_scripts { 'server/*.lua' }
shared_scripts { 'config.lua', 'shared/*.lua' }

View File

@@ -6,7 +6,6 @@ for k, v in pairs(Config.Consumables) do
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
end end
RegisterNetEvent('jim-consumables:server:toggleItem', function(give, item, amount) RegisterNetEvent('jim-consumables:server:toggleItem', function(give, item, amount)
local src = source local src = source
if give == 0 or give == false then if give == 0 or give == false then
@@ -19,3 +18,17 @@ RegisterNetEvent('jim-consumables:server:toggleItem', function(give, item, amoun
end end
end end
end) end)
RegisterNetEvent('jim-consumables:server:addThirst', function(amount)
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.SetMetaData('thirst', amount)
TriggerClientEvent('hud:client:UpdateNeeds', source, Player.PlayerData.metadata.hunger, amount)
end)
RegisterNetEvent('jim-consumables:server:addHunger', function(amount)
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return end
Player.Functions.SetMetaData('hunger', amount)
TriggerClientEvent('hud:client:UpdateNeeds', source, amount, Player.PlayerData.metadata.thirst)
end)

View File

@@ -5,7 +5,7 @@ local time = 1000
function loadModel(model) if not HasModelLoaded(model) then function loadModel(model) if not HasModelLoaded(model) then
if Config.Debug then print("^5Debug^7: ^2Loading Model^7: '^6"..model.."^7'") end if Config.Debug then print("^5Debug^7: ^2Loading Model^7: '^6"..model.."^7'") end
while not HasModelLoaded(model) do while not HasModelLoaded(model) do
if time > 0 then time = time - 1 RequestModel(model) if time > 0 then time -= 1 RequestModel(model)
else time = 1000 print("^5Debug^7: ^3LoadModel^7: ^2Timed out loading model ^7'^6"..model.."^7'") break else time = 1000 print("^5Debug^7: ^3LoadModel^7: ^2Timed out loading model ^7'^6"..model.."^7'") break
end end
Wait(10) Wait(10)
@@ -58,8 +58,7 @@ function toggleItem(give, item, amount) TriggerServerEvent("jim-consumables:serv
--Screen Effects --Screen Effects
local alienEffect = false local alienEffect = false
function AlienEffect() function AlienEffect()
if alienEffect then return end if alienEffect then return else alienEffect = true end
alienEffect = true
if Config.Debug then print("^5Debug^7: ^3AlienEffect^7() ^2activated") end if Config.Debug then print("^5Debug^7: ^3AlienEffect^7() ^2activated") end
AnimpostfxPlay("DrugsMichaelAliensFightIn", 3.0, 0) AnimpostfxPlay("DrugsMichaelAliensFightIn", 3.0, 0)
Wait(math.random(5000, 8000)) Wait(math.random(5000, 8000))
@@ -95,8 +94,7 @@ function AlienEffect()
end end
local weedEffect = false local weedEffect = false
function WeedEffect() function WeedEffect()
if weedEffect then return end if weedEffect then return else weedEffect = true end
weedEffect = true
if Config.Debug then print("^5Debug^7: ^3WeedEffect^7() ^2activated") end if Config.Debug then print("^5Debug^7: ^3WeedEffect^7() ^2activated") end
AnimpostfxPlay("DrugsMichaelAliensFightIn", 3.0, 0) AnimpostfxPlay("DrugsMichaelAliensFightIn", 3.0, 0)
Wait(math.random(3000, 20000)) Wait(math.random(3000, 20000))
@@ -111,9 +109,8 @@ function WeedEffect()
end end
local trevorEffect = false local trevorEffect = false
function TrevorEffect() function TrevorEffect()
if trevorEffect then return end if trevorEffect then return else trevorEffect = true end
if Config.Debug then print("^5Debug^7: ^3TrevorEffect^7() ^2activated") end if Config.Debug then print("^5Debug^7: ^3TrevorEffect^7() ^2activated") end
trevorEffect = true
AnimpostfxPlay("DrugsTrevorClownsFightIn", 3.0, 0) AnimpostfxPlay("DrugsTrevorClownsFightIn", 3.0, 0)
Wait(3000) Wait(3000)
AnimpostfxPlay("DrugsTrevorClownsFight", 3.0, 0) AnimpostfxPlay("DrugsTrevorClownsFight", 3.0, 0)
@@ -127,9 +124,8 @@ function TrevorEffect()
end end
local turboEffect = false local turboEffect = false
function TurboEffect() function TurboEffect()
if turboEffect then return end if turboEffect then return else turboEffect = true end
if Config.Debug then print("^5Debug^7: ^3TurboEffect^7() ^2activated") end if Config.Debug then print("^5Debug^7: ^3TurboEffect^7() ^2activated") end
turboEffect = true
AnimpostfxPlay('RaceTurbo', 0, true) AnimpostfxPlay('RaceTurbo', 0, true)
SetTimecycleModifier('rply_motionblur') SetTimecycleModifier('rply_motionblur')
ShakeGameplayCam('SKY_DIVING_SHAKE', 0.25) ShakeGameplayCam('SKY_DIVING_SHAKE', 0.25)
@@ -144,9 +140,8 @@ function TurboEffect()
end end
local rampageEffect = false local rampageEffect = false
function RampageEffect() function RampageEffect()
if rampageEffect then return end if rampageEffect then return else rampageEffect = true end
if Config.Debug then print("^5Debug^7: ^3RampageEffect^7() ^2activated") end if Config.Debug then print("^5Debug^7: ^3RampageEffect^7() ^2activated") end
rampageEffect = true
AnimpostfxPlay('Rampage', 0, true) AnimpostfxPlay('Rampage', 0, true)
SetTimecycleModifier('rply_motionblur') SetTimecycleModifier('rply_motionblur')
ShakeGameplayCam('SKY_DIVING_SHAKE', 0.25) ShakeGameplayCam('SKY_DIVING_SHAKE', 0.25)
@@ -161,16 +156,38 @@ function RampageEffect()
end end
local focusEffect = false local focusEffect = false
function FocusEffect() function FocusEffect()
if focusEffect then return end if focusEffect then return else focusEffect = true end
if Config.Debug then print("^5Debug^7: ^3FocusEffect^7() ^2activated") end if Config.Debug then print("^5Debug^7: ^3FocusEffect^7() ^2activated") end
focusEffect = true Wait(1000)
AnimpostfxPlay('FocusIn', 0, true) AnimpostfxPlay('FocusIn', 0, true)
Wait(30000) Wait(30000)
Wait(1000)
AnimpostfxStop('FocusIn') AnimpostfxStop('FocusIn')
focusEffect = false focusEffect = false
if Config.Debug then print("^5Debug^7: ^3FocusEffect^7() ^2stopped") end if Config.Debug then print("^5Debug^7: ^3FocusEffect^7() ^2stopped") end
end end
local NightVisionEffect = false
function NightVisionEffect()
if NightVisionEffect then return else NightVisionEffect = true end
if Config.Debug then print("^5Debug^7: ^3NightVisionEffect^7() ^2activated") end
SetNightvision(true)
Wait(math.random(3000, 4000)) -- FEEL FREE TO CHANGE THIS
SetNightvision(false)
SetSeethrough(false)
NightVisionEffect = false
if Config.Debug then print("^5Debug^7: ^3NightVisionEffect^7() ^2stopped") end
end
local thermalEffect = false
function ThermalEffect()
if thermalEffect then return else thermalEffect = true end
if Config.Debug then print("^5Debug^7: ^3ThermalEffect^7() ^2activated") end
SetNightvision(true)
SetSeethrough(true)
Wait(math.random(2000, 3000)) -- FEEL FREE TO CHANGE THIS
SetNightvision(false)
SetSeethrough(false)
thermalEffect = false
if Config.Debug then print("^5Debug^7: ^3ThermalEffect^7() ^2stopped") end
end
--Built-in Buff effects --Built-in Buff effects
local healEffect = false local healEffect = false
@@ -181,7 +198,7 @@ function HealEffect(data)
local count = (data[1] / 1000) local count = (data[1] / 1000)
while count > 0 do while count > 0 do
Wait(1000) Wait(1000)
count = count - 1 count -= 1
SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) + data[2]) SetEntityHealth(PlayerPedId(), GetEntityHealth(PlayerPedId()) + data[2])
end end
healEffect = false healEffect = false
@@ -198,7 +215,7 @@ function StaminaEffect(data)
while startStamina > 0 do while startStamina > 0 do
Wait(1000) Wait(1000)
if math.random(5, 100) < 10 then RestorePlayerStamina(PlayerId(), data[2]) end if math.random(5, 100) < 10 then RestorePlayerStamina(PlayerId(), data[2]) end
startStamina = startStamina - 1 startStamina -= 1
if math.random(5, 100) < 51 then end if math.random(5, 100) < 51 then end
end end
startStamina = 0 startStamina = 0
@@ -207,7 +224,7 @@ function StaminaEffect(data)
if Config.Debug then print("^5Debug^7: ^3StaminaEffect^7() ^2stopped") end if Config.Debug then print("^5Debug^7: ^3StaminaEffect^7() ^2stopped") end
end end
function StopEffects() function StopEffects() -- Used to clear up any effects stuck on screen
if Config.Debug then print("^5Debug^7: ^2All screen effects stopped") end if Config.Debug then print("^5Debug^7: ^2All screen effects stopped") end
ShakeGameplayCam('DRUNK_SHAKE', 0.0) ShakeGameplayCam('DRUNK_SHAKE', 0.0)
SetPedToRagdoll(PlayerPedId(), 5000, 1000, 1, 0, 0, 0) SetPedToRagdoll(PlayerPedId(), 5000, 1000, 1, 0, 0, 0)
@@ -216,6 +233,8 @@ function StopEffects()
ResetPedMovementClipset(PlayerPedId(), 0) ResetPedMovementClipset(PlayerPedId(), 0)
SetPedIsDrunk(PlayerPedId(), false) SetPedIsDrunk(PlayerPedId(), false)
SetPedMotionBlur(PlayerPedId(), false) SetPedMotionBlur(PlayerPedId(), false)
SetNightvision(false)
SetSeethrough(false)
AnimpostfxStop("DrugsMichaelAliensFightIn") AnimpostfxStop("DrugsMichaelAliensFightIn")
AnimpostfxStop("DrugsMichaelAliensFight") AnimpostfxStop("DrugsMichaelAliensFight")
AnimpostfxStop("DrugsMichaelAliensFightOut") AnimpostfxStop("DrugsMichaelAliensFightOut")