SA-MP Forums Archive
How to loop through the 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to loop through the textdraws? (/showthread.php?tid=162510)



How to loop through the textdraws? - Nonameman - 23.07.2010

Hey Guys!

I have many textdraws, and I want to make them all hideable with pressing LMB.
To do it, I have to loop through all the textdraws, and close all of them, because I think I cannot hide just the active one.

I've already made these lines:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(RELEASED(KEY_FIRE))
{
for(i=0; i<MAX_??; i++)
{
TextDrawHideForPlayer(playerid, i);
}}
return 1;
}
What should I put in place of '??' ?

Thanks
Nonameman


Re: How to loop through the textdraws? - FUNExtreme - 23.07.2010

You could save all of the textdraws inside an array and then use
pawn Код:
sizeof(AllTextdraws)
But you might not be able to do this with your experience, just a guess, no offence!


Re: How to loop through the textdraws? - Nonameman - 23.07.2010

Quote:
Originally Posted by FUNExtreme
Посмотреть сообщение
You could save all of the textdraws inside an array and then use
pawn Код:
sizeof(AllTextdraws)
But you might not be able to do this with your experience, just a guess, no offence!
Good idea, Thanks, I know how to do it.


Re: How to loop through the textdraws? - FUNExtreme - 23.07.2010

Well, my excuses then


Re: How to loop through the textdraws? - Nonameman - 23.07.2010

Quote:
Originally Posted by FUNExtreme
Посмотреть сообщение
Well, my excuses then
No, I cannot. xD Tried, but got 3 errors.

Can you show me how to do it?


Re: How to loop through the textdraws? - Fj0rtizFredde - 23.07.2010

pawn Код:
new textdraw[5]; // How many textdraws you have :) (On top of your script)
//OnGameModeInit:
textdraw[0] = CreateTextDraw....
//and so on

//Where you need the loop:
for(i=0; i<sizeof(textdraw); i++)
{
TextDrawHideForPlayer(playerid, i);
}
Something like that :P


Re: How to loop through the textdraws? - FUNExtreme - 23.07.2010

I have a better idea, that you might be able to do yourself.

Create a custom function that creates the textdraw and sets +1 to a variable

pawn Код:
TextDrawCreateEx(Float:x, Float:y, text[])
{
       TextDrawCreate(x, y, text);
       Textdraws =+ 1;
}
Note: if you use this method, you will need a custom destroy function aswell wich does -1


Re: How to loop through the textdraws? - Nonameman - 23.07.2010

Thank You All!