SA-MP Forums Archive
Hunger System - TextDraw bug. - 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 System - TextDraw bug. (/showthread.php?tid=442389)



Hunger System - TextDraw bug. - faff - 07.06.2013

Hello, I've made an timer to update the textdraw.

The problem was.. It's updating all textdraws, instead of updating the Hunger Textdraw only..

pawn Код:
forward HungryLost();
public HungryLost() // Must be a public.
{
    for(new i; i<MAX_PLAYERS; i++) // Loop for all players
    {
       new TDstring[150];
       format(TDstring, sizeof(TDstring), "Hunger: %d %", PlayerInfo[i][pHunger]);

       new Float:Health;
       GetPlayerHealth(i, Health);
       if(!aDuty[i] && !mDuty[i])
       {
        if(PlayerInfo[i][pHunger] >= 1)
        {
        PlayerInfo[i][pHunger] --;
        TextDrawSetString(hunger[i], TDstring);
        }
        else
        {
        SetPlayerHealth(i,Health-5);
        PlayerInfo[i][pHungry] = 1;
        PlayerInfo[i][pHunger] = 0;
        TextDrawSetString(hunger[i], TDstring);
        }
       }
    }
    return 1;
}

This is the timer..

I hope somebody could help me. Thanks.


Re: Hunger System - TextDraw bug. - faff - 07.06.2013

Hmm?


Re: Hunger System - TextDraw bug. - Tingesport - 07.06.2013

Try.

pawn Код:
forward HungryLost();
public HungryLost() // Must be a public.
{
    for(new i; i<MAX_PLAYERS; i++) // Loop for all players
    {
       new TDstring[150];
       format(TDstring, sizeof(TDstring), "Hunger: %d %", PlayerInfo[i][pHunger]);

       new Float:Health;
       GetPlayerHealth(i, Health);
       if(!aDuty[i] && !mDuty[i])
       {
        if(PlayerInfo[i][pHunger] >= 1)
        {
        PlayerInfo[i][pHunger] --;
        TextDrawSetString(PlayerInfo[i][pHunger], TDstring);
        }
        else
        {
        SetPlayerHealth(i,Health-5);
        PlayerInfo[i][pHungry] = 1;
        PlayerInfo[i][pHunger] = 0;
        TextDrawSetString(PlayerInfo[i][pHunger], TDstring);
        }
       }
    }
    return 1;
}



Re: Hunger System - TextDraw bug. - faff - 07.06.2013

''hunger' is the name of the textdraw


Re: Hunger System - TextDraw bug. - Tingesport - 07.06.2013

Ohyea, fuck I'm dumb hahah :$

pawn Код:
forward HungryLost();
public HungryLost() // Must be a public.
{
    for(new i; i<MAX_PLAYERS; i++) // Loop for all players
    {
       new TDstring[150];
       format(TDstring, sizeof(TDstring), "Hunger: %d", hunger[i]);

       new Float:Health;
       GetPlayerHealth(i, Health);
       if(!aDuty[i] && !mDuty[i])
       {
        if(PlayerInfo[i][pHunger] >= 1)
        {
        PlayerInfo[i][pHunger] --;
        TextDrawSetString(hunger[i], TDstring);
        }
        else
        {
        SetPlayerHealth(i,Health-5);
        PlayerInfo[i][pHungry] = 1;
        PlayerInfo[i][pHunger] = 0;
        TextDrawSetString(hunger[i], TDstring);
        }
       }
    }
    return 1;
}



Re: Hunger System - TextDraw bug. - faff - 07.06.2013

LOL, that format doesnt need the textdrawname in it .
That PlayerInfo, is to fill up %d.