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);
}
}
}
pawn Код:
forward FadeOut(playerid, A);
forward FadeIn(playerid, A);
//------
public FadeIn(playerid, A)
{
PlayerTextDrawBoxColor(playerid, Background[playerid], RGBToHex(0,0,0,A));
PlayerTextDrawShow(playerid, Background[playerid]);
if (A) SetTimerEx("FadeIn", DELAY, false, "id", playerid, A-1); else PlayerTextDrawHide(playerid, Background[playerid]);
return 1;
}
public FadeOut(playerid, A)
{
PlayerTextDrawBoxColor(playerid, Background[playerid], RGBToHex(0,0,0,A));
PlayerTextDrawShow(playerid, Background[playerid]);
if (A < 255) SetTimerEx("FadeOut", DELAY, false, "id", playerid, A+1);
return 1;
}