[SOLVED] Counting textdraw problems
#1

I made a textdraw, that counts the remaining jail time for the players. It works good, but when you are moving, it writes bad numbers. I tried to make this from Kye's clock.

Counting:
pawn Код:
public UpdateJailTime(playerid)
{
    format(jailtimestr,32,"%d",PlayerInfo[playerid][pJailTime]);
    TextDrawSetString(txtJailTimeDisp,jailtimestr);
}
On player gets jailed:
pawn Код:
TextDrawShowForPlayer(playerid,txtJailTimeDisp);
            UpdateJailTime(playerid);
            SetTimerEx("UpdateJailTime", 1000, 1, "i", playerid);
OnGameModeInit:
pawn Код:
txtJailTimeDisp = TextDrawCreate(605.0,40.0,"00");
    TextDrawUseBox(txtJailTimeDisp, 0);
    TextDrawFont(txtJailTimeDisp, 3);
    TextDrawSetShadow(txtJailTimeDisp,0); // no shadow
  TextDrawSetOutline(txtJailTimeDisp,2); // thickness 1
  TextDrawBackgroundColor(txtJailTimeDisp,0x000000FF);
  TextDrawColor(txtJailTimeDisp,COLOR_LIGHTRED);
  TextDrawAlignment(txtJailTimeDisp,3);
    TextDrawLetterSize(txtJailTimeDisp,0.5,1.5);
Reply
#2

first of all this isn't a 0.3 error but you need to set your textdraw a global variable for all players or it will show everybody the same numbers.

Код:
new Text:txtJailTimeDisp[MAX_PLAYERS]; // Top of teh script
and for ongamemode init use
Код:
for(new i=0; i < MAX_PLAYERS; i++)
{
txtJailTimeDisp[i] = TextDrawCreate(605.0,40.0,"00");
	TextDrawUseBox(txtJailTimeDisp[i], 0);
	TextDrawFont(txtJailTimeDisp[i], 3);
	TextDrawSetShadow(txtJailTimeDisp[i],0); // no shadow
  TextDrawSetOutline(txtJailTimeDisp[i],2); // thickness 1
  TextDrawBackgroundColor(txtJailTimeDisp[i],0x000000FF);
  TextDrawColor(txtJailTimeDisp[i],COLOR_LIGHTRED);
  TextDrawAlignment(txtJailTimeDisp[i],3);
	TextDrawLetterSize(txtJailTimeDisp[i],0.5,1.5);
}
and
Код:
public UpdateJailTime(playerid)
{
    format(jailtimestr,32,"%d",PlayerInfo[playerid][pJailTime]);
  	TextDrawSetString(txtJailTimeDisp[playerid],jailtimestr);
}
that should work i hope
Reply
#3

Thank you very much, it works now!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)