Textdraw questions
#1

I'm making a phone system, which uses upto 20 Player Textdraws. Each time a user clicks on something from the phone the script destroys the previously 20 made player texdraws and creates them again for the next screen. I'm using Player Textdraaws on all 20 currently.
Textdraw variable for my phone:
pawn Код:
new phone[MAX_PLAYERS][20]
There are quite a few things that are unique to players regarding the phone textdraw. They can change the color as they want, and every player has different contact names in his phone.
So my first question would be: In this case, should I be using Per-player textdraw or a Global textdraw set to Max_players?
My second question would be: Is Max_players neccessary on the 20 of my phone textdraws? I tried without it, but whenever I close my phone on a secondly logged account (which uses textdrawhide) it somehow doesn't closes a few textdraws for the second player.
Last question: Is 265 the limit for textdraws showed on screen? or total textdraws on the script?
Thanks.
Reply
#2

One more question. How many variables out 265 will this player textdraw use:
pawn Код:
new phone[MAX_PLAYERS][20]
Reply
#3

256 is the limit of per-player textdraws per-player so that will only use 20 out of every players 256.
Reply
#4

Alright thanks. What about my other questions?
Reply
#5

You should be using per-player textdraws and as far as I know the MAX_PLAYERS would still be necessary. You could test it out with and without it and see. I've always done it with MAX_PLAYERS
Reply
#6

Last question: Is 265 the limit for textdraws showed on screen? or total textdraws on the script?
Thanks.
Reply
#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
#8

Thank you for your tips and being so detailed. I find less posts like this these days.
The question would be, if I had around 300 Player Textdraws in my script and only 20 were to be showed at a time to a player. Will that work out fine? Or I cannot pass the limit of 256 Player Textdraws in my script?
Reply
#9

Quote:
Originally Posted by ||123||
Посмотреть сообщение
if I had around 300 Player Textdraws in my script and only 20 were to be showed at a time to a player. Will that work out fine?
yes.
Reply
#10

Thank you everyone for your help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)