20.06.2012, 10:14
ok I will tell you working with the above example
First, we need to create a textdraw.
Now we will create a textdraw at position 611(X) ,120(Y).
To decorate it we add
So, now we want to update our textdraw after 1 second.
So we make a timer
And Now Make the timer call a function (which decreases textdraw) after 1 sec.
Also we need some variable to store current value of textdraw
Now let's make the function which decreases the value of time.
Full Code :
First, we need to create a textdraw.
pawn Код:
new Text:Textdraw0;//This will be needed to edit the textdraw etc.
pawn Код:
Textdraw0 = TextDrawCreate(611.000000, 120.000000, "100");//100 is the text
pawn Код:
TextDrawAlignment(Textdraw0, 3);
TextDrawBackgroundColor(Textdraw0, 255);
TextDrawFont(Textdraw0, 2);
TextDrawLetterSize(Textdraw0, 0.440000, 1.800000);
TextDrawColor(Textdraw0, -1446714113);
TextDrawSetOutline(Textdraw0, 1);
TextDrawSetProportional(Textdraw0, 1);
So we make a timer
pawn Код:
new GameTimer;
pawn Код:
GameTimer = SetTimer("GameTime",1000,1);//1 second
pawn Код:
new time=100;//As textdraw was 100 in starting
pawn Код:
forward GameTime();
public GameTime()
{
time=time-1;//Here we decreases value of time by 1
new str[20];//A string to update textdraw
format(str,sizeof(str),"%d",time);//Value of time is copied into %d(str).
TextDrawSetString(Textdraw0,str);//Replace text of textdraw with str.
return 1;
}
pawn Код:
new Text:Textdraw0;//This will be needed to edit the textdraw etc.
new GameTimer;
new time=100;//As textdraw was 100 in starting
public OnGameModeInit()
{
Textdraw0 = TextDrawCreate(611.000000, 120.000000, "100");//100 is the text
TextDrawAlignment(Textdraw0, 3);
TextDrawBackgroundColor(Textdraw0, 255);
TextDrawFont(Textdraw0, 2);
TextDrawLetterSize(Textdraw0, 0.440000, 1.800000);
TextDrawColor(Textdraw0, -1446714113);
TextDrawSetOutline(Textdraw0, 1);
TextDrawSetProportional(Textdraw0, 1);
GameTimer = SetTimer("GameTime",1000,1);//1 second
//All your other code
}
forward GameTime();
public GameTime()
{
time=time-1;//Here we decreases value of time by 1
new str[20];//A string to update textdraw
format(str,sizeof(str),"%d",time);//Value of time is copied into %d(str).
TextDrawSetString(Textdraw0,str);//Replace text of textdraw with str.
return 1;
}