[Help] Textdraw
#1

Hello there I have created a stats box for my gamemode it doesn't give any errors or anything but the box doesn't show up in game. In this script I am going to show you I have putted the stats underneath the money:

At the top:
pawn Код:
New Text: Stats;
OnPlayerCommandText:
pawn Код:
if(strcmp(cmd, "/statsbox", true) ==0)
    {
      if(IsPlayerConnected(playerid))
      {
        if (gPlayerLogged[playerid] == 1)
        {
                new otext[20];
                if(PlayerInfo[playerid][pOrigin] == 1) { otext = "USA"; }
                else if(PlayerInfo[playerid][pOrigin] == 2) { otext = "Europe"; }
                else if(PlayerInfo[playerid][pOrigin] == 3) { otext = "Asia"; }
                else if(PlayerInfo[playerid][pOrigin] == 4) { otext = "Africa"; }
            new name[MAX_PLAYER_NAME];
            new level = PlayerInfo[playerid][pLevel];
            new age = PlayerInfo[playerid][pAge];
            new pnumber = PlayerInfo[playerid][pPnumber];
            new coordsstring[256];
                format(coordsstring, sizeof(coordsstring),"< %s >",name);
                Stats = TextDrawCreate(507, 145, coordsstring);
                format(coordsstring, sizeof(coordsstring), "Level:[%d]", level);
                Stats = TextDrawCreate(507, 155, coordsstring);
                format(coordsstring, sizeof(coordsstring), "Age:[%d]", age);
                Stats = TextDrawCreate(507, 165, coordsstring);
                format(coordsstring, sizeof(coordsstring), "Origin:[%d]",otext);
                Stats = TextDrawCreate(507, 175, coordsstring);
                format(coordsstring, sizeof(coordsstring), "Ph:[%d]",pnumber);
                Stats = TextDrawCreate(507, 185, coordsstring);
                Stats = TextDrawCreate(507, 196, "_______________");
                TextDrawAlignment(Stats, 1);
                TextDrawFont(Stats, 1);
                TextDrawLetterSize(Stats, 0.1, 0.1);
                TextDrawColor(Stats, COLOR_LIGHT_BLUE);
            }
        }
        return 1;
    }
The box are going to be showing all the time when a player types /statbox, but the text draws doesn't show, could anyone help me getting out of this?
Reply
#2

You can't do
pawn Код:
new Text:Stats;
Stats = TextDrawCreate(507, 145, coordsstring);
Stats = TextDrawCreate(507, 155, coordsstring);
It will assign to 'Stats' the id of the last textdraw which you created

Do it like
pawn Код:
new
  Text:Stats1,
  Text:Stats2;
Stats1 = TextDrawCreate(507, 145, coordsstring);
Stats2 = TextDrawCreate(507, 155, coordsstring);
or
pawn Код:
new Text:Stats[2];
Stats[0] = TextDrawCreate(507, 145, coordsstring);
Stats[1] = TextDrawCreate(507, 155, coordsstring);
Reply
#3

Okay, thank you I will try it out.

EDIT:
Now it looks like this but still doesn't show:

pawn Код:
new otext[20];
                if(PlayerInfo[playerid][pOrigin] == 1) { otext = "USA"; }
                else if(PlayerInfo[playerid][pOrigin] == 2) { otext = "Europe"; }
                else if(PlayerInfo[playerid][pOrigin] == 3) { otext = "Asia"; }
                else if(PlayerInfo[playerid][pOrigin] == 4) { otext = "Africa"; }
            new name[MAX_PLAYER_NAME];
            new level = PlayerInfo[playerid][pLevel];
            new age = PlayerInfo[playerid][pAge];
            new pnumber = PlayerInfo[playerid][pPnumber];
            new coordsstring[256];
                format(coordsstring, sizeof(coordsstring),"< %s >",name);
                Stats[0] = TextDrawCreate(507, 145, coordsstring);
                format(coordsstring, sizeof(coordsstring), "Level:[%d]", level);
                Stats[1] = TextDrawCreate(507, 155, coordsstring);
                format(coordsstring, sizeof(coordsstring), "Age:[%d]", age);
                Stats[2] = TextDrawCreate(507, 165, coordsstring);
                format(coordsstring, sizeof(coordsstring), "Origin:[%d]",otext);
                Stats[3] = TextDrawCreate(507, 175, coordsstring);
                format(coordsstring, sizeof(coordsstring), "Ph:[%d]",pnumber);
                Stats[4] = TextDrawCreate(507, 185, coordsstring);
                Stats[5] = TextDrawCreate(507, 196, "_______________");
                //Stats[0]
                TextDrawAlignment(Stats[0], 1);
                TextDrawFont(Stats[0], 1);
                TextDrawLetterSize(Stats[0], 0.1, 0.1);
                TextDrawColor(Stats[0], COLOR_LIGHT_BLUE);
                //Stats[1]
                TextDrawAlignment(Stats[1], 1);
                TextDrawFont(Stats[1], 1);
                TextDrawLetterSize(Stats[1], 0.1, 0.1);
                TextDrawColor(Stats[1], COLOR_LIGHT_BLUE);
                //Stats[2]
                TextDrawAlignment(Stats[2], 1);
                TextDrawFont(Stats[2], 1);
                TextDrawLetterSize(Stats[2], 0.1, 0.1);
                TextDrawColor(Stats[2], COLOR_LIGHT_BLUE);
                //Stats[3]
                TextDrawAlignment(Stats[3], 1);
                TextDrawFont(Stats[3], 1);
                TextDrawLetterSize(Stats[3], 0.1, 0.1);
                TextDrawColor(Stats[3], COLOR_LIGHT_BLUE);
                //Stats[4]
                TextDrawAlignment(Stats[4], 1);
                TextDrawFont(Stats[4], 1);
                TextDrawLetterSize(Stats[4], 0.1, 0.1);
                TextDrawColor(Stats[4], COLOR_LIGHT_BLUE);
                //Stats[5]
                TextDrawAlignment(Stats[5], 1);
                TextDrawFont(Stats[5], 1);
                TextDrawLetterSize(Stats[5], 0.1, 0.1);
                TextDrawColor(Stats[5], COLOR_LIGHT_BLUE);
Reply
#4

https://sampwiki.blast.hk/wiki/TextDrawShowForPlayer
https://sampwiki.blast.hk/wiki/TextDrawShowForAll
Reply
#5

God tell me that I'm stupid.... Forgot the ShowTextDrawForPlayer. :/
Reply
#6

I don't see anywhere "TextDrawShowForPlayer". You need that, if you want that players would see it. I had a similar problem with that kind of thing.

EDIT:Oh, sorry, didn't see that you solved the problem
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)