CreatePlayerTextDraw not working?
#1

So I have encountered a interesting issue. While testing a Spawn Selection script I started working on this morning I noticed that all the Player Textdraws are not being shown. After a few hours of debugging I traced it all the way back to CreatePlayerTextDraw.

Here is the Relevant Code:

Variables:
pawn Код:
new Text: G_SpawnSelectionTD[5];
new PlayerText: P_SpawnSelectionTD[MAX_PLAYERS][6];
TextDraws:
pawn Код:
// SS_CreateGlobalTextDraws - create all the global textdraws
stock SS_CreateGlobalTextDraws()
{
    G_SpawnSelectionTD[0] = TextDrawCreate(641.666931, 1.500000, "top-box");
    TextDrawLetterSize(G_SpawnSelectionTD[0], 0.000000, 9.582097);
    TextDrawTextSize(G_SpawnSelectionTD[0], -1.333333, 0.000000);
    TextDrawAlignment(G_SpawnSelectionTD[0], 1);
    TextDrawColor(G_SpawnSelectionTD[0], 0);
    TextDrawUseBox(G_SpawnSelectionTD[0], true);
    TextDrawBoxColor(G_SpawnSelectionTD[0], 102);
    TextDrawSetShadow(G_SpawnSelectionTD[0], 0);
    TextDrawSetOutline(G_SpawnSelectionTD[0], 0);
    TextDrawFont(G_SpawnSelectionTD[0], 0);

    G_SpawnSelectionTD[1] = TextDrawCreate(642.333923, 355.922241, "bottom-box");
    TextDrawLetterSize(G_SpawnSelectionTD[1], 0.000000, 9.915431);
    TextDrawTextSize(G_SpawnSelectionTD[1], -1.999989, 0.000000);
    TextDrawAlignment(G_SpawnSelectionTD[1], 1);
    TextDrawColor(G_SpawnSelectionTD[1], 0);
    TextDrawUseBox(G_SpawnSelectionTD[1], true);
    TextDrawBoxColor(G_SpawnSelectionTD[1], 102);
    TextDrawSetShadow(G_SpawnSelectionTD[1], 0);
    TextDrawSetOutline(G_SpawnSelectionTD[1], 0);
    TextDrawFont(G_SpawnSelectionTD[1], 0);

    G_SpawnSelectionTD[2] = TextDrawCreate(318.333282, 355.496307, "~r~Spawn Selection Controls");
    TextDrawLetterSize(G_SpawnSelectionTD[2], 0.526997, 2.031407);
    TextDrawAlignment(G_SpawnSelectionTD[2], 2);
    TextDrawColor(G_SpawnSelectionTD[2], -1);
    TextDrawSetShadow(G_SpawnSelectionTD[2], 0);
    TextDrawSetOutline(G_SpawnSelectionTD[2], 1);
    TextDrawBackgroundColor(G_SpawnSelectionTD[2], 255);
    TextDrawFont(G_SpawnSelectionTD[2], 3);
    TextDrawSetProportional(G_SpawnSelectionTD[2], 1);

    G_SpawnSelectionTD[3] = TextDrawCreate(449.333251, 376.077880, "spawn-name-box");
    TextDrawLetterSize(G_SpawnSelectionTD[3], 0.000000, 2.725306);
    TextDrawTextSize(G_SpawnSelectionTD[3], 187.333374, 0.000000);
    TextDrawAlignment(G_SpawnSelectionTD[3], 1);
    TextDrawColor(G_SpawnSelectionTD[3], 0);
    TextDrawUseBox(G_SpawnSelectionTD[3], true);
    TextDrawBoxColor(G_SpawnSelectionTD[3], 102);
    TextDrawSetShadow(G_SpawnSelectionTD[3], 0);
    TextDrawSetOutline(G_SpawnSelectionTD[3], 0);
    TextDrawFont(G_SpawnSelectionTD[3], 0);

    G_SpawnSelectionTD[4] = TextDrawCreate(303.999908, 8.296285, "~r~Total~b~Stuntage");
    TextDrawLetterSize(G_SpawnSelectionTD[4], 0.927666, 2.956444);
    TextDrawAlignment(G_SpawnSelectionTD[4], 2);
    TextDrawColor(G_SpawnSelectionTD[4], -1);
    TextDrawSetShadow(G_SpawnSelectionTD[4], 0);
    TextDrawSetOutline(G_SpawnSelectionTD[4], 2);
    TextDrawBackgroundColor(G_SpawnSelectionTD[4], 255);
    TextDrawFont(G_SpawnSelectionTD[4], 0);
    TextDrawSetProportional(G_SpawnSelectionTD[4], 1);

    printf("Global Textdraws\n%d | %d | %d | %d | %d",
        _:G_SpawnSelectionTD[0],
        _:G_SpawnSelectionTD[1],
        _:G_SpawnSelectionTD[2],
        _:G_SpawnSelectionTD[3],
        _:G_SpawnSelectionTD[4]);
    return 1;
}

// SS_CreatePlayerTextDraws - create all the player textdraws
stock SS_CreatePlayerTextDraws()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {  
        P_SpawnSelectionTD[i][0] = CreatePlayerTextDraw(i, 190.999969, 376.237121, "~<~");
        PlayerTextDrawLetterSize(i, P_SpawnSelectionTD[i][0], 0.479999, 2.375705);
        PlayerTextDrawAlignment(i, P_SpawnSelectionTD[i][0], 2);
        PlayerTextDrawColor(i, P_SpawnSelectionTD[i][0], -1);
        PlayerTextDrawSetShadow(i, P_SpawnSelectionTD[i][0], 0);
        PlayerTextDrawSetOutline(i, P_SpawnSelectionTD[i][0], 1);
        PlayerTextDrawBackgroundColor(i, P_SpawnSelectionTD[i][0], 51);
        PlayerTextDrawFont(i, P_SpawnSelectionTD[i][0], 1);
        PlayerTextDrawSetProportional(i, P_SpawnSelectionTD[i][0], 1);
        PlayerTextDrawSetSelectable(i, P_SpawnSelectionTD[i][0], true);

        P_SpawnSelectionTD[i][1] = CreatePlayerTextDraw(i, 428.999969, 376.407440, "~>~");
        PlayerTextDrawLetterSize(i, P_SpawnSelectionTD[i][1], 0.479999, 2.375705);
        PlayerTextDrawAlignment(i, P_SpawnSelectionTD[i][1], 2);
        PlayerTextDrawColor(i, P_SpawnSelectionTD[i][1], -1);
        PlayerTextDrawSetShadow(i, P_SpawnSelectionTD[i][1], 0);
        PlayerTextDrawSetOutline(i, P_SpawnSelectionTD[i][1], 1);
        PlayerTextDrawBackgroundColor(i, P_SpawnSelectionTD[i][1], 51);
        PlayerTextDrawFont(i, P_SpawnSelectionTD[i][1], 1);
        PlayerTextDrawSetProportional(i, P_SpawnSelectionTD[i][1], 1);
        PlayerTextDrawSetSelectable(i, P_SpawnSelectionTD[i][1], true);

        P_SpawnSelectionTD[i][2] = CreatePlayerTextDraw(i, 318.333251, 378.481567, "~p~Abandoned Airyard");
        PlayerTextDrawLetterSize(i, P_SpawnSelectionTD[i][2], 0.526997, 2.031407);
        PlayerTextDrawAlignment(i, P_SpawnSelectionTD[i][2], 2);
        PlayerTextDrawColor(i, P_SpawnSelectionTD[i][2], -1);
        PlayerTextDrawSetShadow(i, P_SpawnSelectionTD[i][2], 0);
        PlayerTextDrawSetOutline(i, P_SpawnSelectionTD[i][2], 1);
        PlayerTextDrawBackgroundColor(i, P_SpawnSelectionTD[i][2], 255);
        PlayerTextDrawFont(i, P_SpawnSelectionTD[i][2], 0);
        PlayerTextDrawSetProportional(i, P_SpawnSelectionTD[i][2], 1);

        P_SpawnSelectionTD[i][3] = CreatePlayerTextDraw(i, 449.666564, 405.700103, "spawn-box");
        PlayerTextDrawLetterSize(i, P_SpawnSelectionTD[i][3], 0.000000, 2.725306);
        PlayerTextDrawTextSize(i, P_SpawnSelectionTD[i][3], 186.666717, 0.000000);
        PlayerTextDrawAlignment(i, P_SpawnSelectionTD[i][3], 1);
        PlayerTextDrawColor(i, P_SpawnSelectionTD[i][3], 0);
        PlayerTextDrawUseBox(i, P_SpawnSelectionTD[i][3], true);
        PlayerTextDrawBoxColor(i, P_SpawnSelectionTD[i][3], 102);
        PlayerTextDrawSetShadow(i, P_SpawnSelectionTD[i][3], 0);
        PlayerTextDrawSetOutline(i, P_SpawnSelectionTD[i][3], 0);
        PlayerTextDrawFont(i, P_SpawnSelectionTD[i][3], 0);

        P_SpawnSelectionTD[i][4] = CreatePlayerTextDraw(i, 313.999969, 407.518585, "~r~~h~Spawn");
        PlayerTextDrawLetterSize(i, P_SpawnSelectionTD[i][4], 0.526997, 2.031407);
        PlayerTextDrawAlignment(i, P_SpawnSelectionTD[i][4], 2);
        PlayerTextDrawColor(i, P_SpawnSelectionTD[i][4], -1);
        PlayerTextDrawSetShadow(i, P_SpawnSelectionTD[i][4], 0);
        PlayerTextDrawSetOutline(i, P_SpawnSelectionTD[i][4], 1);
        PlayerTextDrawBackgroundColor(i, P_SpawnSelectionTD[i][4], 255);
        PlayerTextDrawFont(i, P_SpawnSelectionTD[i][4], 3);
        PlayerTextDrawSetProportional(i, P_SpawnSelectionTD[i][4], 1);
        PlayerTextDrawSetSelectable(i, P_SpawnSelectionTD[i][4], true);

        P_SpawnSelectionTD[i][5] = CreatePlayerTextDraw(i, 309.000000, 39.333396, "~p~We hope you enjoy your stay with us!");
        PlayerTextDrawLetterSize(i, P_SpawnSelectionTD[i][5], 0.263997, 1.438221);
        PlayerTextDrawAlignment(i, P_SpawnSelectionTD[i][5], 2);
        PlayerTextDrawColor(i, P_SpawnSelectionTD[i][5], -1);
        PlayerTextDrawSetShadow(i, P_SpawnSelectionTD[i][5], 0);
        PlayerTextDrawSetOutline(i, P_SpawnSelectionTD[i][5], 1);
        PlayerTextDrawBackgroundColor(i, P_SpawnSelectionTD[i][5], 255);
        PlayerTextDrawFont(i, P_SpawnSelectionTD[i][5], 3);
        PlayerTextDrawSetProportional(i, P_SpawnSelectionTD[i][5], 1);
    }

    printf("Player Textdraws\n%d | %d | %d | %d | %d | %d",
        _:P_SpawnSelectionTD[0][0],
        _:P_SpawnSelectionTD[0][1],
        _:P_SpawnSelectionTD[0][2],
        _:P_SpawnSelectionTD[0][3],
        _:P_SpawnSelectionTD[0][4],
        _:P_SpawnSelectionTD[0][5]);
    return 1;
}
Display Code:
pawn Код:
// SS_DisplayTextDraws - displays all the textdraws for the current spawn selection
stock SS_DisplayTextDraws(playerid)
{
    for(new i = 0; i < sizeof(G_SpawnSelectionTD); i++)
    {
        TextDrawShowForPlayer(playerid, G_SpawnSelectionTD[i]);
        printf("X: [Spawn Selector] Displaying Global Textdraw %i", i);
    }
   
    for(new i = 0; i < sizeof(P_SpawnSelectionTD[]); i++)
    {
        PlayerTextDrawShow(playerid, P_SpawnSelectionTD[playerid][i]);
        printf("X: [Spawn Selector] Displaying Player Textdraw %i", i);
    }
    return 1;
}
output:


I have been banging my head against the wall for hours now trying to figure out why the player textdraws are not being created. I must be something so simple that I am over looking it 3000 times. Just hoping maybe some fresh eyes might shed some light where I don goofed.


EDIT--

I also installed CrashDetect to see if it would find out whats happening. No stack traces are being created. Everything seems to operate normally other than the player textdraws not being created.
Reply
#2

@Also on your first area, Where you want to create the player text draws try adding 'PLAYERID' after the stock exchange

I always use this method, saves time and you know it works every time.

Hopefully this helps you out.

Код:
new Text:ExampleTextdraw[MAX_PLAYERS];

LoadPlayerTextdraws(playerid);


forward LoadPlayerTextdraws(playerid);
public LoadPlayerTextdraws(playerid)
{
      for(new i = 0; i < MAX_PLAYERS; i++)
      {
              ExampleTextdraws[i] = TextDrawCreate etc
       }
}
Reply
#3

You have to create PlayerTextdraw for player if he is connected - if not, textdraws won't be created. Try put this code to callback OnPlayerConnect - i have like this in my gamemode.
Reply
#4

Quote:
Originally Posted by ball
Посмотреть сообщение
You have to create PlayerTextdraw for player if he is connected - if not, textdraws won't be created. Try put this code to callback OnPlayerConnect - i have like this in my gamemode.
see that's what I meant by I was missing something. Thanks!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)