Question about textdraw
#1

I want to make like a login/disconnect log but I am not sure how to make the textdraws go up then dissapear, like only 4 rows will show

x has connected(when the fifth row appear, this will dissapear and the textdraw under it will take this place)
x has connected
x has dissconnected
x has dissconnected
x has connected
Reply
#2

let me elighten you with this little example i put together.
PHP код:
#include <a_samp>
enum txInfo
{
    
Float:x,
    
Float:y,
    
text[43],//\0 + 24 Name + longest message i.e. " has dissconnected"
    
queueID//will decide at which position "textdraw" will be in queue
}
new 
textdraw[][txInfo] =
//setting some test data
{
    {
250.0350.0"a"4},
    {
250.0375.0"b"3},
    {
250.0400.0"c"2},
    {
250.0425.0"d"1}
};
main()
{
    new 
i=0;
    print(
"-initial state-");
    for(; 
i<4i++)//show initial
        
printf("QID: %d txt: %s",textdraw[i][queueID],textdraw[i][text]);
    print(
"\n\n-Test run-");
    for(
i=0i<4i++)//testing it...
        
showConLog(), print("\n");
}
showConLog()
{
    for(new 
i=0i<4i++)
    {
        if(!(
textdraw[i][queueID]%4))//this one reached the top & is going to the bottom now (% -> modulo)
            
textdraw[i][queueID]=1;//could also add a new message here
        
else 
            
textdraw[i][queueID]++;
    }
    for(new 
i=3i>-1i--)
        
printf("QID: %d txt: %s",textdraw[textdraw[i][queueID]-1][queueID],textdraw[textdraw[i][queueID]-1][text]);

nice and simple, it'll move the "textdraws" bottom-top
and then again bottom-top
it'll print this
Код:
-initial state-
QID: 4 txt: a
QID: 3 txt: b
QID: 2 txt: c
QID: 1 txt: d


-Test run-
QID: 4 txt: b
QID: 3 txt: c
QID: 2 txt: d
QID: 1 txt: a


QID: 4 txt: c
QID: 3 txt: d
QID: 2 txt: a
QID: 1 txt: b


QID: 4 txt: d
QID: 3 txt: a
QID: 2 txt: b
QID: 1 txt: c


QID: 4 txt: a
QID: 3 txt: b
QID: 2 txt: c
QID: 1 txt: d
if you follow the "a" "textdraws",
you can see it moves from the top to the 1st sopt at the bottom
and is making its way back to the top from there.
once it reaches the top, it'll all start over again and again and again...

if youdid understand the logic here, you can easily do this.
all you would have to do is change the Y position of the textdraw
along with it's queue ID (which you've set when creating your 4 log textdraws)


obviously there are a lot of different approaches you can take with this,
but this is just what came to my mind first
Reply
#3

May be useful: http://forum.sa-mp.com/showpost.php?...postcount=4471
Although they need to be adapted to work with string values.
Reply
#4

Here is a simple example for you xD.

PHP код:
new textdraw_str][ 128 ];
// 5 = the rows on TD
// 128 = string dimension.
The stock:
stock TextdrawText[ ] )
{
    if( 
strlentextdraw_str] ) < )
        
formattextdraw_str], 256"%s"Text );
    else
    {
        
formattextdraw_str], 256"%s"textdraw_str] );
        
formattextdraw_str], 256"%s"textdraw_str] );
        
formattextdraw_str], 256"%s"textdraw_str] );
        
formattextdraw_str], 256"%s"Text );
    }
    new 
string1000 ];
    
formatstring1000"~w~%s~n~%s~n~%s~n~%s"textdraw_str], textdraw_str], textdraw_str],  textdraw_str] );
    
TextDrawSetStringHERE YOU PUT YOUR TD NAMEstring );
    
// THAT'S ALL YOU NEED.
    // TO USE ON OTHERS MESSAGES JUST USE: Textdraw( YOUR STRING NAME );
    // Cu placere.
    
    
return 1;

Reply
#5

Thank you guys, really helped me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)