[TextDraw ]Timer and String
#2

Quote:
Originally Posted by Canna
Посмотреть сообщение
Hey Guys,
Welcome Canna

Quote:
Originally Posted by Canna
Посмотреть сообщение
Sorry for my english, i come from Germany!
Many people say that but its not an excuse -_-
By the way there is the MIGHTY ****** translator

Quote:
Originally Posted by Canna
Посмотреть сообщение
I have a TextDraw with "Durst" and a String and a Timer.
And the TextDraw soll "Durst: 1- 100 %".

Wie?

Canna
so you have a "Durst" variable (playerbased ? I suppose)
and a textdraw which shows it
pawn Код:
new Durst[MAX_PLAYERS] = {100, ...}; //Sets the whole array to 100
new Text:t_Durst[MAX_PLAYERS] = {Text:INVALID_TEXT_DRAW, ...};
Now our timer, we just start him if the gamemode starts
pawn Код:
//OnGameModeInit
SetTimer("Thirsty", 30 * 1000, true); //All 30 seconds
We add our textdraw at OnPlayerConnect with TextDrawCreate
And destroy it at OnPlayerDisconnect
pawn Код:
//OnPlayerConnect
t_Durst[playerid] = TextDrawCreate(0.0, 0.0, "_");
//You can change the font and so on with the function on the bottom of the TextDrawCreate page
pawn Код:
//OnPlayerDisconnect
TextDrawDestroy(t_Durst[playerid]);
t_Durst[playerid] = Text:INVALID_TEXT_DRAW;
Now our timer code
pawn Код:
forward Thirsty();
public Thirsty()
{
    for(new i, string[16], Float:health; i != MAX_PLAYERS; i++)
    {
        if(t_Durst[i] != (Text:INVALID_TEXT_DRAW))
        {
            if(Durst[i] > 0.0)
            {
                Durst[i] --;
                format(string, sizeof string, "Durst: %d%%", Durst[i]);
                TextDrawSetString(t_Durst[i], string);
            } else {
                GetPlayerHealth(i, health);
                SetPlayerHealth(i, (health - 1.0));
                TextDrawSetString(t_Durst[i], "Durst: 0%");
            }
        }
    }
}
Reply


Messages In This Thread
[TextDraw ]Timer and String - by Canna - 14.12.2010, 16:49
Re: [TextDraw ]Timer and String - by Nero_3D - 14.12.2010, 17:31
AW: [TextDraw ]Timer and String - by Canna - 14.12.2010, 22:19
Re: AW: [TextDraw ]Timer and String - by Nero_3D - 14.12.2010, 22:42
AW: [TextDraw ]Timer and String - by Canna - 15.12.2010, 00:25

Forum Jump:


Users browsing this thread: 1 Guest(s)