Looping through all player textdraws
#1

As title says, I want to loop through all player textdraws (to set alpha - fading effect), but I have little problem, I have all PlayerTextdraws defined like this:

pawn Код:
static
    PlayerText:Textdraw0[MAX_PLAYERS],
    PlayerText:Textdraw1[MAX_PLAYERS],
    PlayerText:Textdraw2[MAX_PLAYERS,
    // And so on till Textdraw26 ...

//And then I'm initializing these in on player login
Textdraw0[playerid] = CreatePlayerTextdraw( ... );
// ...'

//And OnPlayerDisconnect I'm destroying these player textdraws
DestroyPlayerTextdraw(playerid, Textdraw0[playerid]);
// ...
So I probably need to convert these to array, but I'm not sure how to do it so I'm asking here, so I won't mess up something. Thanks.
Reply
#2

You can use an iter whenever you create a textdraw and then foreach it

Код:
new Iterator:totalPTextdraws<MAX_PLAYER_TEXT_DRAWS>
Код:
Iter_Add(totalPTextdraws, yourtextdrawvar);
I am not sure if you can use it like this but you can try
Reply
#3

Use the find & replace function of your editor, replace 'Textdraw0[playerid]' ==> 'Textdraw[playerid][0]'

Код:
 new PlayerText:Textdraw[MAX_PLAYERS][MAX_TEXTDRAWS];
Код:
 stock DestroyPlayerTextdraws(playerid)
{
    for(new i=0; i<MAX_TEXTDRAWS; i++)
    {
        DestroyPlayerTextdraw(playerid, Textdraw[playerid][i]);
    }
}

stock CreatePlayerTextdraws(playerid)
{
    for(new i=0; i<MAX_TEXTDRAWS; i++)
    {
        Textdraw[playerid][i] = CreatePlayerTextdraw(...);
    }
}
Reply
#4

Thanks Tamy, that's what I needed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)