[HELP] Textdraw not showing
#1

So I have these codes that supposed to be Player textdraws (not global).

pawn Код:
new PlayerText:Textdraw20[MAX_PLAYERS];
new PlayerText:Textdraw21[MAX_PLAYERS];
new PlayerText:Textdraw22[MAX_PLAYERS];


public OnPlayerConnect(playerid)
{
    Textdraw20[playerid] = CreatePlayerTextDraw(playerid, 37.999977, 431.573272, "2000");
    PlayerTextDrawLetterSize(playerid, Textdraw20[playerid], 0.215999, 1.380977);
    PlayerTextDrawAlignment(playerid, Textdraw20[playerid], 1);
    PlayerTextDrawColor(playerid, Textdraw20[playerid], -2147483393);
    PlayerTextDrawSetShadow(playerid, Textdraw20[playerid], 0);
    PlayerTextDrawSetOutline(playerid, Textdraw20[playerid], 0);
    PlayerTextDrawBackgroundColor(playerid, Textdraw20[playerid], 51);
    PlayerTextDrawFont(playerid, Textdraw20[playerid], 1);
    PlayerTextDrawSetProportional(playerid, Textdraw20[playerid], 1);

    Textdraw21[playerid] = CreatePlayerTextDraw(playerid, 120.800018, 431.075622, "1000");
    PlayerTextDrawLetterSize(playerid, Textdraw21[playerid], 0.208399, 1.495465);
    PlayerTextDrawAlignment(playerid, Textdraw21[playerid], 1);
    PlayerTextDrawColor(playerid, Textdraw21[playerid], -2147483393);
    PlayerTextDrawSetShadow(playerid, Textdraw21[playerid], 0);
    PlayerTextDrawSetOutline(playerid, Textdraw21[playerid], 0);
    PlayerTextDrawBackgroundColor(playerid, Textdraw21[playerid], 51);
    PlayerTextDrawFont(playerid, Textdraw21[playerid], 1);
    PlayerTextDrawSetProportional(playerid, Textdraw21[playerid], 1);

    Textdraw22[playerid] = CreatePlayerTextDraw(playerid, 211.199981, 430.577758, "Louis");
    PlayerTextDrawLetterSize(playerid, Textdraw22[playerid], 0.278400, 1.570132);
    PlayerTextDrawAlignment(playerid, Textdraw22[playerid], 1);
    PlayerTextDrawColor(playerid, Textdraw22[playerid], -2147483393);
    PlayerTextDrawSetShadow(playerid, Textdraw22[playerid], 0);
    PlayerTextDrawSetOutline(playerid, Textdraw22[playerid], 0);
    PlayerTextDrawBackgroundColor(playerid, Textdraw22[playerid], 51);
    PlayerTextDrawFont(playerid, Textdraw22[playerid], 1);
    PlayerTextDrawSetProportional(playerid, Textdraw22[playerid], 1);

    return 1;
}


public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer(playerid, Textdraw20[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw21[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw22[playerid]);
    return 1;
}

public OnPlayerUpdate(playerid)
{
    TextDrawSetString(Textdraw20[playerid], PInfo[playerid][Kills]);
    TextDrawSetString(Textdraw21[playerid], PInfo[playerid][Deaths]);
    return 1;
}
And the textdraw20 and textdraw21 doesn't show anything.

NOTE: I'm using a textdraw box below those text. If you want to see how the textdraw looks like then please let me know.

NOTE: Same goes for the other player textdraws I'm creating. It doesn't show anything!

Thanks! I really appreciate someone for the help!
Reply
#2

Any help?
Reply
#3

You need to move the whole OnPlayerConnect section to OnGameModeInit.
Cheers.
Reply
#4

How am I suppose to move that codes to OnGameModeInit since it doesn't have playerid function in it?
Reply
#5

PHP код:
public OnGameModeInit()
{
  for(new 
i=0;i<MAX_PLAYERS;i++)
  {
     
//Add Your Code Here
    //Change [playerid] to [i]
  
}
  return 
1;

Reply
#6

This is the codes after I attempt to change (it is still not working!) Am I doing something wrong here?

pawn Код:
new PlayerText:Textdraw20[MAX_PLAYERS];
new PlayerText:Textdraw21[MAX_PLAYERS];
new PlayerText:Textdraw22[MAX_PLAYERS];

public OnGameModeInit()
{  
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        Textdraw20[i] = CreatePlayerTextDraw(i, 37.999977, 431.573272, "");
        PlayerTextDrawLetterSize(i, Textdraw20[i], 0.215999, 1.380977);
        PlayerTextDrawAlignment(i, Textdraw20[i], 1);
        PlayerTextDrawColor(i, Textdraw20[i], -2147483393);
        PlayerTextDrawSetShadow(i, Textdraw20[i], 0);
        PlayerTextDrawSetOutline(i, Textdraw20[i], 0);
        PlayerTextDrawBackgroundColor(i, Textdraw20[i], 51);
        PlayerTextDrawFont(i, Textdraw20[i], 1);
        PlayerTextDrawSetProportional(i, Textdraw20[i], 1);

        Textdraw21[i] = CreatePlayerTextDraw(i, 120.800018, 431.075622, "");
        PlayerTextDrawLetterSize(i, Textdraw21[i], 0.208399, 1.495465);
        PlayerTextDrawAlignment(i, Textdraw21[i], 1);
        PlayerTextDrawColor(i, Textdraw21[i], -2147483393);
        PlayerTextDrawSetShadow(i, Textdraw21[i], 0);
        PlayerTextDrawSetOutline(i, Textdraw21[i], 0);
        PlayerTextDrawBackgroundColor(i, Textdraw21[i], 51);
        PlayerTextDrawFont(i, Textdraw21[i], 1);
        PlayerTextDrawSetProportional(i, Textdraw21[i], 1);

        Textdraw22[i] = CreatePlayerTextDraw(i, 211.199981, 430.577758, "");
        PlayerTextDrawLetterSize(i, Textdraw22[i], 0.278400, 1.570132);
        PlayerTextDrawAlignment(i, Textdraw22[i], 1);
        PlayerTextDrawColor(i, Textdraw22[i], -2147483393);
        PlayerTextDrawSetShadow(i, Textdraw22[i], 0);
        PlayerTextDrawSetOutline(i, Textdraw22[i], 0);
        PlayerTextDrawBackgroundColor(i, Textdraw22[i], 51);
        PlayerTextDrawFont(i, Textdraw22[i], 1);
        PlayerTextDrawSetProportional(i, Textdraw22[i], 1);
    }
    return 1;
}

public OnPlayerSpawn(playerid)
{
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        TextDrawShowForPlayer(playerid, Textdraw20[i]);
        TextDrawShowForPlayer(playerid, Textdraw21[i]);
        TextDrawShowForPlayer(playerid, Textdraw22[i]);
    }

    return 1;
}

public OnPlayerUpdate(playerid)
{
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        TextDrawSetString(Textdraw20[i], PInfo[playerid][Kills]);
        TextDrawSetString(Textdraw21[i], PInfo[playerid][Deaths]);
    }
    return 1;
}
Please let me know if I did something wrong..
Reply
#7

Quote:
Originally Posted by Xsyiaris
Посмотреть сообщение
You need to move the whole OnPlayerConnect section to OnGameModeInit.
Cheers.
that doesn't really matter.

I don't understand what you're doing though, and I'm wondering why it doesn't show any errors/warnings.

because of this:

Creation of a PLAYER textdraw;
pawn Код:
Textdraw20[i] = CreatePlayerTextDraw(i, 37.999977, 431.573272, "");
Showing a Textdraw( wrong function! )
pawn Код:
TextDrawShowForPlayer(playerid, Textdraw20[playerid]);
switch those to:

PlayerTextDrawShow.

https://sampwiki.blast.hk/wiki/PlayerTextDrawShow

the way you do it, it should give some tag mismatch warnings if I'm right.

same goes for OnPlayerUpdate

pawn Код:
TextDrawSetString(Textdraw20[i], PInfo[playerid][Kills]);
should be PlayerTextDrawSetString

https://sampwiki.blast.hk/wiki/PlayerTextDrawSetString

also don't use loops in OnPlayerConnect/OnPlayerSpawn/OnPlayerUpdate as it has a playerid parameter already.

this is how you should do it:

pawn Код:
// Create Playertextdraws here( new PlayerText:yourtext; );
OnPlayerConnect // create them here with yourtext = CreatePlayerTextDraw;
OnPlayerSpawn // Show them here with PlayerTextDrawShow;
OnPlayerUpdate // update them here with PlayerTextDrawSetString
NOTE: after changing the string, you need to RE-SHOW the textdraw, meaning you should do:

pawn Код:
PlayerTextDrawSetString( .... );
PlayerTextDrawShow( .... );
Reply
#8

Okay, thanks for your replies, but however it is still not working:

pawn Код:
new PlayerText:Textdraw20[MAX_PLAYERS];
new PlayerText:Textdraw21[MAX_PLAYERS];
new PlayerText:Textdraw22[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
        Textdraw20[playerid] = CreatePlayerTextDraw(playerid, 37.999977, 431.573272, " ");
        PlayerTextDrawLetterSize(playerid, Textdraw20[playerid], 0.215999, 1.380977);
        PlayerTextDrawAlignment(playerid, Textdraw20[playerid], 1);
        PlayerTextDrawColor(playerid, Textdraw20[playerid], -2147483393);
        PlayerTextDrawSetShadow(playerid, Textdraw20[playerid], 0);
        PlayerTextDrawSetOutline(playerid, Textdraw20[playerid], 0);
        PlayerTextDrawBackgroundColor(playerid, Textdraw20[playerid], 51);
        PlayerTextDrawFont(playerid, Textdraw20[playerid], 1);
        PlayerTextDrawSetProportional(playerid, Textdraw20[playerid], 1);

        Textdraw21[playerid] = CreatePlayerTextDraw(playerid, 120.800018, 431.075622, " ");
        PlayerTextDrawLetterSize(playerid, Textdraw21[playerid], 0.208399, 1.495465);
        PlayerTextDrawAlignment(playerid, Textdraw21[playerid], 1);
        PlayerTextDrawColor(playerid, Textdraw21[playerid], -2147483393);
        PlayerTextDrawSetShadow(playerid, Textdraw21[playerid], 0);
        PlayerTextDrawSetOutline(playerid, Textdraw21[playerid], 0);
        PlayerTextDrawBackgroundColor(playerid, Textdraw21[playerid], 51);
        PlayerTextDrawFont(playerid, Textdraw21[playerid], 1);
        PlayerTextDrawSetProportional(playerid, Textdraw21[playerid], 1);

        Textdraw22[playerid] = CreatePlayerTextDraw(playerid, 211.199981, 430.577758, " ");
        PlayerTextDrawLetterSize(playerid, Textdraw22[playerid], 0.278400, 1.570132);
        PlayerTextDrawAlignment(playerid, Textdraw22[playerid], 1);
        PlayerTextDrawColor(playerid, Textdraw22[playerid], -2147483393);
        PlayerTextDrawSetShadow(playerid, Textdraw22[playerid], 0);
        PlayerTextDrawSetOutline(playerid, Textdraw22[playerid], 0);
        PlayerTextDrawBackgroundColor(playerid, Textdraw22[playerid], 51);
        PlayerTextDrawFont(playerid, Textdraw22[playerid], 1);
        PlayerTextDrawSetProportional(playerid, Textdraw22[playerid], 1);
        return 1;
}

public OnPlayerSpawn(playerid)
{  
        PlayerTextDrawShow(playerid, Textdraw20[playerid]);
        PlayerTextDrawShow(playerid, Textdraw21[playerid]);
        PlayerTextDrawShow(playerid, Textdraw22[playerid]);
        return 1;
}

public OnPlayerUpdate(playerid)
{
        PlayerTextDrawSetString(Textdraw20[playerid], PInfo[playerid][Kills]);
        PlayerTextDrawSetString(Textdraw21[playerid], PInfo[playerid][Deaths]);
        return 1;
}
Did I do something wrong, again?


Or if I'm not, what might be the reasons it is not appearing?
Reply
#9

Quote:
Originally Posted by roar
Посмотреть сообщение
Okay, thanks for your replies, but however it is still not working:

pawn Код:
new PlayerText:Textdraw20[MAX_PLAYERS];
new PlayerText:Textdraw21[MAX_PLAYERS];
new PlayerText:Textdraw22[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
        Textdraw20[playerid] = CreatePlayerTextDraw(playerid, 37.999977, 431.573272, " ");
        PlayerTextDrawLetterSize(playerid, Textdraw20[playerid], 0.215999, 1.380977);
        PlayerTextDrawAlignment(playerid, Textdraw20[playerid], 1);
        PlayerTextDrawColor(playerid, Textdraw20[playerid], -2147483393);
        PlayerTextDrawSetShadow(playerid, Textdraw20[playerid], 0);
        PlayerTextDrawSetOutline(playerid, Textdraw20[playerid], 0);
        PlayerTextDrawBackgroundColor(playerid, Textdraw20[playerid], 51);
        PlayerTextDrawFont(playerid, Textdraw20[playerid], 1);
        PlayerTextDrawSetProportional(playerid, Textdraw20[playerid], 1);

        Textdraw21[playerid] = CreatePlayerTextDraw(playerid, 120.800018, 431.075622, " ");
        PlayerTextDrawLetterSize(playerid, Textdraw21[playerid], 0.208399, 1.495465);
        PlayerTextDrawAlignment(playerid, Textdraw21[playerid], 1);
        PlayerTextDrawColor(playerid, Textdraw21[playerid], -2147483393);
        PlayerTextDrawSetShadow(playerid, Textdraw21[playerid], 0);
        PlayerTextDrawSetOutline(playerid, Textdraw21[playerid], 0);
        PlayerTextDrawBackgroundColor(playerid, Textdraw21[playerid], 51);
        PlayerTextDrawFont(playerid, Textdraw21[playerid], 1);
        PlayerTextDrawSetProportional(playerid, Textdraw21[playerid], 1);

        Textdraw22[playerid] = CreatePlayerTextDraw(playerid, 211.199981, 430.577758, " ");
        PlayerTextDrawLetterSize(playerid, Textdraw22[playerid], 0.278400, 1.570132);
        PlayerTextDrawAlignment(playerid, Textdraw22[playerid], 1);
        PlayerTextDrawColor(playerid, Textdraw22[playerid], -2147483393);
        PlayerTextDrawSetShadow(playerid, Textdraw22[playerid], 0);
        PlayerTextDrawSetOutline(playerid, Textdraw22[playerid], 0);
        PlayerTextDrawBackgroundColor(playerid, Textdraw22[playerid], 51);
        PlayerTextDrawFont(playerid, Textdraw22[playerid], 1);
        PlayerTextDrawSetProportional(playerid, Textdraw22[playerid], 1);
        return 1;
}

public OnPlayerSpawn(playerid)
{  
        PlayerTextDrawShow(playerid, Textdraw20[playerid]);
        PlayerTextDrawShow(playerid, Textdraw21[playerid]);
        PlayerTextDrawShow(playerid, Textdraw22[playerid]);
        return 1;
}

public OnPlayerUpdate(playerid)
{
        PlayerTextDrawSetString(Textdraw20[playerid], PInfo[playerid][Kills]);
        PlayerTextDrawSetString(Textdraw21[playerid], PInfo[playerid][Deaths]);
        return 1;
}
Did I do something wrong, again?


Or if I'm not, what might be the reasons it is not appearing?
because you're leaving the textdraws empty.

Quote:

NOTE: after changing the string, you need to RE-SHOW the textdraw.

so you should do:

pawn Код:
public OnPlayerUpdate(playerid)
{
        PlayerTextDrawSetString(Textdraw20[playerid], PInfo[playerid][Kills]);
        PlayerTextDrawSetString(Textdraw21[playerid], PInfo[playerid][Deaths]);
        PlayerTextDrawShow(playerid, Textdraw20[playerid]);
        PlayerTextDrawShow(playerid, Textdraw21[playerid]);
        return 1;
}
https://sampwiki.blast.hk/wiki/CreatePlayerTextDraw

checkout the red bars stating "NOTE" for all the information you need

also I do NOT recommend using OnPlayerUpdate to update the kills and deaths.

simply use OnPlayerDeath.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
        PInfo[ killerid ][ Kills ]++;
        PInfo[ playerid ][ Deaths ]++;
        PlayerTextDrawSetString(Textdraw20[killerid], PInfo[killerid][Kills]);
        PlayerTextDrawSetString(Textdraw21[playerid], PInfo[playerid][Deaths]);
        PlayerTextDrawShow(killerid, Textdraw20[killerid]);
        PlayerTextDrawShow(playerid, Textdraw21[playerid]);
        return 1;
}
Reply
#10

The second parameter of PlayerTextDrawSetString must be string and not integers. You also should check if the killer is connected/valid player before using it in an array otherwise a run time error will be caused.

And a last thing, per-player textdraws should be created in OnPlayerConnect, if the server starts, there are 0 players connected thus it will create none of them.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)