i need help in TextDraw
#1

How I work time left Countdown TextDraw?
Reply
#2

you mean this?
http://www.movieserv.net/files/clock.png
pawn Код:
// 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);
Reply
#3

I think he means Textdraw "Time Left: 2:00'' and sec later "Time Left: 1:59''
Reply
#4

pawn Код:
new Text:Textdraw0;
new GameMinutes =4;//Change them according to your needs
new GameSeconds =59;
new GameTimer;
pawn Код:
// 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

pawn Код:
//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;
}
Reply
#5

Thanks for help, but not so

I want to how it works Countdown TextDraw
Example:
100
99
98
97
...
Reply
#6

ok I will tell you working with the above example

First, we need to create a textdraw.

pawn Код:
new Text:Textdraw0;//This will be needed to edit the textdraw etc.
Now we will create a textdraw at position 611(X) ,120(Y).
pawn Код:
Textdraw0 = TextDrawCreate(611.000000, 120.000000, "100");//100 is the text
To decorate it we add
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, now we want to update our textdraw after 1 second.
So we make a timer

pawn Код:
new GameTimer;
And Now Make the timer call a function (which decreases textdraw) after 1 sec.

pawn Код:
GameTimer = SetTimer("GameTime",1000,1);//1 second
Also we need some variable to store current value of textdraw
pawn Код:
new time=100;//As textdraw was 100 in starting
Now let's make the function which decreases the value of time.

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;
}
Full Code :
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;
}
Reply
#7

Thanks for help, but Sorry did not work with me is it possible to put you

In this game mode: http://pastebin.com/nPMr8B9z
Reply
#8

http://www.pasteall.org/33087
Reply
#9

Thank you worked, but there is a problem

Decrease in the number remains so
-1
-2
-3
-4
....

Must When you change the map Re-count
Reply
#10

Quote:
Originally Posted by [MM]RoXoR[FS]
Посмотреть сообщение
pawn Код:
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;
}
Cute, taking that from one of my servers made ages ago, changed a couple of lines, could've atleast gave some form of credit..
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)