Player-textdraws -
JohnN - 22.04.2012
Hello,
I was a bit confused with this and wanted to share this with you guys.
If you go to this wikipedia page:
https://sampwiki.blast.hk/wiki/CreatePlayerTextDraw
- you will see that there is an example where player-textdraw's cells are defined with MAX_PLAYERS define.
1. example from the page (copied):
pawn Код:
new
PlayerText:welcomeText[MAX_PLAYERS];
welcomeText[playerid] = CreatePlayerTextDraw(playerid, 240.0, 580.0, "Welcome to my SA-MP server");
PlayerTextDrawShow(playerid, welcomeText[playerid]);
Now, if you go to this wikipedia page:
https://sampwiki.blast.hk/wiki/PlayerTextDrawAlignment
- you will see that there is an example where player-textdraw's cells are
NOT defined with MAX_PLAYERS define.
2. example from the page (copied):
pawn Код:
new
PlayerText:MyTextdraw;
MyTextdraw = PlayerTextDrawCreate(320.0, 425.0, "This is an example textdraw");
PlayerTextDrawAlignment(playerid, MyTextdraw, 2);
In the first example, there are MAX_PLAYERS (let's say we have it defined as 500) player-textdraws created, while in the second example, there is only one player-textdraw created.
I believe that there was more than one person who wrote those examples on the SA:MP wikipedia page and because of that, we have a bit of confusion.
However, I've tried the second example, creating only one player-textdraw and I've tested it with 2 players on the server and it works fine for every player (the player-textdraw isn't changing for everyone the same like global one, every player sees his string in his player-textdraw), but I still want to share this with you guys and in good hope that wikipedia will be updated.
I apologize if a topic like this one already exists - I didn't find a topic like this one in this section.
Kind regards,
JohnN
Re: Player-textdraws -
SuperViper - 22.04.2012
[MAX_PLAYERS] is not required you just need a regular variable with the tag.
Re: Player-textdraws -
JohnN - 22.04.2012
Yes, I know. As I said, I've tried the second example which I added in my first post and I've tested it and it works. What I actually want, is the others to see this, because some player-textdraw-function pages on wikipedia are giving the first example, and the others are giving the second one.
I believe it's a mistake and it should be fixed and I want others to see this so they won't be confused like I was.
Regards,
JohnN
Re: Player-textdraws -
Jonny5 - 22.04.2012
as far as I can tell if your TextDraw is gonna be unique to each player then youll need MAX_PLAYERS
otherwise you should just use a global....
Re: Player-textdraws -
JohnN - 22.04.2012
And what is the meaning of the new player-textdraw functions in 0.3e version? Like I've said, using the second example in my first post works just fine.
Re: Player-textdraws -
Jonny5 - 22.04.2012
yes because that TD is the SAME for every player,
if the text was unique to the player it wouldn't work.
it would show but wouldnt be unique, every player would see the same text.
i think the idea was to expand how many TDS in total a server can use
your second example could be done with 1 global TD as its text is the same for every player.
if you had a TD that maybe showed some stats /players name ect..
then youll need to use an array with MAX_PLAYERS and PlayerText or the likes.
an example would be a speedometer,
the speed will be different for every player,
Re: Player-textdraws -
JohnN - 22.04.2012
This example works just fine and unique for me and other player who tested with me:
pawn Код:
new
PlayerText:MyTextdraw;
MyTextdraw = PlayerTextDrawCreate(320.0, 425.0, "This is an example textdraw");
PlayerTextDrawShow(playerid, MyTextdraw);
Re: Player-textdraws -
Jonny5 - 22.04.2012
that is NOT unique
every player will see the same text.
"This is an example textdraw"
make one that shows
your name to
you!
youll see every player see's the same name, and maybe 1 person sees their name.
the thing here is it is still only 1 TD with your code
so it cannot contain 2 different text strings..
the reason for adding them i think was to give more td's per player
so a server can possible have MAX_GLOBAL + MAX_PLAYER textdraws for each player.
before we would eat up all our textdraws trying to make things unique per player,
now we have 256(i think) per player that can be unique(speedos, stats ect....)
and 1024(i think) to be global and the same for every player(Server name, time, tutorial, menus..,commands ect..)
Re: Player-textdraws -
JohnN - 22.04.2012
No, like I've said, it works fine and unique. I didn't use that code, I've said it's only an
example (example which is using the
PlayerText: tag without MAX_PLAYERS array). I'm using my own script with selectable textdraws where you can change their values/string by clicking, and every player sees his own values in the player-textdraws.
I know what do you mean, but you're wrong. Write a code and test it, then post again in this topic.
Regards,
JohnN
Re: Player-textdraws -
Jonny5 - 22.04.2012
I will test this,
but i dont see how to make the Text different for each player, without an array!
edit:
are you using
pawn Код:
PlayerTextDrawSetString(playerid, SomePlayerTD, PlayersName(playerid));
i think i see how this might work as it has a player id!
and that will set it only for 1 player?
this is awesome!!!
I will be testing this,
and this makes the code allot more efficient!
Im surprised no one else has realized this yet or posted correcting people!
good job!