18.08.2014, 20:13
I've just faced with very annoying "bug". I created clock system (hh : mm : ss) (textdraw) and EVERYTHING works fine, clock shows, time is correct, everything's fine. But one thing sucks. I created another system before, when you enter or exit building, screen fades in and out, and this is it! When that 'fading textdraw box' starts showing (and transparency drops, increases), black and very scaled seconds' text in the middle of screen (when fading out finishes "bugged" text disappears as well). But remember, that my hours, minutes and seconds original text in the corner of the screen is working perfectly. What the hell is happening? Here is some code:
Also, I found out, that the "bugged" text is :36 (yeah, seconds. But these seconds were when PlayerSpawn function was called.)
pawn Код:
// on the top
new PlayerText: clock[MAX_PLAYERS]; // "00:00"
new PlayerText: clock_sec[MAX_PLAYERS]; // ":00"
//- - - - - - - - - - -
stock CreatePlayerClock(playerid)
{
// Hours and minutes
clock[playerid] = CreatePlayerTextDraw(playerid,547.000000,22.000000,"00:00");
PlayerTextDrawAlignment(playerid,clock[playerid],0);
PlayerTextDrawBackgroundColor(playerid,clock[playerid],0x000000ff);
PlayerTextDrawFont(playerid,clock[playerid],3);
PlayerTextDrawLetterSize(playerid,clock[playerid],0.399999,1.700000);
PlayerTextDrawColor(playerid,clock[playerid],0xffffffff);
PlayerTextDrawSetOutline(playerid,clock[playerid],1);
PlayerTextDrawSetProportional(playerid,clock[playerid],1);
PlayerTextDrawSetShadow(playerid,clock[playerid],1);
// Seconds
clock_sec[playerid] = CreatePlayerTextDraw(playerid,586.000000,25.000000,":00");
PlayerTextDrawAlignment(playerid,clock_sec[playerid],0);
PlayerTextDrawBackgroundColor(playerid,clock_sec[playerid],0x000000ff);
PlayerTextDrawFont(playerid,clock_sec[playerid],3);
PlayerTextDrawLetterSize(playerid,clock_sec[playerid],0.299999,1.300000);
PlayerTextDrawColor(playerid,clock_sec[playerid],0xffffffff);
PlayerTextDrawSetOutline(playerid,clock_sec[playerid],1);
PlayerTextDrawSetProportional(playerid,clock_sec[playerid],1);
PlayerTextDrawSetShadow(playerid,clock_sec[playerid],1);
return 1;
}
//- - - - - - - - - - - -
stock PlayerSpawn(playerid, team, skin, Float:x,Float:y,Float:z,Float:a,g,gb,h,hb,j,jb) // this stock is called when player enters correct password and this function executes only once per player.
{
// some code not with clocks
CreatePlayerClock(playerid);
if(pInfo[playerid][clock] == 1) {PlayerTextDrawShow(playerid,clock[playerid]); PlayerTextDrawShow(playerid,clock_sec[playerid]);} // if player has a clock in his inventory...
return 1;
}
//- - - - - - -
public OnGameModeInit()
{
SetTimer("Time",100,true); // will update every player's clock
return 1;
}
public Time()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
if(pInfo[i][clock] == 1)
{
new string[20];
format(string,sizeof(string),"%02i:%02i",h,m);
PlayerTextDrawSetString(i, clock[i],string);
format(string,sizeof(string),":%02i",s);
PlayerTextDrawSetString(i, clock_sec[i],string);
}
}
}