Textdraws dissappear
#1

Hello guys. I've got a problem with my textdraws.. After 3-4 hours after the restart they dissappear. I create them on onplayerconnect, destroy them on onplayerdisconnect and update them every second with a custom timer.

Codes:

At top of the script:
pawn Код:
new Text:TextDrawSZ[MAX_PLAYERS];

In OnPlayerConnect:
pawn Код:
TextDrawSZ[playerid] = TextDrawCreate(89.000000, 430.000000, "SafeZone");
TextDrawAlignment(TextDrawSZ[playerid], 2);
TextDrawBackgroundColor(TextDrawSZ[playerid], 255);
TextDrawFont(TextDrawSZ[playerid], 2);
TextDrawLetterSize(TextDrawSZ[playerid], 0.230000, 1.000000);
TextDrawColor(TextDrawSZ[playerid], -1);
TextDrawSetOutline(TextDrawSZ[playerid], 1);
TextDrawSetProportional(TextDrawSZ[playerid], 1);

TextDrawHideForPlayer(playerid, TextDrawSZ[playerid]);
In OnPlayerDisconnect:
pawn Код:
TextDrawDestroy(TextDrawSZ[playerid]);
In a custom timer repeating every second:
pawn Код:
if(IsPlayerInArea(i, 1432.823, 1546.908, -2360.873, -2234.546) || IsPlayerInArea(i, 1402.4, 1577.33, -1863.458, -1737.13) || IsPlayerInArea(i, 1444.231, 1535.499, -1745.026, -1602.907) || IsPlayerInArea(i, 1398.597, 1516.485, -1038.38, -991.0071)) { TextDrawShowForPlayer(i, TextDrawSZ[i]); TextDrawShowForPlayer(i, TextDrawSZ1[i]); if(AdminDuty[i] == 0 && !IsACop(i) && !IsAMedic(i)) SetPlayerArmedWeapon(i,0); }
Is it wrong that I update them every second?
And, if it helps: After some of them dissappear, the ID of other textdraws mix.. For example i type "/logo on" which sets visible only one textdraw, but sets visible two of them. Or i type "/logo off" to hide a textdraw but it hides another one instead of the one i wanted.
Reply
#2

U should destroy them in public OnGameModeInt()
Reply
#3

Quote:
Originally Posted by $$inSane
Посмотреть сообщение
U should destroy them in public OnGameModeInt()
Destroy them in OnGameModeInit? Why? ..
Reply
#4

Quote:
Originally Posted by $$inSane
Посмотреть сообщение
U should destroy them in public OnGameModeInt()
So if the Server starts the textdraw will be deleted then the textdraw will not show.
That is the most n00b post ever. Really.
Reply
#5

You should really create the textdraws in OnGameModeInit then just use "TextDrawSetString" to change the textdraw. That way you have no chance of deleting a textdraw by mistake. That's how I'd do it anyway. Then you don't need to create a textdraw every time a player connects just change the string.
Reply
#6

Ok, for the safezone I'll do that. But I've got a speedometer made of textdraws too. If i make it out of global textdraws won't it show me the speed of another player?
Reply
#7

No, if you use a player array to store them, instead of one var.
Reply
#8

Can you give me just an example, please? I don't understand..
Reply
#9

pawn Код:
new Text:TextDrawSZ[MAX_PLAYERS];
public OnGameModeInit()
{

    for( new i; i < MAX_PLAYERS; ++i )//loop all players and create their textdraw
    {
        TextDrawSZ[i] = TextDrawCreate(89.000000, 430.000000, "SafeZone");
        TextDrawAlignment(TextDrawSZ[i], 2);
        TextDrawBackgroundColor(TextDrawSZ[i], 255);
        TextDrawFont(TextDrawSZ[i], 2);
        TextDrawLetterSize(TextDrawSZ[i], 0.230000, 1.000000);
        TextDrawColor(TextDrawSZ[i], -1);
        TextDrawSetOutline(TextDrawSZ[i], 1);
        TextDrawSetProportional(TextDrawSZ[i], 1);
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    TextDrawSetString(TextDrawSZ[playerid], "blahblah");//set textdraw to what you want

    TextDrawShowForPlayer( playerid, TextDrawSZ[playerid] );//show the textdraw
    return 1;
}

SpeedoFunc(playerid)
{
    //get player speed ect
    TextDrawSetString(TextDrawSZ[playerid], "newspeed");//update the players textrdraw

}
I know your speedo textdraw isn't the same as the "safezone" but its the same principal.
Reply
#10

Quote:
Originally Posted by Romel
Посмотреть сообщение
So if the Server starts the textdraw will be deleted then the textdraw will not show.
That is the most n00b post ever. Really.
shut up its just by mistake
its public OnGameModeExit()
Reply


Forum Jump:


Users browsing this thread: 7 Guest(s)