mirror of
https://github.com/jimathy/jim-consumables.git
synced 2026-08-16 22:16:02 +01:00
fix needStats calculcation
My mad on this one, got `needTypes` and `needStats` confused, so made it just one table and included stress in it
This commit is contained in:
@@ -137,14 +137,15 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
|||||||
local canRun = consumable.canRun
|
local canRun = consumable.canRun
|
||||||
local stats = consumable.stats
|
local stats = consumable.stats
|
||||||
|
|
||||||
local time, stress, heal, armor, needStats = GenerateRandomValues({
|
local time, heal, armor, needStats = GenerateRandomValues({
|
||||||
time = consumable.time or { 5000, 6000 },
|
time = consumable.time or { 5000, 6000 },
|
||||||
stress = consumable.stress or 0,
|
|
||||||
heal = consumable.heal or 0,
|
heal = consumable.heal or 0,
|
||||||
armor = consumable.armor or 0,
|
armor = consumable.armor or 0,
|
||||||
hunger = consumable.stats and consumable.stats.hunger or 0,
|
hunger = consumable.stats and consumable.stats.hunger or 0,
|
||||||
thirst = consumable.stats and consumable.stats.thirst or 0,
|
thirst = consumable.stats and consumable.stats.thirst or 0,
|
||||||
|
stress = consumable.stress or 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
if emote.AnimationOptions.Prop then
|
if emote.AnimationOptions.Prop then
|
||||||
model = emote.AnimationOptions.Prop
|
model = emote.AnimationOptions.Prop
|
||||||
bone = GetPedBoneIndex(Player, emote.AnimationOptions.PropBone)
|
bone = GetPedBoneIndex(Player, emote.AnimationOptions.PropBone)
|
||||||
@@ -263,7 +264,7 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
|||||||
"Type: "..(type or ""),
|
"Type: "..(type or ""),
|
||||||
"Hunger: "..(needStats.hunger or 0).."%",
|
"Hunger: "..(needStats.hunger or 0).."%",
|
||||||
"Thirst: "..(needStats.thirst or 0).."%",
|
"Thirst: "..(needStats.thirst or 0).."%",
|
||||||
"Stress: "..(stress or 0).."%",
|
"Stress: "..(needStats.stress or 0).."%",
|
||||||
"Heal: "..(heal or 0).."%",
|
"Heal: "..(heal or 0).."%",
|
||||||
"Armour: "..(armor or 0).."%",
|
"Armour: "..(armor or 0).."%",
|
||||||
}, nil, nil)
|
}, nil, nil)
|
||||||
@@ -294,25 +295,22 @@ RegisterNetEvent(getScript()..':Consume', function(itemName)
|
|||||||
|
|
||||||
if not cancelled then
|
if not cancelled then
|
||||||
hideText()
|
hideText()
|
||||||
local needTypes = { }
|
|
||||||
|
|
||||||
if needStats then
|
if needStats then
|
||||||
|
|
||||||
--jsonPrint(needStats)
|
|
||||||
if needStats.hunger > 0 then
|
if needStats.hunger > 0 then
|
||||||
needTypes.hunger = needTypes.hunger > 100 and 100 or needTypes.hunger
|
needStats.hunger = needStats.hunger > 100 and 100 or needStats.hunger
|
||||||
end
|
end
|
||||||
|
|
||||||
if needStats.thirst > 0 then
|
if needStats.thirst > 0 then
|
||||||
needTypes.thirst = needTypes.thirst > 100 and 100 or needTypes.thirst
|
needStats.thirst = needStats.thirst > 100 and 100 or needStats.thirst
|
||||||
|
end
|
||||||
|
|
||||||
|
if needStats.stress > 0 then
|
||||||
|
needStats.stress = needStats.stress > 100 and 100 or needStats.stress
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
TriggerServerEvent(getScript()..":server:finishConsume", needTypes)
|
TriggerServerEvent(getScript()..":server:finishConsume", needStats)
|
||||||
|
|
||||||
if stress and stress ~= 0 then
|
|
||||||
debugPrint("^5Debug^7: ^3Consume^7: ^2Relieving ^6"..stress.." ^2stress^7.")
|
|
||||||
needTypes.stress = stress
|
|
||||||
end
|
|
||||||
if heal and heal ~= 0 then
|
if heal and heal ~= 0 then
|
||||||
debugPrint("^5Debug^7: ^3Consume^7: ^2Healing player by^7: ^6"..heal)
|
debugPrint("^5Debug^7: ^3Consume^7: ^2Healing player by^7: ^6"..heal)
|
||||||
SetEntityHealth(Player, GetEntityHealth(Player) + heal)
|
SetEntityHealth(Player, GetEntityHealth(Player) + heal)
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ function GenerateRandomValues(data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
return transData["time"],
|
return transData["time"],
|
||||||
transData["stress"],
|
|
||||||
transData["heal"],
|
transData["heal"],
|
||||||
transData["armor"],
|
transData["armor"],
|
||||||
{ hunger = transData["hunger"], thirst = transData["thirst"] }
|
{ hunger = transData["hunger"], thirst = transData["thirst"], stress = transData["stress"] }
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user