Looping through all player textdraws - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Looping through all player textdraws (
/showthread.php?tid=597300)
Looping through all player textdraws -
Riwerry - 29.12.2015
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.
Re: Looping through all player textdraws -
SecretBoss - 29.12.2015
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
Re: Looping through all player textdraws -
Tamy - 29.12.2015
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(...);
}
}
Re: Looping through all player textdraws -
Riwerry - 29.12.2015
Thanks Tamy, that's what I needed.