Creating new line on textdraw
#1

I got some commands that will show A Message As A Textdraw, That works good.

Ok, so my question is , for example i type /New Hi This Is The new Message < That will create the message on the desired position i created the textdraws, right... Ok that works goood...


NOW, how would i make it so the line "Hi This Is...." appears below a new one?

Ok, so confusing xD........

KK, so I type
/New Hi This Is new message < That line will be the first one

THEN

/new Hi This would be ontop of Hi This Is New Message < That NEW line will be ontop of the old one

So if yall do understand, there will be a total of 5 lines <

.newest line < 1 msg
.old line < etc....
.old line
.old line
.old line < after it gets here, this line will be removed to make space for the newest line, and so and sooo



ROFL, hope yall undestand.
Reply
#2

~n~? <.<
Reply
#3

That will work, but if you read my post good, i don't want the last line to be erased
Reply
#4

I think i got you

You would have to have a variable, that counts the currently shown lines, each time a line is added, it increases by one (linecount)

then pack the textdraw strings into an 2d array, size should be the max number of lines.

new tdraw[5][128 (Max string length]

If a new line is added, you move the old ones on step down in the array and delete the last one like this:

tdraw[4] = tdraw[3]; //The last string is gonna fall out
tdraw[3] = tdraw[2];
...
linecount -= 1;

format all those in one string, divide the strings with ~n~

pawn Код:
new string[512];
for(new i = 0; i < linecount; i ++) {
    format(string,512, "%s~n~%s, string, tdraw[i]);
}
then set this as string for one textdraw, it shows all lines in an order.
Reply
#5

meeh, i don't really like to deal with arrays that much

But here is what i got

Код:
	    new Texts[5];
	    new linecount;
	    new String[128];
		if(sscanf(params,"s",Texts)) return SendClientMessage(playerid,0xBFC0C2FF,"USAGE: /Setnews < News >");
		for(new i = 0; i < linecount; i ++)
		{
		    Texts[5] = Texts[4];
		    Texts[4] = Texts[3];
		    Texts[3] = Texts[2];
		    Texts[2] = Texts[1];
		    Texts[1] = Texts[5];
		    linecount = 1;
		    format(String,sizeof(String),"%s~n~%s",String,Texts[i]);
			TextDrawSetString(NewsText,String);
		}
I get two out of bound index erros

Lines 1st error - Texts[5] = Texts[4];
2nd error - Texts[1] = Texts[5];
Reply
#6

Bumpy Bump Bump
Reply
#7

I think you should use

Код:
format(Texts[5], sizeof(Texts[5]), "%s", Texts[4]);
format(Texts[4], sizeof(Texts[5]), "%s", Texts[3]);
format(Texts[3], sizeof(Texts[5]), "%s", Texts[2]);
format(Texts[2], sizeof(Texts[5]), "%s", Texts[1]);
format(Texts[1], sizeof(Texts[5]), "%s", Texts[5]);
instead of
Код:
   Texts[5] = Texts[4];
   Texts[4] = Texts[3];
   Texts[3] = Texts[2];
   Texts[2] = Texts[1];
   Texts[1] = Texts[5];
.
(I don't know if it works or not, I didn't try it.)
Reply
#8

You mean? ~n~ or \n?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)