PlayerTextDraws
#1

Question:
If I want to create one PlayerTextDraw for each player. Do I need to do it this way:
Код:
new PlayerText:TDid[MAX_PLAYERS];
or in this way:
Код:
new PlayerText:TDid;
I am asking this because every PlayerTextDraw-function has playerid as it's parameter and to me it looks like the second way is right one.
Thank you in advance!
Reply
#2

Код:
public vhealth_td_update(playerid)
{
    new tdstring[32], Float:vHealth;
    GetVehicleHealth(GetPlayerVehicleID(playerid), vHealth);
 
    format(tdstring, sizeof(tdstring), "Vehicle Health: %0f", vHealth);
 
    PlayerTextDrawSetString(playerid, pVehicleHealthTD[playerid], tdstring); // <<< Update the text to show the vehicle health
    return 1;
}
from Samp-wiki(https://sampwiki.blast.hk/wiki/PlayerTextDrawSetString)- they are using[playerid]. I firstly thought same as you but when I saw this example I was like wtf. So the example is wrong?
Reply
#3

I think you DO need an array, though.

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
I wondered this at first but don't worry, forget about the array!

Because you assign it like this:

pawn Код:
gPlayerTD = CreatePlayerTextDraw(playerid, ...)
The first parameter removes the need to use an array, that's the point of Player TextDraws
Have you tested this with 3 or more players?
Reply
#4

Hmmm donno if somone complained about PlayerTextDraws, but for me it looks like they are bugged.
Somehow text of the one textdraw became red. In script that textdraw never should be red.
Others yes, but that one no. As well as that, it changed position.
I think bug comes when you first create A playertextdraw after that create B Playertextdraw and change the color of the B playertextDraw(box,textside,etc) and then show the A playetextdraw to the player.
Reply
#5

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
The array is a waste of time and memory!

There is no need for it if you pass a player ID to the PlayerTextDraw functions.

That's partly why PlayerTextDraws were created:

pawn Код:
// Old way
new Text:gStats[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
    gStats[playerid] = TextDrawCreate(...);
....


// New way
new PlayerText:gStats;
public OnPlayerConnect(playerid)
{
    gStats = CreatePlayerTextDraw([B]playerid[/B], ...);
....
I'll edit the wiki page to avoid confusion.
I disagree. I also, after reading this thread(https://sampforum.blast.hk/showthread.php?tid=336460), think the array thing is needed.
As I said before, somehow in my script Textdraws' Ids were mixed. I still don't understand how will array thing that prevent. i would say that using PlayerTextDraws is a very tricy thing.

Limit for PlayerTextDraw is 256 per player. Is this going over limits since MAX_PLAYERS=500?

new PlayerText:TextDraw[MAX_PLAYERS];
Reply
#6

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
Well I've never had a problem reported to me, and I've seen for myself on both monitors!

Maybe it's a bug related to higher player counts, I only have a 16 slot server!
I tried that only by myself. None else. I guess you are creating them under OnPlayerConnect? then they are in order, and they shouldn't be mixed.
Anyways thanks for help!
Reply
#7

So you are claiming it is better to use CreatePlayerTextdraw fuction related than using TextDrawCreate fuction with an array?
Reply
#8

Oh i see thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)