SA-MP Forums Archive
[Ajuda] Atualizar Relogio. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Atualizar Relogio. (/showthread.php?tid=286142)



[Ajuda] Atualizar Relogio. - Lipe_Stronda - 27.09.2011

Bom, criei uns textdraws no zamaroth... ai eu fiz um de data e um de hora, o de hora eu nao sei como eu ponho para atualizar os segundos e as horas.

pawn Код:
new texto1[100], year, month, day, hour, minute, second, texto2[100];
    getdate(year, month, day);
    gettime(hour, minute, second);
    format(texto1, sizeof texto1, "Dia: %d/%d/%d", day, month, year);
    format(texto2, sizeof texto2, "Hora: %d:%d:%d", hour, minute, second);
    Textdraw0 = TextDrawCreate(496.000000, 98.000000, "Torcidas");
    TextDrawBackgroundColor(Textdraw0, 255);
    TextDrawFont(Textdraw0, 1);
    TextDrawLetterSize(Textdraw0, 0.529999, 1.800000);
    TextDrawColor(Textdraw0, -16776961);
    TextDrawSetOutline(Textdraw0, 1);
    TextDrawSetProportional(Textdraw0, 1);
    Textdraw1 = TextDrawCreate(510.000000, 114.000000, "Organizadas");
    TextDrawBackgroundColor(Textdraw1, 255);
    TextDrawFont(Textdraw1, 1);
    TextDrawLetterSize(Textdraw1, 0.500000, 1.500000);
    TextDrawColor(Textdraw1, -1);
    TextDrawSetOutline(Textdraw1, 1);
    TextDrawSetProportional(Textdraw1, 1);
    Textdraw2 = TextDrawCreate(499.000000, 133.000000, texto1);
    TextDrawBackgroundColor(Textdraw2, 255);
    TextDrawFont(Textdraw2, 1);
    TextDrawLetterSize(Textdraw2, 0.529999, 1.400000);
    TextDrawColor(Textdraw2, -16776961);
    TextDrawSetOutline(Textdraw2, 1);
    TextDrawSetProportional(Textdraw2, 1);
    Textdraw3 = TextDrawCreate(498.000000, 148.000000, texto2);
    TextDrawBackgroundColor(Textdraw3, 255);
    TextDrawFont(Textdraw3, 1);
    TextDrawLetterSize(Textdraw3, 0.500000, 1.500000);
    TextDrawColor(Textdraw3, -1);
    TextDrawSetOutline(Textdraw3, 1);
    TextDrawSetProportional(Textdraw3, 1);
Ajuda ae.


This forum requires that you wait 120 seconds between posts. Please try again in 10 seconds.


Re: [Ajuda] Atualizar Relogio. - Pharrel - 27.09.2011

https://sampwiki.blast.hk/wiki/TextDrawSetString


Re: [Ajuda] Atualizar Relogio. - Lipe_Stronda - 27.09.2011

Nгo atualizou, fiz um timer de 1 segundo

pawn Код:
forward reloginho(playerid);
public reloginho(playerid)
{
    new texto1[100], year, month, day, hour, minute, second, texto2[100];
    getdate(year, month, day);
    gettime(hour, minute, second);
    format(texto1, sizeof texto1, "%d/%d/%d", day, month, year);
    TextDrawSetString(Textdraw2, texto1);
    format(texto2, sizeof texto2, "%d:%d:%d", hour, minute, second);
    TextDrawSetString(Textdraw3, texto2);
    return 1;
}
oqe estб errado?


Re: [Ajuda] Atualizar Relogio. - Dr_Pawno - 27.09.2011

pawn Код:
forward Atualizar();
public OnGameModeInit()
{
    SetTimer("Atualizar", 1 * 1000, true); // 1 Segundo * 1000 milйsimos
    return 1;
}

public Atualizar()
{
    new texto1[64], year, month, day, hour, minute, second, texto2[64];
    getdate(year, month, day);
    gettime(hour, minute, second);
    format(texto1, sizeof texto1, "Dia: %02d/%02d/%04d", day, month, year);
    format(texto2, sizeof texto2, "Hora: %02d:%02d:%02d", hour, minute, second);
    SetTextDrawString(Textdraw2, texto1);
    SetTextDrawString(Textdraw3, texto2);
    return 1;
}



Re: [Ajuda] Atualizar Relogio. - Pharrel - 27.09.2011

pawn Код:
//public OnGameModeInit()
SetTimer("reloginho", 1000, true);

forward reloginho();
public reloginho()
{
    new texto1[15], v1, v2, v3;
    getdate(v1, v2, v3);
    format(texto1, sizeof texto1, "%02d/%02d/%d", v3, v2, v1);
    TextDrawSetString(Textdraw2, texto1);
    gettime(v1, v2, v3);
    format(texto1, sizeof texto1, "%02d:%02d:%02d", v1, v2, v3);
    TextDrawSetString(Textdraw3, texto1);
    return 1;
}
tenta assim

@edit Ninja detected ai em cima


Re: [Ajuda] Atualizar Relogio. - Lipe_Stronda - 27.09.2011

Quote:
Originally Posted by Dr_Pawno
Посмотреть сообщение
pawn Код:
forward Atualizar();
public OnGameModeInit()
{
    SetTimer("Atualizar", 1 * 1000, true); // 1 Segundo * 1000 milйsimos
    return 1;
}

public Atualizar()
{
    new texto1[64], year, month, day, hour, minute, second, texto2[64];
    getdate(year, month, day);
    gettime(hour, minute, second);
    format(texto1, sizeof texto1, "Dia: %02d/%02d/%04d", day, month, year);
    format(texto2, sizeof texto2, "Hora: %02d:%02d:%02d", hour, minute, second);
    SetTextDrawString(Textdraw2, texto1);
    SetTextDrawString(Textdraw3, texto2);
    return 1;
}
SetTextDrawString

Arrumei o codigo, mais nao deu.

@EDIT

Quote:
Originally Posted by Pharrel
Посмотреть сообщение
pawn Код:
//public OnGameModeInit()
SetTimer("reloginho", 1000, true);

forward reloginho();
public reloginho()
{
    new texto1[100], year, month, day, hour, minute, second, texto2[100];
    getdate(year, month, day);
    gettime(hour, minute, second);
    format(texto1, sizeof texto1, "%02d/%02d/%d", day, month, year);
    TextDrawSetString(Textdraw2, texto1);
    format(texto2, sizeof texto2, "%02d:%02d:%02d", hour, minute, second);
    TextDrawSetString(Textdraw3, texto2);
    return 1;
}
tenta assim

@edit Ninja detected ai em cima
O relogio nao atualizou ficou em 0:1:15


Re: [Ajuda] Atualizar Relogio. - Dr_Pawno - 27.09.2011

o %02d й sу pra coloca o texto como:
Ex: Agora й 12:01.
Se nгo tiver o %02d irб aparecer: 12:1.
Se tiver o %02d irб aparecer 12:01.

Entгo, este nгo й o erro.

Malz, й TextDrawSetString .-.

LOL, n deu??

pawn Код:
public OnPlayerConnect(playerid)
{
    TextDrawShowForPlayer(playerid, Textdraw2);
    TextDrawShowForPlayer(playerid, Textdraw3);
    return 1;
}



Re: [Ajuda] Atualizar Relogio. - Lipe_Stronda - 27.09.2011

Quote:
Originally Posted by Dr_Pawno
Посмотреть сообщение
o %02d й sу pra coloca o texto como:
Ex: Agora й 12:01.
Se nгo tiver o %02d irб aparecer: 12:1.
Se tiver o %02d irб aparecer 12:01.

Entгo, este nгo й o erro.

Malz, й TextDrawSetString .-.

LOL, n deu??

pawn Код:
public OnPlayerConnect(playerid)
{
    TextDrawShowForPlayer(playerid, Textdraw2);
    TextDrawShowForPlayer(playerid, Textdraw3);
    return 1;
}
o problema nгo й aparecer, eu ja puis isso em onplayerconnect.

o problema й que a hora fica parada, nao estб atualizando.


Re: [Ajuda] Atualizar Relogio. - Dr_Pawno - 27.09.2011

Tem outros timers antes o Atualizar ou do reloginho? Se tiver posta ae.


Re: [Ajuda] Atualizar Relogio. - Lipe_Stronda - 27.09.2011

So tem o timer do reloginho em ongamemodeinit.