Textdraws get bugged.
#1

Hi

I'm experimenting with textdraws and I encountered a problem that I can't fix.

The textdraws that I'm showing are the licenses of the player. For example if I do /showlicenses 0, it will show the textdraws to player 0 with my information on it. The problem is that the textdraws that I show get bugged. They don't disappear completely or they don't disappear at all.

Here's my code:

Showlicenses command
pawn Код:
CMD:showlicenses(playerid, params[])
{
    new string[128], tID, Float:X, Float:Y, Float:Z;
    if(!gPlayerLogged[playerid]) return SCM(playerid, COLOR_GREY, NOTLOGGED);
    if(sscanf(params, "u", tID)) return SCM(playerid, -1, "* [USAGE]: /showlicenses [playerid/PartOfName]");
    if(tID == INVALID_PLAYER_ID) return SCM(playerid, COLOR_GREY, ISINVALID);
    if(!gPlayerLogged[tID]) return SCM(playerid, COLOR_GREY, ISNOTLOGGED);
    if(gLicensesShown[tID]) return SCM(playerid, COLOR_GREY, "* [ERROR]: Somebody else is showing their licenses. Try again later.");
    GetPlayerPos(playerid, X, Y, Z);
    if(IsPlayerInRangeOfPoint(tID, 5, X, Y, Z))
    {
        Textdraw120[playerid] = CreatePlayerTextDraw(tID, 182.190460, 150.833343, "usebox");
        PlayerTextDrawLetterSize(tID, Textdraw120[playerid], 0.000000, 13.384071);
        PlayerTextDrawTextSize(tID, Textdraw120[playerid], 14.000000, 0.000000);
        PlayerTextDrawAlignment(tID, Textdraw120[playerid], 1);
        PlayerTextDrawColor(tID, Textdraw120[playerid], 0);
        PlayerTextDrawUseBox(tID, Textdraw120[playerid], true);
        PlayerTextDrawBoxColor(tID, Textdraw120[playerid], 102);
        PlayerTextDrawSetShadow(tID, Textdraw120[playerid], 0);
        PlayerTextDrawSetOutline(tID, Textdraw120[playerid], 0);
        PlayerTextDrawFont(tID, Textdraw120[playerid], 0);
        PlayerTextDrawShow(tID, Textdraw120[playerid]);

        Textdraw121[playerid] = CreatePlayerTextDraw(tID, 22.095239, 181.333343, "_");
        PlayerTextDrawLetterSize(tID, Textdraw121[playerid], 0.000000, 0.000000);
        PlayerTextDrawTextSize(tID, Textdraw121[playerid], 41.142860, 84.479980);
        PlayerTextDrawAlignment(tID, Textdraw121[playerid], 1);
        PlayerTextDrawColor(tID, Textdraw121[playerid], -1);
        PlayerTextDrawSetShadow(tID, Textdraw121[playerid], 0);
        PlayerTextDrawSetOutline(tID, Textdraw121[playerid], 0);
        PlayerTextDrawFont(tID, Textdraw121[playerid], TEXT_DRAW_FONT_MODEL_PREVIEW);
        PlayerTextDrawSetPreviewModel(tID, Textdraw121[playerid], pInfo[playerid][pSkin]);
        PlayerTextDrawShow(tID, Textdraw121[playerid]);

        if(pInfo[playerid][pDriverslic] == 1)
        {
            Textdraw122[playerid] = CreatePlayerTextDraw(tID, 66.285728, 184.320007, "~w~Drivers License: ~g~Valid");
            PlayerTextDrawLetterSize(tID, Textdraw122[playerid], 0.262189, 1.006932);
            PlayerTextDrawAlignment(tID, Textdraw122[playerid], 1);
            PlayerTextDrawColor(tID, Textdraw122[playerid], -1);
            PlayerTextDrawSetShadow(tID, Textdraw122[playerid], 0);
            PlayerTextDrawSetOutline(tID, Textdraw122[playerid], 1);
            PlayerTextDrawBackgroundColor(tID, Textdraw122[playerid], 51);
            PlayerTextDrawFont(tID, Textdraw122[playerid], 1);
            PlayerTextDrawSetProportional(tID, Textdraw122[playerid], 1);
            PlayerTextDrawShow(tID, Textdraw122[playerid]);
        }
        else
        {
            Textdraw122[playerid] = CreatePlayerTextDraw(tID, 66.285728, 184.320007, "~w~Drivers License: ~r~Invalid");
            PlayerTextDrawLetterSize(tID, Textdraw122[playerid], 0.262189, 1.006932);
            PlayerTextDrawAlignment(tID, Textdraw122[playerid], 1);
            PlayerTextDrawColor(tID, Textdraw122[playerid], -1);
            PlayerTextDrawSetShadow(tID, Textdraw122[playerid], 0);
            PlayerTextDrawSetOutline(tID, Textdraw122[playerid], 1);
            PlayerTextDrawBackgroundColor(tID, Textdraw122[playerid], 51);
            PlayerTextDrawFont(tID, Textdraw122[playerid], 1);
            PlayerTextDrawSetProportional(tID, Textdraw122[playerid], 1);
            PlayerTextDrawShow(tID, Textdraw122[playerid]);
        }
        if(pInfo[playerid][pBoatlic] == 1)
        {
            Textdraw123[playerid] = CreatePlayerTextDraw(tID, 66.285713, 197.546661, "~w~Boat License: ~g~Valid");
            PlayerTextDrawLetterSize(tID, Textdraw123[playerid], 0.262189, 1.006932);
            PlayerTextDrawAlignment(tID, Textdraw123[playerid], 1);
            PlayerTextDrawColor(tID, Textdraw123[playerid], -1);
            PlayerTextDrawSetShadow(tID, Textdraw123[playerid], 0);
            PlayerTextDrawSetOutline(tID, Textdraw123[playerid], 1);
            PlayerTextDrawBackgroundColor(tID, Textdraw123[playerid], 51);
            PlayerTextDrawFont(tID, Textdraw123[playerid], 1);
            PlayerTextDrawSetProportional(tID, Textdraw123[playerid], 1);
            PlayerTextDrawShow(tID, Textdraw123[playerid]);
        }
        else
        {
            Textdraw123[playerid] = CreatePlayerTextDraw(tID, 66.285713, 197.546661, "~w~Boat License: ~r~Invalid");
            PlayerTextDrawLetterSize(tID, Textdraw123[playerid], 0.262189, 1.006932);
            PlayerTextDrawAlignment(tID, Textdraw123[playerid], 1);
            PlayerTextDrawColor(tID, Textdraw123[playerid], -1);
            PlayerTextDrawSetShadow(tID, Textdraw123[playerid], 0);
            PlayerTextDrawSetOutline(tID, Textdraw123[playerid], 1);
            PlayerTextDrawBackgroundColor(tID, Textdraw123[playerid], 51);
            PlayerTextDrawFont(tID, Textdraw123[playerid], 1);
            PlayerTextDrawSetProportional(tID, Textdraw123[playerid], 1);
            PlayerTextDrawShow(tID, Textdraw123[playerid]);
        }
        if(pInfo[playerid][pFlylic] == 1)
        {
            Textdraw124[playerid] = CreatePlayerTextDraw(tID, 66.666671, 211.626678, "~w~Flying License: ~g~Valid");
            PlayerTextDrawLetterSize(tID, Textdraw124[playerid], 0.262189, 1.006932);
            PlayerTextDrawAlignment(tID, Textdraw124[playerid], 1);
            PlayerTextDrawColor(tID, Textdraw124[playerid], -1);
            PlayerTextDrawSetShadow(tID, Textdraw124[playerid], 0);
            PlayerTextDrawSetOutline(tID, Textdraw124[playerid], 1);
            PlayerTextDrawBackgroundColor(tID, Textdraw124[playerid], 51);
            PlayerTextDrawFont(tID, Textdraw124[playerid], 1);
            PlayerTextDrawSetProportional(tID, Textdraw124[playerid], 1);
            PlayerTextDrawShow(tID, Textdraw124[playerid]);
        }
        else
        {
            Textdraw124[playerid] = CreatePlayerTextDraw(tID, 66.666671, 211.626678, "~w~Flying License: ~r~Invalid");
            PlayerTextDrawLetterSize(tID, Textdraw124[playerid], 0.262189, 1.006932);
            PlayerTextDrawAlignment(tID, Textdraw124[playerid], 1);
            PlayerTextDrawColor(tID, Textdraw124[playerid], -1);
            PlayerTextDrawSetShadow(tID, Textdraw124[playerid], 0);
            PlayerTextDrawSetOutline(tID, Textdraw124[playerid], 1);
            PlayerTextDrawBackgroundColor(tID, Textdraw124[playerid], 51);
            PlayerTextDrawFont(tID, Textdraw124[playerid], 1);
            PlayerTextDrawSetProportional(tID, Textdraw124[playerid], 1);
            PlayerTextDrawShow(tID, Textdraw124[playerid]);
        }
        Textdraw125[playerid] = CreatePlayerTextDraw(tID, 84.190475, 236.800003, "~w~License Points");
        PlayerTextDrawLetterSize(tID, Textdraw125[playerid], 0.262189, 1.006932);
        PlayerTextDrawAlignment(tID, Textdraw125[playerid], 1);
        PlayerTextDrawColor(tID, Textdraw125[playerid], -1);
        PlayerTextDrawSetShadow(tID, Textdraw125[playerid], 0);
        PlayerTextDrawSetOutline(tID, Textdraw125[playerid], 1);
        PlayerTextDrawBackgroundColor(tID, Textdraw125[playerid], 51);
        PlayerTextDrawFont(tID, Textdraw125[playerid], 1);
        PlayerTextDrawSetProportional(tID, Textdraw125[playerid], 1);
        PlayerTextDrawShow(tID, Textdraw125[playerid]);

        Textdraw126[playerid] = CreatePlayerTextDraw(tID, 109.714317, 246.613342, pInfo[playerid][pLicPoints]);
        PlayerTextDrawLetterSize(tID, Textdraw126[playerid], 0.262189, 1.006932);
        PlayerTextDrawAlignment(tID, Textdraw126[playerid], 1);
        PlayerTextDrawColor(tID, Textdraw126[playerid], -1);
        PlayerTextDrawSetShadow(tID, Textdraw126[playerid], 0);
        PlayerTextDrawSetOutline(tID, Textdraw126[playerid], 1);
        PlayerTextDrawBackgroundColor(tID, Textdraw126[playerid], 51);
        PlayerTextDrawFont(tID, Textdraw126[playerid], 1);
        PlayerTextDrawSetProportional(tID, Textdraw126[playerid], 1);
        PlayerTextDrawShow(tID, Textdraw126[playerid]);

        Textdraw127[playerid] = CreatePlayerTextDraw(tID, 181.809539, 151.259994, "usebox");
        PlayerTextDrawLetterSize(tID, Textdraw127[playerid], 0.000000, 2.338148);
        PlayerTextDrawTextSize(tID, Textdraw127[playerid], 14.000000, 0.000000);
        PlayerTextDrawAlignment(tID, Textdraw127[playerid], 1);
        PlayerTextDrawColor(tID, Textdraw127[playerid], 0);
        PlayerTextDrawUseBox(tID, Textdraw127[playerid], true);
        PlayerTextDrawBoxColor(tID, Textdraw127[playerid], -268434859);
        PlayerTextDrawSetShadow(tID, Textdraw127[playerid], 0);
        PlayerTextDrawSetOutline(tID, Textdraw127[playerid], 0);
        PlayerTextDrawFont(tID, Textdraw127[playerid], 0);
        PlayerTextDrawShow(tID, Textdraw127[playerid]);

        format(string, sizeof(string), "Licenses of %s", GetName(playerid));
        Textdraw128[playerid] = CreatePlayerTextDraw(tID, 18.666662, 154.026672, string);
        PlayerTextDrawLetterSize(tID, Textdraw128[playerid], 0.290000, 1.809067);
        PlayerTextDrawAlignment(tID, Textdraw128[playerid], 1);
        PlayerTextDrawColor(tID, Textdraw128[playerid], -1);
        PlayerTextDrawSetShadow(tID, Textdraw128[playerid], 0);
        PlayerTextDrawSetOutline(tID, Textdraw128[playerid], 1);
        PlayerTextDrawBackgroundColor(tID, Textdraw128[playerid], 51);
        PlayerTextDrawFont(tID, Textdraw128[playerid], 1);
        PlayerTextDrawSetProportional(tID, Textdraw128[playerid], 1);
        PlayerTextDrawShow(tID, Textdraw128[playerid]);
       
        Textdraw129[playerid] = CreatePlayerTextDraw(tID, 122.285758, 262.826660, "/closelicenses to close");
        PlayerTextDrawLetterSize(tID, Textdraw129[playerid], 0.150190, 0.878934);
        PlayerTextDrawAlignment(tID, Textdraw129[playerid], 1);
        PlayerTextDrawColor(tID, Textdraw129[playerid], -1);
        PlayerTextDrawSetShadow(tID, Textdraw129[playerid], 0);
        PlayerTextDrawSetOutline(tID, Textdraw129[playerid], 1);
        PlayerTextDrawBackgroundColor(tID, Textdraw129[playerid], 51);
        PlayerTextDrawFont(tID, Textdraw129[playerid], 1);
        PlayerTextDrawSetProportional(tID, Textdraw129[playerid], 1);
        PlayerTextDrawShow(tID, Textdraw129[playerid]);
        gLicensesShown[tID] = true;
       
        format(string, sizeof(string), "* [SERVER]: You've shown your licenses to %s", GetName(tID));
        SCM(playerid, COLOR_WHITE, string);
    }
    return 1;
}
closelicenses command:
pawn Код:
CMD:closelicenses(playerid, params[])
{
    new tID;
    if(!gPlayerLogged[playerid]) return SCM(playerid, COLOR_GREY, NOTLOGGED);
    if(!gLicensesShown[playerid]) return SCM(playerid, COLOR_GREY, "* [ERROR]: Nobody has shown you their licenses.");
    PlayerTextDrawHide(playerid, Textdraw120[tID]);
    PlayerTextDrawHide(playerid, Textdraw121[tID]);
    PlayerTextDrawHide(playerid, Textdraw122[tID]);
    PlayerTextDrawHide(playerid, Textdraw123[tID]);
    PlayerTextDrawHide(playerid, Textdraw124[tID]);
    PlayerTextDrawHide(playerid, Textdraw125[tID]);
    PlayerTextDrawHide(playerid, Textdraw126[tID]);
    PlayerTextDrawHide(playerid, Textdraw127[tID]);
    PlayerTextDrawHide(playerid, Textdraw128[tID]);
    PlayerTextDrawHide(playerid, Textdraw129[tID]);
    gLicensesShown[playerid] = false;
    return 1;
}
Help is much appreciated!
Reply
#2

Try doing this:


pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if ((newkeys & KEY_FIRE))  //
{
   // Remove TextDraw Code Here

  }
   return 1;
}
This makes it so when you press the LMB button is closes it

If that doesnt work try using

pawn Код:
PlayerTextDrawDestroy(playerid, );
It destroys the textdraw and not hides it.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)