Hunger System
#1

How to make Hunger System with Progress bar ?
Reply
#2

Have a timer decrease a variable that holds the player's hunger. Here's a progress bar include, which you can set with the hunger variable.
Reply
#3

Quote:
Originally Posted by Jstylezzz
Посмотреть сообщение
Have a timer decrease a variable that holds the player's hunger. Here's a progress bar include, which you can set with the hunger variable.
Scripts ?
Reply
#4

Quote:
Originally Posted by WhiteAngels
Посмотреть сообщение
Scripts ?
You ask how to make it and Jstylezzz told you. If you need someone to script it for you go here.
Reply
#5

Quote:
Originally Posted by doreto
Посмотреть сообщение
You ask how to make it and Jstylezzz told you. If you need someone to script it for you go here.
I mean,I have created the progress bar textdraw , but i can't make it to Hunger System. How to make Hunger System with this Textdraw & with the command /eat please ?

Textdraw
Код:
new Bar:bar = CreateProgressBar(495.00, 131.00, 119.50, 11.19, -16776961, 100.0);
Reply
#6

Here's an example, and note, it's not copy paste code.
pawn Код:
new Bar:hungerbar[MAX_PLAYERS];
public OnPlayerConnect(playerid) //When a player connects
{
    hungerbar[playerid] = CreateProgressBar(495.00, 131.00, 119.50, 11.19, -16776961, 100.0); //Create a separate progress bar for each player when they join
}
public OnGameModeInit() //When the gamemmode loads
{
    SetTimer("HungerCallback",300000,1); //Set a timer that calls the hunger function (300000 milliseconds is 5 minutes. Note that without the fixes plugin that fixes the timers, it could be a little less than 5 minutes)
}

public HungerCallback() //Hunger function
{
    for(new i=0; i < MAX_PLAYERS; i++) //Loop through players
    {
        pInfo[i][Hunger] -= random(3); //Say that you start with 100 (meaning that stomach is full), each time this callback is called it takes away a value between 0 - 3 ( 1 or 2 )
        SetProgressBarValue(hungerbar[i], pInfo[i][Hunger]); //Sets the progress bar to the hunger value
    }
}

CMD:eat(playerid,params[]) //Example eat command
{
    SendClientMessage(playerid, -1, "Hmmmm.. that was some good food!"); //Send message to let the player know they're full again
    pInfo[playerid][Hunger] = 100; // 'fill the stomach'
    SetProgressBarValue(hungerbar[playerid], pInfo[playerid][Hunger]); //Sets the progress bar to the hunger value
    return 1;
}
I hope this clarifies it a little more. And as Doreto said, go to that link if you want someone to script it for you (although it's would be the best if you continue to learn and continue this yourself )

And again, this was written pretty fast, and probably won't work. It's just to give you an example of how it *could* be done.
Reply
#7

Quote:
Originally Posted by Jstylezzz
Посмотреть сообщение
Here's an example, and note, it's not copy paste code.
pawn Код:
new Bar:hungerbar[MAX_PLAYERS];
public OnPlayerConnect(playerid) //When a player connects
{
    hungerbar[playerid] = CreateProgressBar(495.00, 131.00, 119.50, 11.19, -16776961, 100.0); //Create a separate progress bar for each player when they join
}
public OnGameModeInit() //When the gamemmode loads
{
    SetTimer("HungerCallback",300000,1); //Set a timer that calls the hunger function (300000 milliseconds is 5 minutes. Note that without the fixes plugin that fixes the timers, it could be a little less than 5 minutes)
}

public HungerCallback() //Hunger function
{
    for(new i=0; i < MAX_PLAYERS; i++) //Loop through players
    {
        pInfo[i][Hunger] -= random(3); //Say that you start with 100 (meaning that stomach is full), each time this callback is called it takes away a value between 0 - 3 ( 1 or 2 )
        SetProgressBarValue(hungerbar[i], pInfo[i][Hunger]); //Sets the progress bar to the hunger value
    }
}

CMD:eat(playerid,params[]) //Example eat command
{
    SendClientMessage(playerid, -1, "Hmmmm.. that was some good food!"); //Send message to let the player know they're full again
    pInfo[playerid][Hunger] = 100; // 'fill the stomach'
    SetProgressBarValue(hungerbar[playerid], pInfo[playerid][Hunger]); //Sets the progress bar to the hunger value
    return 1;
}
I hope this clarifies it a little more. And as Doreto said, go to that link if you want someone to script it for you (although it's would be the best if you continue to learn and continue this yourself )

And again, this was written pretty fast, and probably won't work. It's just to give you an example of how it *could* be done.
Thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)