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.