10.07.2012, 18:55
Here's what I know:
This will bypass textdraw '0'
Unfortunately, it also creates textdraw '1', meaning you lose access to 2 textdraws. Also it will not support being ran more than once (so only on OnGameModeInit, not OnFilterScriptInit).
The only alternative you can use so that you can keep textdraw '0' and '1', is to keep an array of associated boolean variables to determine if the textdraw has been created AND to destroy ALL textdraws under OnGameModeExit.
EDIT:
On further examination of your code, your TextDrawDestroyEx doesn't take into consideration that the end-user is trying to destroy a textdraw ID that hasn't been created yet (other than '0')
If I were to create TextDraw '5', for example, then try to destroy it twice, it will destroy textdraw '5' then '0'.
The reason I go with just creating TextDraws '0' and '1' at OnGameModeInit, is so I don't use up unnecessary RAM. However; on second thought, I think that 2 textdraws probably uses up a considerable amount of RAM as well (considerable as compared to an array)
- The first textdraw created is '0'
- If you attempt to use TextDrawDestroy on a non-existing textdraw, it will destroy textdraw '0'
- A GMX will destroy all textdraws except for '0'
pawn Code:
public OnGameModeInit()
{
while(_:TextDrawCreate(0,0," ")==0)continue;
return 1;
}
Unfortunately, it also creates textdraw '1', meaning you lose access to 2 textdraws. Also it will not support being ran more than once (so only on OnGameModeInit, not OnFilterScriptInit).
The only alternative you can use so that you can keep textdraw '0' and '1', is to keep an array of associated boolean variables to determine if the textdraw has been created AND to destroy ALL textdraws under OnGameModeExit.
pawn Code:
new bool:TextDrawIsActive[MAX_TEXT_DRAWS];
stock Text:TextDrawCreate2(Float:x, Float:y, text[])
{
new Text:tdID=TextDrawCreate(x,y,text);
TextDrawIsActive[_:tdID]=true;
return Text:tdID;
}
stock TextDrawDestroy2(Text:textdraw)
{
if(TextDrawIsActive[_:textdraw])
{
TextDrawIsActive[_:textdraw]=false;
TextDrawDestroy(textdraw);
return true;
}
return false;
}
public OnGameModeExit()
{
for(new td; td<MAX_TEXT_DRAWS; td++)TextDrawDestroy2(Text:td);
}
EDIT:
On further examination of your code, your TextDrawDestroyEx doesn't take into consideration that the end-user is trying to destroy a textdraw ID that hasn't been created yet (other than '0')
If I were to create TextDraw '5', for example, then try to destroy it twice, it will destroy textdraw '5' then '0'.
The reason I go with just creating TextDraws '0' and '1' at OnGameModeInit, is so I don't use up unnecessary RAM. However; on second thought, I think that 2 textdraws probably uses up a considerable amount of RAM as well (considerable as compared to an array)