Help with hunger system
#1

I made a hunger system but I need to make it as percentage and textdraw so each minute it decreases 1 like for example my hunger is 99 next minute it should be 98 and so on...

Here is my script http://pastebin.com/qJ8db6e2
Reply
#2

Set a timer every minute under OnFiletScriptInit()

pawn Код:
SetTimerEx("HungyCheck", 60000, true, "i", playerid);
Create function.

pawn Код:
forward HungryCheck();

public HungryCheck()
{
    // YourVariableForHungy--;
    return 1;
}
At your variable for hungry add your variable, but add "--" without " ". Because this will increase hungry with -1.

pawn Код:
public OnPlayerUpdate(playerid)
{
    new text[4];
    format(text, sizeof(text), "%d", YourHungryVariable);
    TextDrawSetString(Hungy[playerid], text);
    return 1;
}
This function under OnPlayerUpdate() will check how many hunger you are, and will display hunger on player's screens.

Replace all YourHungyVariable.

Reply
#3

You can use ProgressBar include too
Reply
#4

Quote:
Originally Posted by Clad
Посмотреть сообщение
You can use ProgressBar include too
Can I use it to make percentage textdraw?
Reply
#5

Progress bar will create a bar. Wich can increase/decrease.

https://sampforum.blast.hk/showthread.php?tid=113443
Reply
#6

He said can you make a percentage bar not a progress bar...
Reply
#7

@HY: Why don't you put the textdraw-update in that same timer, instead of under OnPlayerUpdate?
The variable gets changed once a minute, there's no need to update the textdraws 50 times a seconds...
Reply
#8

When I put the hungry variable it gives me this error

Код:
.pwn(45) : error 022: must be lvalue (non-constant)
.pwn(45) : warning 215: expression has no effect
at this line

Код:
forward HungryCheck();

public HungryCheck()
{
    thing --;
    return 1;
}
Reply
#9

My foult:

pawn Код:
forward HungryCheck(playerid);

public HungryCheck(playerid)
{
    thing --;
    return 1;
}
Reply
#10

[removed]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)