Textdraw not working?
#1

I have a textdraw that turns your screen black when you die and type /accept death, the code is below:


Top of script:
pawn Код:
new Text:blackTD;
After Typed /accept death:
pawn Код:
else if(!strcmp(params, "death", true))
    {
        if(!Injured[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not injured.");
        FMDAcceptedBy[playerid] = 0;
        FMDAccepted[playerid] = 0;
        Injured[playerid] = 0;
        KillTimer(death_timer[playerid]);
        KillTimer(injured_timer[playerid]);
        SendClientMessage(playerid, COLOR_GREY, "You have blacked out. You're currently undergoing hospital treatment.");
        SendClientMessage(playerid, COLOR_WHITE, "You will be released when you have recovered."); //trek
        blackTD = TextDrawCreate(-20.000000,2.000000,"|");
        TextDrawUseBox(blackTD,1);
        TextDrawBoxColor(blackTD,0x000000ff);
        TextDrawTextSize(blackTD,660.000000,22.000000);
        TextDrawAlignment(blackTD,0);
        TextDrawBackgroundColor(blackTD,0x000000ff);
        TextDrawFont(blackTD,3);
        TextDrawLetterSize(blackTD,1.000000,52.200000);
        TextDrawColor(blackTD,0x000000ff);
        TextDrawSetOutline(blackTD,1);
        TextDrawSetProportional(blackTD,1);
        TextDrawSetShadow(blackTD,1);
        TextDrawShowForPlayer(playerid, blackTD);
        SpawnChar(playerid);
        SetPlayerPos(playerid, 1607.3260,1816.8665,10.8203);
        TogglePlayerControllable(playerid, 0);
        SetPlayerHealth(playerid, 100);
        SetPlayerArmour(playerid, 0);
        SetTimerEx("ToggleAcceptDeath", 8000, false, "i", playerid);
        return 1;
    }
    return 1;
}
Timer used above:
pawn Код:
forward ToggleAcceptDeath(playerid);
public ToggleAcceptDeath(playerid)
{
    SendClientMessage(playerid, COLOR_GREY, "---------------------------------------------------------");
    SendClientMessage(playerid, COLOR_LIGHTRED, "You where charged $250 for your medical bill.");
    SendClientMessage(playerid, COLOR_GREY, "You lost 30 minutes memory due to your death to prevent Revenge Kills.");
    SendClientMessage(playerid, COLOR_GREY, "---------------------------------------------------------");
    ResetDodWeapons(playerid);
    GiveDodMoney(playerid, -250);
    TogglePlayerControllable(playerid, 1);
    TextDrawHideForPlayer(playerid, blackTD);
    return 1;
}
The problem is, the first time you use the command, it works-.. but if you use it again the text draw will not hide, it will stay black as appose to the first time where it hid it once the timer was done.
Reply
#2

First: Make PlayerTextdraws not, default global
Second: Create PlayerTextdraws under OnPlayerConnect(Create, SetShadow, Font... everything)
Third: Show PlayerTextdraw to a player when he accepts death and hide it when he respawns
Reply
#3

Quote:
Originally Posted by Sime30
Посмотреть сообщение
First: Make PlayerTextdraws not, default global
Second: Create PlayerTextdraws under OnPlayerConnect(Create, SetShadow, Font... everything)
Third: Show PlayerTextdraw to a player when he accepts death and hide it when he respawns
That did the trick, thank you.

+ Rep
Reply
#4

I'm assuming that this is just a plain black box so I don't see why it should be a player textdraw. It's not like it has any player specific text on it or anything. Create ONE textdraw globally and show/hide as necessary. No need to create a MAX_PLAYER amount of identical textdraws. What a waste of space and processing power.
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
I'm assuming that this is just a plain black box so I don't see why it should be a player textdraw. It's not like it has any player specific text on it or anything. Create ONE textdraw globally and show/hide as necessary. No need to create a MAX_PLAYER amount of identical textdraws. What a waste of space and processing power.
Oooh, what a waste, like what processing power? His script will be slower by 0.00000000001% , DAYUM, that's one hell of a speed. And about space... Please...

By creating Player Textdraws he doesn't need to worry about destroying them or calculating how many are there because the limit for Player Textdraws is a lot bigger than global.

Overall, don't get mad Vince, I respect you because you helped me several times and you know "the stuff". In my honest opinion, I think he should use Player Textdraws whenever the textdraw is being shown "to only one player" at some time. Stuff like Server messages, server time should be global, that's okay. You never know what will happen next. What if he wants a unique message to be shown when a player dies, blah blah... He doesn't need to worry when using Player Textdraws as he needs with global.

Amen!
Reply
#6

Your argument is just plain ridiculous. Then why does TextDrawShowForPlayer exist? If you need one textdraw that you only need to create once (in OnGameModeInit) then why bother creating one for each and every player if it's going to look identical anyway? More clutter in OnPlayerConnect and therefore more unneeded processing, however small the impact may be. I stand by my point.
Reply
#7

Quote:
Originally Posted by Vince
Посмотреть сообщение
Your argument is just plain ridiculous. Then why does TextDrawShowForPlayer exist? If you need one textdraw that you only need to create once (in OnGameModeInit) then why bother creating one for each and every player if it's going to look identical anyway? More clutter in OnPlayerConnect and therefore more unneeded processing, however small the impact may be. I stand by my point.
Although that is true, I initially used that method and it wasn't working. I spent about an hour and couldn't fix the bug, so I just created a seperate textdraw for every player. So-.. Yes that way is better, but it wouldn't work and as said above, it wouldn't have any effect on the script.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)