Hellow, thanks for read, thats the problem... i was trying to do something like that.
any idea about how to do that?
function Itemcool()
local inv = getPlayer():getInventory();
it = inv:FindAndReturn("Base.Apple");
if it then
inv:Remove("Apple");
A = random number between (0 to 100)
-- Roll a number between 0 and 100
if A <= 30 then { Player Hunger-10} else {Player Hunger -20}
-- 30% chance of lose 10 of hunger and 70% chance of lose 20 Hunger
end
end
Events.OnPlayerUpdate.Add(Itemcool);
Solution --->
function Itemcool() local inv = getPlayer():getInventory();
local player = getPlayer();
it = inv:FindAndReturn("Base.Apple");
if it then
inv:Remove("Apple");
if ZombRand( 100 ) <= 30 then
player:getStats():setThirst (player:getStats():getThirst() + 0.05);
else
player:getStats():setThirst (player:getStats():getThirst() + 0.15);
end end
end
--// 30% chance of get 0.05 thirst and 70% of get 0.15%
Events.OnPlayerUpdate.Add(Itemcool);