19.06.2012, 07:41
How I work time left Countdown TextDraw?
// On top of script:
new Text:Textdraw0;
// In OnGameModeInit
Textdraw0 = TextDrawCreate(611.000000, 120.000000, "TIME 06:30");
TextDrawAlignment(Textdraw0, 3);
TextDrawBackgroundColor(Textdraw0, 255);
TextDrawFont(Textdraw0, 2);
TextDrawLetterSize(Textdraw0, 0.440000, 1.800000);
TextDrawColor(Textdraw0, -1446714113);
TextDrawSetOutline(Textdraw0, 1);
TextDrawSetProportional(Textdraw0, 1);
new Text:Textdraw0;
new GameMinutes =4;//Change them according to your needs
new GameSeconds =59;
new GameTimer;
// In OnGameModeInit
Textdraw0 = TextDrawCreate(611.000000, 120.000000, "TIME 05:00");
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
//Anywhere add
forward GameTime();
public GameTime()
{
if(GameSeconds || GameMinutes)
{
GameSeconds--;
if(GameSeconds <= -1)
{
GameMinutes--;
GameSeconds=59;
}
new TimeString[256];
format(TimeString,sizeof(TimeString),"~b~%02d~y~:~r~%02d",GameMinutes,GameSeconds);
TextDrawSetString(Textdraw0,TimeString);
}
return 1;
}
new Text:Textdraw0;//This will be needed to edit the textdraw etc.
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);
new GameTimer;
GameTimer = SetTimer("GameTime",1000,1);//1 second
new time=100;//As textdraw was 100 in starting
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;
}
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;
}
pawn Код:
|