[Ajuda] Atualizar Relogio.
#1

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.
Reply
#2

https://sampwiki.blast.hk/wiki/TextDrawSetString
Reply
#3

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?
Reply
#4

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;
}
Reply
#5

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
Reply
#6

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
Reply
#7

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;
}
Reply
#8

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.
Reply
#9

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

So tem o timer do reloginho em ongamemodeinit.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)