Hunger - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Hunger (
/showthread.php?tid=654442)
Hunger -
KamilPolska - 28.05.2018
I have a hunger and restaurant system. For example I have 95% of hunger. I can buy food that gives 1-5% of hunger. And if I buy food that gives 6-20%, it is supposed to pop out a message that I should choose other food. How to make?
Example:
I have 75% hunger.
I can buy food that gives 1-25% of hunger(Max.100% of hunger), not 26%
Re: Hunger -
aristoffky - 28.05.2018
So it isn't really unclear what you want but:
You should simply store a variable that contains the amount of food and perhaps a timer that removes the amount of food everytime some time has passed.
Then, you can make a function GetPlayerHunger() in which you check the variable and return the amount of hunger.
After that you check if when he's buying amounts of food that give higher than his possible maximum amount
(playerHunger > selectedOption) and if it is, you simply show a dialog.
Re: Hunger -
KamilPolska - 28.05.2018
To use: Player[playerid][Hunger];
I have this code:
Код:
if(listitem == 0)
{
if(GetPlayerMoney(playerid) >= 5)
{
GivePlayerMoney(playerid, -5);
Player[playerid][Hunger] = Player[playerid][Hunger] + 10;
}
else
{
return SendClientMessage(playerid, -1, "You can not afford this dish!");
}
}
Re: Hunger -
KamilPolska - 29.05.2018
@ref