Textdraw dissapears after few seconds
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
You're going over the textdraw limit because you're recreating the same textdraw over and over again without ever deleting old ones. Use TextDrawSetString instead. Much easier. Also you would probably want to have a per-player textdraw ([MAX_PLAYERS]).
What's the point of making it a per-player text draw as it's very static and public text draw which will not change at any point for any player? You're wasting per-player text draw slots there, this kind of text draws should be global ones.

Just create the needed text draws under OnGameModeInit and show/hide them when you want.

pawn Код:
new Text:td_mavseen_no,
    Text:td_mavseen_yes,
    Text:td_siren_no,
    Text:td_siren_yes,
    Text:td_mobiledatacomputer;

public OnGameModeInit()
{
    td_mavseen_no = TextDrawCreate(388.000000, 310.000000, "Visual From Sky: ~r~No");
    TextDrawBackgroundColor(td_mavseen_no, 255);
    TextDrawFont(td_mavseen_no, 1);
    TextDrawLetterSize(td_mavseen_no, 0.500000, 1.000000);
    TextDrawColor(td_mavseen_no, -16776961);
    TextDrawSetOutline(td_mavseen_no, 0);
    TextDrawSetProportional(td_mavseen_no, 1);
    TextDrawSetShadow(td_mavseen_no, 1);

    td_mavseen_yes = TextDrawCreate(388.000000, 310.000000, "Visual From Sky: ~r~Yes");
    TextDrawBackgroundColor(td_mavseen_yes, 255);
    TextDrawFont(td_mavseen_yes, 1);
    TextDrawLetterSize(td_mavseen_yes, 0.500000, 1.000000);
    TextDrawColor(td_mavseen_yes, -16776961);
    TextDrawSetOutline(td_mavseen_yes, 0);
    TextDrawSetProportional(td_mavseen_yes, 1);
    TextDrawSetShadow(td_mavseen_yes, 1);

    td_siren_no = TextDrawCreate(388.000000, 320.000000, "Siren: ~r~No");
    TextDrawBackgroundColor(td_siren_no, 255);
    TextDrawFont(td_siren_no, 1);
    TextDrawLetterSize(td_siren_no, 0.500000, 1.000000);
    TextDrawColor(td_siren_no, -16776961);
    TextDrawSetOutline(td_siren_no, 0);
    TextDrawSetProportional(td_siren_no, 1);
    TextDrawSetShadow(td_siren_no, 1);

    td_siren_yes = TextDrawCreate(388.000000, 320.000000, "Siren: ~r~Yes");
    TextDrawBackgroundColor(td_siren_yes, 255);
    TextDrawFont(td_siren_yes, 1);
    TextDrawLetterSize(td_siren_yes, 0.500000, 1.000000);
    TextDrawColor(td_siren_yes, -16776961);
    TextDrawSetOutline(td_siren_yes, 0);
    TextDrawSetProportional(td_siren_yes, 1);
    TextDrawSetShadow(td_siren_yes, 1);

    td_mobiledatacomputer = TextDrawCreate(560.000000, 312.000000, "Mobile Data Computer");
    TextDrawBackgroundColor(td_mobiledatacomputer, 255);
    TextDrawFont(td_mobiledatacomputer, 1);
    TextDrawLetterSize(td_mobiledatacomputer, 0.500000, 1.000000);
    TextDrawColor(td_mobiledatacomputer, -1);
    TextDrawSetOutline(td_mobiledatacomputer, 1);
    TextDrawSetProportional(td_mobiledatacomputer, 1);
    TextDrawUseBox(td_mobiledatacomputer, 1);
    TextDrawBoxColor(td_mobiledatacomputer, 65535);
    TextDrawTextSize(td_mobiledatacomputer, 384.000000, 165.000000);
    return 1;
}
pawn Код:
public OnPlayerUpdate(playerid)
{
    if(team[playerid] == 0)
    {
        TextDrawShowForPlayer(playerid, td_mobiledatacomputer);

        if(newmavseen == 0)
        {
            TextDrawShowForPlayer(playerid, td_mavseen_no);
        }
        else
        {
            TextDrawShowForPlayer(playerid, td_mavseen_yes);
        }

        new vid = GetPlayerVehicleID(playerid);
        if(vid && Siren[vid] == 1)
        {
            TextDrawShowForPlayer(playerid, td_siren_yes);
        }
        else
        {
            TextDrawShowForPlayer(playerid, td_siren_no);
        }
    }
    else
    {
        TextDrawHideForPlayer(playerid, td_mobiledatacomputer);
        TextDrawHideForPlayer(playerid, td_mavseen_yes);
        TextDrawHideForPlayer(playerid, td_mavseen_no);
        TextDrawHideForPlayer(playerid, td_siren_yes);
        TextDrawHideForPlayer(playerid, td_siren_no);
    }

    return 1;
}
Reply


Messages In This Thread
Textdraw dissapears after few seconds - by Sam5513 - 30.11.2012, 17:31
Re: Textdraw dissapears after few seconds - by Vince - 30.11.2012, 17:59
Re: Textdraw dissapears after few seconds - by Finn - 30.11.2012, 18:25
Re: Textdraw dissapears after few seconds - by Sam5513 - 30.11.2012, 18:50
Re: Textdraw dissapears after few seconds - by Sam5513 - 30.11.2012, 18:56
Re: Textdraw dissapears after few seconds - by Finn - 30.11.2012, 19:02
Re: Textdraw dissapears after few seconds - by Sam5513 - 30.11.2012, 19:05
Re: Textdraw dissapears after few seconds - by Finn - 30.11.2012, 22:14

Forum Jump:


Users browsing this thread: 1 Guest(s)