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%");
}
}
}
}