How to loop through the textdraws?
#1

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
Reply
#2

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!
Reply
#3

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.
Reply
#4

Well, my excuses then
Reply
#5

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?
Reply
#6

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
Reply
#7

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
Reply
#8

Thank You All!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)