[QUESTION] PlayerTextDraw
#1

About the new PlayerTextDraws.
If I want to create a new global variable for the PlayerTextDraw (for use it in other callbacks, like for speedo, in statechange, and update), whats the correct usage?
Код:
new PlayerText:asd[MAX_PLAYERS];
or
Код:
new PlayerText:asd;
or unable to do this?
Reply
#2

Код:
new PlayerText:asd;
I just tried it. This is how it's used.
Reply
#3

I am now confused about the player text draws.
Will they destroy automaticly when a player quits and do I have to declarate a player text draws as an array or does it fit as he/she mentioned above?
Reply
#4

Quote:
Originally Posted by BigETI
Посмотреть сообщение
I am now confused about the player text draws.
Will they destroy automaticly when a player quits and do I have to declarate a player text draws as an array or does it fit as he/she mentioned above?
They are supposed to destroy when a player disconnects but it's better to destroy it script wise and the declaration doesn't needs an array as it already has a playerid parameter(argument).
Reply
#5

Код:
new PlayerText:asd[MAX_PLAYERS];
This one. Because you are putting the textdraw ids into an array.
Reply
#6

Quote:
Originally Posted by BlackBank3
Посмотреть сообщение
Код:
new PlayerText:asd[MAX_PLAYERS];
This one. Because you are putting the textdraw ids into an array.
No need. It will create complication. Read my post above.
Reply
#7

But how are you suppose to know what to open if it's not saved in a variable?
Reply
#8

Player textdraws are exactly the same as normal textdraws appart from the playerid parameter.

pawn Код:
new PlayerText: eText[MAX_PLAYERS];

// OnPlayerConnect
eText[playerid] = CreatePlayerTextDraw(playerid, "Example Text", 5.0, 200.0);

// OnPlayerDisconnect
PlayerTextDrawDestroy(playerid, eText[playerid]);

// OnPlayerSpawn
PlayerTextDrawShow(playerid, eText[playerid]);

// OnPlayerDeath
PlayerTextDrawHide(playerid, eText[playerid]);
and because there per-player, PlayerTextDrawSetString will only change the text for a single player.

A good example of using player textdraws over global textdraws would be a speedo or some kind of stats display.
Reply
#9

There is something that looks strange:
pawn Код:
TextDrawCreate()
CreatePlayerTextDraw()
Wouldn't it be better if TextDrawCreate was CreateTextDraw or if CreatePlayerTextDraw was PlayerTextDrawCreate?
Reply
#10

@up you can easy rename function name
pawn Код:
#define CreateTextDraw(%0) TextDrawCreate(%0)
Reply
#11

I'm still a bit confused about this. I'm guessing is HAS to be an array? How can you store IDs for all players in one variable..?
Reply
#12

new ptextdraws[MAX_PLAYERS];

OnPlayerConnect

ptextdraw[playerid]=CreatePlayerTextdraw(blabla);
Reply
#13

You still need to use an array

pawn Код:
new PlayerText:asd[MAX_PLAYERS];
because the IDs might be different for players, for example if one player has 2 textdraws created and other has 3
Reply
#14

You don't need Arrays ...
Reply
#15

Quote:
Originally Posted by Psymetrix
Посмотреть сообщение
Player textdraws are exactly the same as normal textdraws appart from the playerid parameter. This means the variable does NOT have to be an array (MAX_PLAYERS).

pawn Код:
new PlayerText: eText;

// OnPlayerConnect
eText = CreatePlayerTextDraw(playerid, "Example Text", 5.0, 200.0);

// OnPlayerDisconnect
PlayerTextDrawDestroy(playerid, eText);

// OnPlayerSpawn
PlayerTextDrawShow(playerid, eText);

// OnPlayerDeath
PlayerTextDrawHide(playerid, eText);
and because there per-player, PlayerTextDrawSetString will only change the text for a single player.

A good example of using player textdraws over global textdraws would be a speedo or some kind of stats display.
If you want that textdraw to exist for every player, you need an array:
pawn Код:
new PlayerText: eText[MAX_PLAYERS];

// OnPlayerConnect
eText[playerid] = CreatePlayerTextDraw(playerid, "Example Text", 5.0, 200.0);

// OnPlayerDisconnect
PlayerTextDrawDestroy(playerid, eText[playerid]);

// OnPlayerSpawn
PlayerTextDrawShow(playerid, eText[playerid]);

// OnPlayerDeath
PlayerTextDrawHide(playerid, eText[playerid]);
CreatePlayerTextDraw returns the ID to the eText array, at the playerid's index.
CreatePlayerTextDraw returns a unique ID every time. Since this differs per player, you need an array.
Reply
#16

If player 0 has 1 TD created (id 0) and player 1 has 2 (id 0+1) then the next textdraw created for them both will be 1 and 2, so of course you need an array.

(Not sure if TDs start at ID 0, assume so.)
Reply
#17

I also think there has to be an array.
Example:

pawn Код:
new PlayerText: eText[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    eText[playerid] = CreatePlayerTextDraw(playerid, "Welcome to my Server", 5.0, 200.0);
}

public OnPlayerSpawn(playerid)
{
    PlayerTextDrawDestroy(playerid, eText[playerid]);
    return 1;
}
It's like with playerobjects and globalobjects or not?...
Reply
#18

Quote:
Originally Posted by Nanory
Посмотреть сообщение
It's like with playerobjects and globalobjects or not?...
yes
(4char)
Reply
#19

NeTuddMeg,
pawn Код:
new PlayerText:asd[MAX_PLAYERS];
Reply
#20

I'm not sure how I managed to get it so wrong haha. I'll change my post to avoid confusion.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)