[TextDraw ]Timer and String
#1

Hey Guys,

Sorry for my english, i come from Germany!
I have a TextDraw with "Durst" and a String and a Timer.
And the TextDraw soll "Durst: 1- 100 %".

Wie?

Canna
Reply
#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
#3

hmm sorry I can not understand: (
I now use the translator that you may understand me better
So, I have 4 textdraws defined above in the script:
Код:
new Text:Textdraw0;
new Text:Textdraw1;
new Text:Textdraw2;
new Text:Textdraw3;
The timer starts at OnGameModeInit:
Код:
BeduerfnissTimer = SetTimer("Bedarfs",180000, 1);
And the public Bedarfs for the Timer:
Код:
public Bedarfs()
{
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	    if(IsPlayerConnected(i))
	    {
	        if(gPlayerLogged[i] == 1)
	        {
		        if(SpielerInfo[i][Textdraw0] < 100)
		        {
		            SpielerInfo[i][Textdraw0]++;
		        }
				if(SpielerInfo[i][Textdraw1] < 100)
				{
				    SpielerInfo[i][Textdraw1]++;
				}
				if(SpielerInfo[i][Textdraw2] < 100)
				{
				    SpielerInfo[i][Textdraw2]++;
				}
				if(SpielerInfo[i][Textdraw3] < 100)
				{
				    SpielerInfo[i][Textdraw3]++;
				}
	        }
	    }
	}
}
What is wrong?
Would be nice if I could give a equal to the code because I only started with the script
Reply
#4

Something like that ?

pawn Код:
new Text:Textdraw0;
new Text:Textdraw1;
new Text:Textdraw2;
new Text:Textdraw3;

new BeduerfnissTimer;
new gPlayerLogged[MAX_PLAYERS];
new SpielerInfo[MAX_PLAYERS][Text:MAX_TEXT_DRAWS];
pawn Код:
//OnGameModeInit
BeduerfnissTimer = SetTimer("Bedarfs",180000, 1);

Textdraw0 = TextDrawCreate(x, y, "_");
Textdraw1 = TextDrawCreate(x, y, "_");
Textdraw2 = TextDrawCreate(x, y, "_");
Textdraw3 = TextDrawCreate(x, y, "_");
pawn Код:
forward Bedarfs();
public Bedarfs()
{
    for(new i = 0, string[64]; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(gPlayerLogged[i] == 1)
            {
                if(SpielerInfo[i][Textdraw0] < 100)
                {
                    SpielerInfo[i][Textdraw0]++; // Ist das hier die Durst variable ?
                    format(string, sizeof(string), "Durst %d%%", SpielerInfo[i][Textdraw0]);
                    TextDrawSetString(Textdraw0, string);
                }
                if(SpielerInfo[i][Textdraw1] < 100)
                {
                    SpielerInfo[i][Textdraw1]++; // Noch eine ?
                    format(string, sizeof(string), "Durst %d%%", SpielerInfo[i][Textdraw1]);
                    TextDrawSetString(Textdraw1, string);
                }
                if(SpielerInfo[i][Textdraw2] < 100)
                {
                    SpielerInfo[i][Textdraw2]++; // *Verwirrt* :p
                    format(string, sizeof(string), "Durst %d%%", SpielerInfo[i][Textdraw2]);
                    TextDrawSetString(Textdraw2, string);
                }
                if(SpielerInfo[i][Textdraw3] < 100)
                {
                    SpielerInfo[i][Textdraw3]++; // gn8
                    format(string, sizeof(string), "Durst %d%%", SpielerInfo[i][Textdraw3]);
                    TextDrawSetString(Textdraw3, string);
                }
            }
        } // Es gibt auch eine Forumuntergruppe fьr Deutsche
    } // Zwar ist dise so gut wie nie nie besucht, aber man darf dort deutsch reden ^^
}
Reply
#5

No it is not still, can you tell me icq or msn perhaps help skype on?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)