Confusion: TextDraw tags and MAX_PLAYERS
#1

I've got a big confusion in my head regarding a few things in Text Draws.
Firstly, what is the difference and usage of the two tags of Text Draws; PlayerText, and Text used on a variable assigned to the Text Draw.
Secondly, I've seen [MAX_PLAYERS] added on textdraw variables. I'm confused isn't this the same as PlayerText? AFAIK, PlayerText is used when people want certain text draws strings to appear different to each player, or on different timings (e.g using timers to turn off certain textdraws for each player at different timings). But then why is MAX_PLAYERS used for? I talked a little about this on IRC and I learned that MAX_PLAYERS doesn't create new textdraws for every player, but simply assigns each variable to every player, which is different from using playertext, which assigns NEW TEXTDRAWS to every player. What's the difference between them. Please be brief and elaborate it to me. A single or two lined answers won't help me understand much.
Reply
#2

There is a significant difference between player text draws and global text draws. Global text draws are only used, if they don't have to be unique for each player. Player text draws will be destroyed automaticly after someone disconnects, and those text draws have to be unique for each player. About the tags, since PAWN is a typeless language, the tags actually are only important during pre-compilation, so if you attempt to use player text draw variables inside a global text draw function, it should give you an error, instead of ignoring it. About MAX_PLAYERS, it just tells your script to create an array, so each player can have their own text draw ID. Let's say the script has created a text draw for player 1 with ID 1, for player 2 it can ALSO create a text draw with ID 1, which can be for each completly different text draws.
Reply
#3

So that means I can use MAX_PLAYERS on a global textdraw and make it unique to each player myself? Or I'll still have to use Playertext on that one. Will that be exactly the same as using Playertext?
Reply
#4

Playertext draws were created so you don't have to do that look at this way there are 256 player textdraws if you had 500 players that is a total of 128,000 textdraws which shatters the global limit of 2048.
Reply
#5

Quote:
Originally Posted by ||123||
Посмотреть сообщение
So that means I can use MAX_PLAYERS on a global textdraw and make it unique to each player myself? Or I'll still have to use Playertext on that one. Will that be exactly the same as using Playertext?
You can use MAX_PLAYERS with the global textdraws to make it unique for everyone. If there are per-players textdraws already so that global method kindof sucks anyway.
Reply
#6

Why would it shatter the global textdraw limit since, as stated above MAX_PLAYERS only creates a new variable for each player to have their on textdraw ID, using the same textdraw.
Reply
#7

Keeping in mind that Global textdraws are used for textdraws that don't change for every player, and pre-player textdraws for the textdraws that are a subject to change for every player. How will a good use of MAX_PLAYERS apply in both of them. What changes will MAX_PLAYERS make in them.
Reply
#8

MAX_PLAYERS is just a definition anyway. By doing
pawn Код:
new PlayerText:my_p_td[MAX_PLAYERS];
will tell your compiler to create "MAX_PLAYERS" amount of "my_p_td"s variables, hence also called an array.

If you don't use an array, but instead a single variable, it will look like this:
pawn Код:
// "playerid" equals 0
my_p_td = CreatePlayerTextDraw(playerid, 0.0, 0.0, "_");

// "playerid" equals 1 (overwrites last TD ID of player ID 0, bad!)
my_p_td = CreatePlayerTextDraw(playerid, 0.0, 0.0, "_");
https://sampwiki.blast.hk/wiki/CreatePlayerTextDraw
"Creates a textdraw for a single player. This can be used as a way around the global text-draw limit."
Reply
#9

Since PlayerTextdraws were introduced quite recently (well, relatively ...) many people have not changed their old style, that's why you'll see a lot of MAX_PLAYER arrays for the normal textdraws. And to be honest: if it works, why would you?

To summarize it: use a normal, global, textdraw for things like web addresses or backgrounds. Static things that are the same for everyones and basically never change. Use PlayerText for stuff that is only shown to a specific player. Kill/Death ratio, score, cash, ... Stuff that updates quite frequently and is unique for each player.
Reply
#10

I forgot to mention, that this thread should be at the scripting discussions area instead.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)