TextDrawShowForAll hiding other textdraws
#1

EDIT: SOLVED



Hey Guys,

So I'm working on a bit of a race script and I have no idea why the script is behaving the way that it is.

Basically I have created 16 textdraws using a loop that is run OnGameModeInit()
pawn Код:
for(new i = 0; i < 16; i++) {
        ScoreboardNames[i] = TextDrawCreate(480.000000, 130+(i*10), "~r~Error");
        TextDrawFont(ScoreboardNames[i], 2);
        TextDrawLetterSize(ScoreboardNames[i], 0.200000, 1.000000);
        TextDrawColor(ScoreboardNames[i], -1);
        TextDrawSetOutline(ScoreboardNames[i], 1);
        TextDrawSetProportional(ScoreboardNames[i], 1);
        TextDrawSetSelectable(ScoreboardNames[i], 0);
    }
Like so. There are no problems with the creating of the TextDraws as I have debugged it by assigning my ShowTextDrawForAll() function to a command and in doing so I found no problems with the display. Therefore there is actually no purpose in me showing you this script other than giving the idea of how the textdraws are created.

Once the user crosses the last checkpoint (Finish line) a variable (called Finish) will decide upon which place they came (As it increments every time someone finishes) and that will then decide on which Textdraw will be displayed (as it will correspond with the Textdraw.)

OnPlayerEnterRaceCheckpoint() [On the last checkpoint]:
pawn Код:
CurrCP[playerid] = 0;
        if(Finish == 0) { TextDrawShowForAll(ScoreboardBG); TextDrawShowForAll(Scoreboard); }
        new string[35];
        GetPlayerName(playerid, pname, sizeof(pname));
        format(string, sizeof(string), "~g~%i. ~w~%s", Finish+1, pname);
        TextDrawSetString(ScoreboardNames[Finish], string);
        TextDrawShowForAll(ScoreboardNames[Finish]);
        DisablePlayerRaceCheckpoint(playerid);
        Finish++;
        GameTextForPlayer(playerid, "~g~Finished!", 2000, 5);
This is where my problem is coming in.
When I ran
pawn Код:
new string[35];
        GetPlayerName(playerid, pname, sizeof(pname));
        format(string, sizeof(string), "~g~%i. ~w~%s", Finish+1, pname);
        TextDrawSetString(ScoreboardNames[Finish], string);
        TextDrawShowForAll(ScoreboardNames[Finish]);
By itself, it worked perfectly.
When I ran the code within the OnPlayerEnterRaceCheckpoint(playerid) callback, I receive an error where only one textdraw in the ScoreboardNames[] array can be displayed at a time, it moves to the correct location, however, it hides the textdraw above it.

I'm really stuck on this and have no idea what to do to fix it.

Thanks,
Reply
#2

I have found the solution for anyone who may experience a similar problem:

Line:
pawn Код:
if(Finish == 0) { TextDrawShowForAll(ScoreboardBG); TextDrawShowForAll(Scoreboard); }
Was causing it, I think it may be hiding the previous textdraw underneath it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)