Mostrar Tempo do Comando -
SK00L - 15.02.2014
aew galera , queria saber como criar um tempo que fica
decrescendo e mostrando o tempo que resta ainda,tipo assim "
Ainda falta 5 min e 10 segundos para usar o comando novamente"
+Rep pra quem conseguir ajudar
Re: Mostrar Tempo do Comando -
FallweN - 15.02.2014
Basta adaptar agora
pawn Код:
new
Minuto[MAX_PLAYERS],
;
CMD:teste(playerid) {
new String[128];
format(String, 128, "Ainda Falta %02d minutos para usar o comando novamente", Minuto[playerid]);
if(Minuto[playerid] > 0)
return SendClientMessage(playerid, -1, String);
SetTimerEx("Tempo", 1000*60, true, "i", playerid);
Minuto[playerid] = 5;
return true;
}
forward Tempo(playerid);
public Tempo(playerid) {
Minuto[playerid]--;
return true;
}
Re: Mostrar Tempo do Comando -
SK00L - 15.02.2014
Quote:
Originally Posted by FallweN
Basta adaptar agora
pawn Код:
new Minuto[MAX_PLAYERS], ;
CMD:teste(playerid) { new String[128]; format(String, 128, "Ainda Falta %02d minutos para usar o comando novamente", Minuto[playerid]); if(Minuto[playerid] > 0) return SendClientMessage(playerid, -1, String);
SetTimerEx("Tempo", 1000*60, true, "i", playerid); Minuto[playerid] = 5; return true; }
forward Tempo(playerid); public Tempo(playerid) { Minuto[playerid]--; return true; }
|
Vocк sabe como aparecer os segundos junto com os minutos ? tipo "5 min e 10 segundos" ao invez de sу "5 minutos"
Re: Mostrar Tempo do Comando -
Locky_ - 15.02.2014
Tem uma forma mais simples de fazer isto, e que й bem funcional.
pawn Код:
CMD:nick(playerid) {
if(GetPVarInt(playerid, "nick_time") > gettime()) {
new T = GetPVarInt(playerid, "nick_time"), Msg[144];
if(T >= (60*60)) { // Maior que 1 hora
T = T / (60*60);
format(Msg, sizeof(Msg), "{ffff00}Use novamente daqui a %i hora%s", T, (T > 1) ? ("s") : (""));
}
else if(T >= 60) { //Maior que 1 minuto
T = T / 60;
format(Msg, sizeof(Msg), "{ffff00}Use novamente daqui a %i minuto%s!", T, (T > 1) ? ("s") : (""));
}
else
format(Msg, sizeof(Msg), "{ffff00}Use novamente daqui a %i segundo%s", T, (T > 1) ? ("s") : ("")); // Menor que 1 minuto e menor que 1 hora, ou seja, segundos.
return SendClientMessage(playerid, -1, Msg);
}
SetPVarInt(playerid, "nick_time", gettime() + 120); // tempo atual + 120 segundos (2 min).
return SendClientMessage(playerid, -1, "{ff0000}Comando de demostraзгo!");
}
Use como uma demostraзгo.
Caso queira dividir o tempo, exemplo: 1 minuto e 2 segundos.
Sу dividir o tempo da variavel. Exemplo:
pawn Код:
new Min, Hrs, Seg, Dia, Total = gettime() + (60*60*24*3); //Total = tempo atual + daqui a 3 dias
if(Total >= (60*60*24)) {
Dia = Total / (60*60*24);
Total = Total - (Dia * (60*60*24));
}
if(Total >= (60*60)) {
Hrs = Total / (60*60);
Total = Total - (Hrs* (60*60*24));
}
if(Total >= 60) {
Min = Total / 60;
Total = Total - (Min * 60);
}
Seg = Total;
//Agora se tem: Dias, Horas, Minutos, Segundos.
Isso acima й muito usado em sistemas vip e banimento.
Re: Mostrar Tempo do Comando -
SK00L - 15.02.2014
Quote:
Originally Posted by Nickvj7
Tem uma forma mais simples de fazer isto, e que й bem funcional.
pawn Код:
CMD:nick(playerid) { if(GetPVarInt(playerid, "nick_time") > gettime()) { new T = GetPVarInt(playerid, "nick_time"), Msg[144]; if(T >= (60*60)) { // Maior que 1 hora T = T / (60*60); format(Msg, sizeof(Msg), "{ffff00}Use novamente daqui a %i hora%s", T, (T > 1) ? ("s") : ("")); } else if(T >= 60) { //Maior que 1 minuto T = T / 60; format(Msg, sizeof(Msg), "{ffff00}Use novamente daqui a %i minuto%s!", T, (T > 1) ? ("s") : ("")); } else format(Msg, sizeof(Msg), "{ffff00}Use novamente daqui a %i segundo%s", T, (T > 1) ? ("s") : ("")); // Menor que 1 minuto e menor que 1 hora, ou seja, segundos. return SendClientMessage(playerid, -1, Msg); } SetPVarInt(playerid, "nick_time", gettime() + 120); // tempo atual + 120 segundos (2 min). return SendClientMessage(playerid, -1, "{ff0000}Comando de demostraзгo!"); }
Use como uma demostraзгo.
Caso queira dividir o tempo, exemplo: 1 minuto e 2 segundos.
Sу dividir o tempo da variavel. Exemplo:
pawn Код:
new Min, Hrs, Seg, Dia, Total = gettime() + (60*60*24*3); //Total = tempo atual + daqui a 3 dias if(Total >= (60*60*24)) { Dia = Total / (60*60*24); Total = Total - (Dia * (60*60*24)); } if(Total >= (60*60)) { Hrs = Total / (60*60); Total = Total - (Hrs* (60*60*24)); } if(Total >= 60) { Min = Total / 60; Total = Total - (Min * 60); } Seg = Total;
//Agora se tem: Dias, Horas, Minutos, Segundos.
Isso acima й muito usado em sistemas vip e banimento.
|
Vlw por me ensinar ,
+REP