SA-MP Forums Archive
[FilterScript] Simple Hunger System - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Simple Hunger System (/showthread.php?tid=325755)



Simple Hunger System - AlexTracer - 14.03.2012

.: Hunger System :.
.: Description :.
This is a hunger system. After every spawn, after 600000 miliseconds, you'll lose 15% of your hunger (that you can see with /hungerInfo or /hin)... You can eat with /eat in the Burger Shot in the north of Los Santos (you can edit it and add new positions and items in the menu). If you have 0% of you hunger, you the health of your PG will set to 0.

.: Bugs :.
I have no found any bug at the moment. If you found one, please tell me about it.

.: Download :.
Here should be the download link .

.: How to add new places for eating and menu items :.
You can add places for eating. Here is the original script:
the command (string from 80 to 89):
pawn Code:
if(!strcmp(cmdtext, "/eat", true))
    {
        if(IsPlayerInRangeOfPoint(playerid, 7.0, 375.5660,-68.2220,1001.5151)) // You can edit this position or add new.
        {
            ShowPlayerDialog(playerid, 20401, DIALOG_STYLE_LIST, "What is it that you want?", "Chicken", "Purchase", "Cancel"); // You can add items
        }
        return 1;
    }
and the dialog( string from 91 to 110:
pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 20401 && response)
    {
        switch(listitem)
        {
            case 0: // We have only one item, but you can add some.
            {
                pHunger[playerid] = pHunger[playerid] + 15; // How many % of hunger to give the player
                if(pHunger[playerid] + 15 >= 100) // If the player eat this and get a % of hunger more then 100...
                {
                    pHunger[playerid] = 100; // ...it set the player hunger to 100%.
                }
                SendClientMessage(playerid, 0xFFFFFF, "You ate Chicken!");
                return 1;
            }
        }
    }
    return 1;
}
So, if you want to change/add places, save a position with the in-game command /save in the place where you want to use the /eat command. You must put the floats at the string 82, by adding again the IsPlayerInRageOfPoint function. Here is a example:
original:
pawn Code:
if(IsPlayerInRangeOfPoint(playerid, 7.0, 375.5660,-68.2220,1001.5151)) // You can edit this position or add new.
adding a new position:
pawn Code:
if(IsPlayerInRangeOfPoint(playerid, 7.0, 375.5660,-68.2220,1001.5151) || IsPlayerInRangeOfPoint(playerid, 7.0, 375.5660,-68.2220,1001.5151)) // You can edit this position or add new.
.

If you want to add items, you must add the item at the string 84 and separate every item only with \n (shown in the next examples) and then add the case (what happen if a player click the first button of the dialog). Example:
original:
pawn Code:
ShowPlayerDialog(playerid, 20401, DIALOG_STYLE_LIST, "What is it that you want?", "Chicken", "Purchase", "Cancel"); // You can add items
pawn Code:
if(dialogid == 20401 && response)
    {
        switch(listitem)
        {
            case 0: // We have only one item, but you can add some. Chicken.
            {
                pHunger[playerid] = pHunger[playerid] + 15; // How many % of hunger to give the player
                if(pHunger[playerid] + 15 >= 100) // If the player eat this and get a % of hunger more then 100...
                {
                    pHunger[playerid] = 100; // ...it set the player hunger to 100%.
                }
                SendClientMessage(playerid, 0xFFFFFF, "You ate Chicken!");
                return 1;
            }
        }
    }
adding items:
pawn Code:
ShowPlayerDialog(playerid, 20401, DIALOG_STYLE_LIST, "What is it that you want?", "Chicken\nChips", "Purchase", "Cancel"); // You can add items
pawn Code:
if(dialogid == 20401 && response)
    {
        switch(listitem)
        {
            case 0: // We have only one item, but you can add some. Chicken.
            {
                pHunger[playerid] = pHunger[playerid] + 15; // How many % of hunger to give the player
                if(pHunger[playerid] + 15 >= 100) // If the player eat this and get a % of hunger more then 100...
                {
                    pHunger[playerid] = 100; // ...it set the player hunger to 100%.
                }
                SendClientMessage(playerid, 0xFFFFFF, "You ate Chicken!");
                return 1;
            }
            case 1: // Second item. Chips.
            {
                // Add functions.
            }
        }
    }
.

Sorry my bad grammar :P.
Alex Tracer.


Re: Simple Hunger System - Issam - 14.03.2012

Nice and easy


Re: Simple Hunger System - AlexTracer - 14.03.2012

Ahahah, yes, its very easy , but useful for roleplays .


Re: Simple Hunger System - lordturhan - 15.03.2012

Question why don't you just edit the interiors (Clucking Bell etc) and make this script better.


Re: Simple Hunger System - AlexTracer - 15.03.2012

Because the place is only an example xD i think i'll do it but the script is for the hunger...