2-dimensional textdraw arrays
#1

So i want this:

new PlayerText:txtStats1[MAX_PLAYERS];
new PlayerText:txtStats2[MAX_PLAYERS];
new PlayerText:txtStats3[MAX_PLAYERS];
new PlayerText:txtStats4[MAX_PLAYERS];
new PlayerText:txtStats5[MAX_PLAYERS];

To be this:

new PlayerText:txtStats[MAX_PLAYERS][5];

But it doesn't work (it messes up id's i guess).

What am i doing wrong? Thanks.
Reply
#2

It works for me, an example:
pawn Код:
#define MAX_PLAYAS 10
#define MAX_TEXTDRWS 10

new PlayerText: myTEXTS[ MAX_PLAYERS ][ MAX_TEXTDRWS ];

public OnPlayerConnect( playerid )
{
     myTEXTS[ playerid ][ 0 ] = Create_FirstTextDraw;
     myTEXTS[ playerid ][ 1 ] = Create_SecTextDraw;
}

public ShowText( playerid )
{
     for( ... )
        PlayerTextDrawShow( playerid, myTEXTS[ playerid ][ 0 ] );
}
Reply
#3

Well can you explain further what happens in your script when you use multidimensional arrayed variables in creating textdraws?

its like you must be using

pawn Код:
txtStats[playerid][0] = CreatePlayerTextDraw(playerid,X,Y,"text");
You should start array values from zero
Reply
#4

pawn Код:
// global
new PlayerText:txtStats[5][MAX_PLAYERS];


// Where you want to create them:
txtStats[0][playerid] = CreatePlayerTextDraw(playerid, 240.0, 580.0, "Welcome");
txtStats[1][playerid] = CreatePlayerTextDraw(playerid, 240.0, 580.0, "to");
txtStats[2][playerid] = CreatePlayerTextDraw(playerid, 240.0, 580.0, "my");
txtStats[3][playerid] = CreatePlayerTextDraw(playerid, 240.0, 580.0, "SA-MP");
txtStats[4][playerid] = CreatePlayerTextDraw(playerid, 240.0, 580.0, "server");
Reply
#5

Now you confused me, should i use:

txtStats[0][playerid] or txtStats[playerid][0]

What comes first the textdraw id or playerid?
Reply
#6

Quote:
Originally Posted by Whizion
Посмотреть сообщение
Now you confused me, should i use:

txtStats[0][playerid] or txtStats[playerid][0]

What comes first the textdraw id or playerid?

I rather use, but to be honest both of them work the same, just different dilemma of scripting


pawn Код:
new Textdraw[MAX_PLAYERS][Number Of Textdraw+1];
//or
new Textdraw[Number Of Textdraw+1][MAX_PLAYERS];
EDIT: Check the pattern made by Rajat_Pawar that explains everything I guess
Reply
#7

Quote:
Originally Posted by Whizion
Посмотреть сообщение
Now you confused me, should i use:

txtStats[0][playerid] or txtStats[playerid][0]

What comes first the textdraw id or playerid?
It's the same, you can use anything. It's like:

pawn Код:
Textdraw ---> Player 1 ---> textdraw 1
                                 ---> textdraw 2
                                 ---> textdraw 3
or
pawn Код:
Textdraw---> Textdraw1 ---> Player 1
                                 ---> Player 2
                                 ---> Player 3
In total, the slots are going to be the same.

(MAX_PLAYERS * MAX_TEXTDRAWS = MAX_TEXTDRAWS * MAX_PLAYERS)
Your choice, I prefer using a player array and then sub dividing them into textdraws..

EDIT: A bit late
Reply
#8

Thanks everyone.
Reply
#9

Quote:
Originally Posted by Whizion
Посмотреть сообщение
Now you confused me, should i use:

txtStats[0][playerid] or txtStats[playerid][0]

What comes first the textdraw id or playerid?
I've read that using less size on the first one than the second is better. I just tested it and the "Total requirements:" was greater with the greater size on the first index (same code, only swapping the values).

PS: Your welcome.
Reply
#10

https://sampforum.blast.hk/showthread.php?tid=30938&page=208
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)