Textdraw questions
#7

You can have 2048 normal textdraws and 256 per playertextdraws. I have never hit a limit displaying them so that will definitely be a non-issue. There are some points people did not mention for instance textdraws that never change and would be the same for all players should never be playertextdraws. Colors do not dynamically update for shown textdraws they must be hidden first then any colors can be set then shown to the player that means you wouldn't need playertextdraws for personalized color schemes. There is reasons why you would want to do this.

- It is very easy to fill the playertextdraw limit if you only use them.
- Normal textdraws are simplified you don't need to worry about per-player dynamics
- You won't need to create them every time a player joins the server

Some other considerations
- If you have clickable playertextdraws your still going to need to use OnPlayerClickTextDraw() to catch INVALID_TEXT_DRAW calls (when the mouse pointer is lost)
- Order of textdraws is critical it must be thought of as in layers with successive textdraws overlapping the previous this means when creating them background textdraws need to be created first information textdraws need to be created last. To expand even further you need to consider the order in which your various textdraw systems will be created this will determine how they overlap one another.
- I always take a modular approach that means every system is in it's own include this is very critical for any server design but which so many scripters fail to do how this concept relates to textdraws assists with preventing overlapping. For instance say you have a /serverstats command and /playerstats command you don't want them to ever overlap so you create a variable and #define in your gamemode like this

pawn Код:
#define TEXTDRAW_NONE 0
#define TEXTDRAW_SERVERSTATS 1
#define TEXTDRAW_PLAYERSTATS 2

new CurrTextDraw[MAX_PLAYERS;
new bool:TextDrawOpen[MAX_PLAYERS];

#define SetCurrTextDraw(%0,%1) CurrTextDraw[%0] = %1
#define GetCurrTextDraw(%0) CurrTextDraw[%0]
When a player types /serverstats we do this

pawn Код:
TextDrawOpen[playerid] = true;
SetCurrTextDraw(playerid, TEXTDRAW_SERVERSTATS);
Any other textdraw commands can be prevented from being opened by placing this line anywhere you need it.

pawn Код:
// Prevent any other textdraw actions
if(TextDrawOpen[playerid]) return 1;
We can control what textdraws are called in a couple of ways either make our own functions in each include or use callback hooking. For me this is one of the few things I don't use callback hooking for so to simplify things I will only show the method I use.

pawn Код:
public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
    if(GetCurrTextDraw(playerid) == TEXTDRAW_SERVERSTATS) OnPlayerClickTextDrawServerStats(playerid,clickedid);
    else if(GetCurrTextDraw(playerid) == TEXTDRAW_PLAYERSTATS) OnPlayerClickTextDrawPlayerStats(playerid,clickedid);
    return 1;
}
Let me know if you have any more questions those are my tips and tricks
Reply


Messages In This Thread
Textdraw questions - by ||123|| - 01.11.2013, 20:33
Re: Textdraw questions - by ||123|| - 01.11.2013, 21:11
Re: Textdraw questions - by Chenko - 01.11.2013, 22:01
Re: Textdraw questions - by ||123|| - 01.11.2013, 22:06
Re: Textdraw questions - by Chenko - 01.11.2013, 23:25
Re: Textdraw questions - by ||123|| - 04.11.2013, 13:19
Re: Textdraw questions - by Pottus - 04.11.2013, 14:09
Re: Textdraw questions - by ||123|| - 04.11.2013, 16:02
Re: Textdraw questions - by Ada32 - 04.11.2013, 16:04
Re: Textdraw questions - by ||123|| - 04.11.2013, 16:21

Forum Jump:


Users browsing this thread: 2 Guest(s)