SA-MP Forums Archive
[QUESTION] PlayerTextDraw - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [QUESTION] PlayerTextDraw (/showthread.php?tid=327783)

Pages: 1 2


[QUESTION] PlayerTextDraw - NeTuddMeg - 22.03.2012

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?


Re: [QUESTION] PlayerTextDraw - TheBetaFox - 22.03.2012

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


AW: [QUESTION] PlayerTextDraw - BigETI - 22.03.2012

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?


Re: AW: [QUESTION] PlayerTextDraw - T0pAz - 22.03.2012

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).


Re: [QUESTION] PlayerTextDraw - BlackBank - 22.03.2012

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


Re: [QUESTION] PlayerTextDraw - T0pAz - 22.03.2012

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.


Re: [QUESTION] PlayerTextDraw - Kyle - 22.03.2012

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


Re: [QUESTION] PlayerTextDraw - Psymetrix - 22.03.2012

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.


AW: [QUESTION] PlayerTextDraw - Meta - 22.03.2012

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


Re: [QUESTION] PlayerTextDraw - QuaTTrO - 22.03.2012

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



Re: [QUESTION] PlayerTextDraw - MP2 - 22.03.2012

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..?


Re: [QUESTION] PlayerTextDraw - BloodyEric - 22.03.2012

new ptextdraws[MAX_PLAYERS];

OnPlayerConnect

ptextdraw[playerid]=CreatePlayerTextdraw(blabla);


Re: [QUESTION] PlayerTextDraw - MadeMan - 22.03.2012

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


AW: [QUESTION] PlayerTextDraw - Meta - 22.03.2012

You don't need Arrays ...


Re: [QUESTION] PlayerTextDraw - ikkentim - 22.03.2012

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.


Re: [QUESTION] PlayerTextDraw - MP2 - 22.03.2012

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.)


Re: [QUESTION] PlayerTextDraw - Nanory - 22.03.2012

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?...


Re: [QUESTION] PlayerTextDraw - ikkentim - 22.03.2012

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


Re: [QUESTION] PlayerTextDraw - AirKite - 22.03.2012

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



Re: [QUESTION] PlayerTextDraw - Psymetrix - 22.03.2012

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