mirror of
https://github.com/jimathy/jim-consumables.git
synced 2026-08-18 15:06:03 +01:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e794d9a446 | ||
|
|
541263b156 | ||
|
|
60c42b2506 | ||
|
|
2a4de6fdc1 | ||
|
|
4b015e5efa |
@@ -172,7 +172,7 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
|||||||
debugPrint("^5Debug^7: ^3Consume^7: ^2Event already started^7, ^1Cancelling^7.")
|
debugPrint("^5Debug^7: ^3Consume^7: ^2Event already started^7, ^1Cancelling^7.")
|
||||||
tempLockInv(false)
|
tempLockInv(false)
|
||||||
if Config.UseProgbar then
|
if Config.UseProgbar then
|
||||||
stopPropgressBar()
|
stopProgressBar()
|
||||||
else
|
else
|
||||||
triggerNotify(nil, "Stopped "..string, "error")
|
triggerNotify(nil, "Stopped "..string, "error")
|
||||||
end
|
end
|
||||||
@@ -208,9 +208,17 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
|||||||
debugPrint("^5Debug^7: ^3Consume^7: ^2Player Movement Flag^7 - ^6"..json.encode(MovementType).." ^7")
|
debugPrint("^5Debug^7: ^3Consume^7: ^2Player Movement Flag^7 - ^6"..json.encode(MovementType).." ^7")
|
||||||
if Config.Main.UseProgbar then
|
if Config.Main.UseProgbar then
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
if progressBar({ time = time, label = string..Items[itemName].label.."..", dead = false, cancel = false}) then
|
if progressBar({
|
||||||
|
time = time,
|
||||||
|
label = string..Items[itemName].label.."..",
|
||||||
|
dead = false,
|
||||||
|
disableMovement = false,
|
||||||
|
disableCombat = true,
|
||||||
|
cancel = false
|
||||||
|
}) then
|
||||||
consuming = false
|
consuming = false
|
||||||
else
|
else
|
||||||
|
consuming = false
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
@@ -273,7 +281,7 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
|||||||
tempLockInv(false)
|
tempLockInv(false)
|
||||||
hideText()
|
hideText()
|
||||||
if Config.Main.UseProgbar then
|
if Config.Main.UseProgbar then
|
||||||
stopPropgressBar()
|
stopProgressBar()
|
||||||
else
|
else
|
||||||
triggerNotify(nil, "Cancelled "..string, "error")
|
triggerNotify(nil, "Cancelled "..string, "error")
|
||||||
end
|
end
|
||||||
@@ -313,24 +321,33 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
if needStats then
|
if needStats then
|
||||||
if needStats.hunger then
|
jsonPrint(needStats)
|
||||||
|
if needStats.hunger > 0 then
|
||||||
local hunger = 0
|
local hunger = 0
|
||||||
if Core.Functions and Core.Functions.GetPlayerData then
|
if Core and Core.Functions then
|
||||||
hunger = Core.Functions.GetPlayerData().metadata["hunger"] or 0
|
hunger = (Core.Functions.GetPlayerData().metadata["hunger"] or 0) + needStats.hunger
|
||||||
|
hunger = hunger > 100 and 100 or hunger
|
||||||
|
|
||||||
elseif ESX and ESX.GetPlayerData then
|
elseif ESX and ESX.GetPlayerData then
|
||||||
hunger = ESX.GetPlayerData().hunger or 0
|
hunger = (needStats.hunger / 100) * 1000000
|
||||||
end
|
hunger = hunger > 1000000 and 1000000 or hunger
|
||||||
TriggerServerEvent(getScript()..":server:addNeed", hunger + needStats.hunger, "hunger")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if needStats.thirst then
|
TriggerServerEvent(getScript()..":server:setNeed", "hunger", hunger)
|
||||||
local thirst = 0
|
|
||||||
if Core.Functions and Core.Functions.GetPlayerData then
|
|
||||||
thirst = Core.Functions.GetPlayerData().metadata["thirst"] or 0
|
|
||||||
elseif ESX and ESX.GetPlayerData then
|
|
||||||
thirst = ESX.GetPlayerData().thirst or 0
|
|
||||||
end
|
end
|
||||||
TriggerServerEvent(getScript()..":server:addNeed", thirst + needStats.thirst, "thirst")
|
|
||||||
|
if needStats.thirst > 0 then
|
||||||
|
local thirst = 0
|
||||||
|
if Core and Core.Functions then
|
||||||
|
thirst = (Core.Functions.GetPlayerData().metadata["thirst"] or 0) + needStats.thirst
|
||||||
|
thirst = thirst > 100 and 100 or thirst
|
||||||
|
|
||||||
|
elseif ESX and ESX.GetPlayerData then
|
||||||
|
thirst = (needStats.thirst / 100) * 1000000
|
||||||
|
thirst = thirst > 1000000 and 1000000 or thirst
|
||||||
|
end
|
||||||
|
|
||||||
|
TriggerServerEvent(getScript()..":server:setNeed", "thirst", thirst)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
debugPrint("^5Debug^7: ^2Hunger^7: [^6"..(needStats.hunger or 0).."^7] ^2Thrist^7: [^6"..(needStats.thirst or 0).."^7]" )
|
debugPrint("^5Debug^7: ^2Hunger^7: [^6"..(needStats.hunger or 0).."^7] ^2Thrist^7: [^6"..(needStats.thirst or 0).."^7]" )
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ Config = {
|
|||||||
|
|
||||||
},
|
},
|
||||||
Main = {
|
Main = {
|
||||||
UseProgbar = false, -- Disabled this, progress bars stop all anims when complete.
|
UseProgbar = false, -- Recommended to disable this, progress bars stop ALL anims when complete.
|
||||||
-- This is intended to create a progressbar to show consuming but it was usually forces animations to end weirdly
|
-- This is intended to create a progressbar to show consuming but it was usually forces animations to end weirdly
|
||||||
},
|
},
|
||||||
Crafting = {
|
Crafting = {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name "Jim-Consumables"
|
name "Jim-Consumables"
|
||||||
author "Jimathy"
|
author "Jimathy"
|
||||||
version "2.0.03"
|
version "2.0.05"
|
||||||
description "Consumables Script"
|
description "Consumables Script"
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
game "gta5"
|
game "gta5"
|
||||||
|
|||||||
@@ -18,40 +18,6 @@ onResourceStop(function()
|
|||||||
GlobalState.jimConsumableEmotes = Emotes
|
GlobalState.jimConsumableEmotes = Emotes
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent(getScript()..':server:addNeed', function(amount, type)
|
|
||||||
local src = source
|
|
||||||
|
|
||||||
if Core.Functions and Core.Functions.GetPlayer then -- QBCore/QBox
|
|
||||||
local Player = Core.Functions.GetPlayer(src)
|
|
||||||
if not Player then return end
|
|
||||||
|
|
||||||
if type == "thirst" then
|
|
||||||
Player.Functions.SetMetaData('thirst', amount)
|
|
||||||
TriggerClientEvent('hud:client:UpdateNeeds', src, Player.PlayerData.metadata.hunger, amount)
|
|
||||||
elseif type == "hunger" then
|
|
||||||
Player.Functions.SetMetaData('hunger', amount)
|
|
||||||
TriggerClientEvent('hud:client:UpdateNeeds', src, amount, Player.PlayerData.metadata.thirst)
|
|
||||||
end
|
|
||||||
|
|
||||||
elseif ESX and ESX.GetPlayerFromId then -- ESX
|
|
||||||
local xPlayer = ESX.GetPlayerFromId(src)
|
|
||||||
if not xPlayer then return end
|
|
||||||
|
|
||||||
local hunger = xPlayer.get('hunger') or 0
|
|
||||||
local thirst = xPlayer.get('thirst') or 0
|
|
||||||
|
|
||||||
if type == "thirst" then
|
|
||||||
thirst = amount
|
|
||||||
xPlayer.set('thirst', thirst)
|
|
||||||
elseif type == "hunger" then
|
|
||||||
hunger = amount
|
|
||||||
xPlayer.set('hunger', hunger)
|
|
||||||
end
|
|
||||||
|
|
||||||
TriggerClientEvent('hud:client:UpdateNeeds', src, hunger, thirst)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
local syncScheduled = false
|
local syncScheduled = false
|
||||||
function syncConsumables()
|
function syncConsumables()
|
||||||
debugPrint("^5Statebag^7: ^2Sending ^6"..countTable(Consumables).." ^3Consumables ^2to all clients^7")
|
debugPrint("^5Statebag^7: ^2Sending ^6"..countTable(Consumables).." ^3Consumables ^2to all clients^7")
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
2.0.03
|
2.0.05
|
||||||
|
|
||||||
- Convert to Global Statebags for optimized data syncing
|
- Fix ESX Hunger events
|
||||||
- Fix hunger/thirst for esx
|
- Fix minor progressBar option issues
|
||||||
- Possible fix for imported items not being usable
|
|
||||||
|
|
||||||
https://github.com/jimathy/jim-consumables
|
https://github.com/jimathy/jim-consumables
|
||||||
Reference in New Issue
Block a user