10.01.2014, 21:23
Nгo encontrei nenhum tipo de tutorial que ensine a criar um relуgio parecido com o do gta off.Alguem sabe onde tem um, ou me possa dar o exemplo de um ? rs, obrigado .
new Text:gText2[MAX_PLAYERS];
new horas = 0;
new minu = 0;
gText2[i] = TextDrawCreate(550.00, 20.00, " ");
TextDrawFont(gText2[i],3);
TextDrawBackgroundColor(gText2[i], 255);
TextDrawSetOutline(gText2[i], 2);
TextDrawColor(gText2[i], -1);
TextDrawLetterSize(gText2[i],0.5,2.0);
new stringr[256];
if (minu <= 9){format(stringr,25,"~w~%02d:%02d",horas,minu);}
else {format(stringr,25,"~w~%02d:%02d",horas,minu);}
TextDrawSetString(gText2[i], stringr);
}
#include a_samp
#include timerfix
new hora = 0, minuto = 0;
forward updateClock();
public OnGameModeInit() {
SetTimer("updateClock", 1000, true);
return 1;
}
public updateClock() {
minuto++;
if ( hora == 23 && minuto > 59 )
hora = 0, minuto = 0, printf("%02d:%02d", hora, minuto);
else if ( minuto > 59 )
minuto = 0, hora++, printf("%02d:%02d", hora, minuto);
else
printf("%02d:%02d", hora, minuto);
return 1;
}
pawn Код:
https://sampforum.blast.hk/showthread.php?tid=289675 |
new str[5];
format (str, 5, "%02d:%02d", hora, minuto);
TextDrawSetString(..., str);
public RELOGIM()
{
new string[128];
Min++;
if ( Hrs == 23 && Min > 59 )
{
Hrs = 0, Min = 0, format(string, sizeof string,"~g~%02d:%02d",Hrs,Min);
TextDrawSetString(Relogio, string);
return 1;
}
else if ( Min > 59 )
{
Min = 0, format(string, sizeof string,"~g~%02d:%02d",Hrs,Min);
TextDrawSetString(Relogio, string);
Hrs++;
}
else
{
format(string, sizeof string,"~g~%02d:%02d", Hrs, Min);
TextDrawSetString(Relogio, string);
return 1;
}