i need help in TextDraw
#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


Messages In This Thread
i need help in TextDraw - by kings24 - 19.06.2012, 07:41
Re: i need help in TextDraw - by Skaizo - 19.06.2012, 07:56
Re: i need help in TextDraw - by Audi_Quattrix - 19.06.2012, 08:43
Re: i need help in TextDraw - by [MM]RoXoR[FS] - 19.06.2012, 11:53
Re : i need help in TextDraw - by kings24 - 20.06.2012, 08:58
Re: i need help in TextDraw - by [MM]RoXoR[FS] - 20.06.2012, 10:14
Re : i need help in TextDraw - by kings24 - 20.06.2012, 19:56
Re: i need help in TextDraw - by [MM]RoXoR[FS] - 21.06.2012, 04:15
Re : i need help in TextDraw - by kings24 - 21.06.2012, 14:04
Re: i need help in TextDraw - by WillyP - 21.06.2012, 15:34

Forum Jump:


Users browsing this thread: 1 Guest(s)