Convert seconds help/improve
#1

Hello,
So, can someone help me make 00:00:00 format for afk timer?
Thanks.

Код:
stock ConvertSeconds(time)
{
    new string[128];
    if(time < 60) format(string, sizeof(string), "%d seconds", time);
    else if(time == 60) string = "1 minūte";
    else if(time > 60 && time < 3600)
    {
        new Float: minutes;
        new seconds;
        minutes = time / 60;
        seconds = time % 60;
        format(string, sizeof(string), "%.0f minutes %d seconds", minutes, seconds);
    }
    else if(time == 3600) string = "1 hour";
    else if(time > 3600)
    {
        new Float: hours;
        new minutes_int;
        new Float: minutes;
        new seconds;
        hours = time / 3600;
        minutes_int = time % 3600;
        minutes = minutes_int / 60;
        seconds = minutes_int % 60;
        format(string, sizeof(string), "%.0f:%.0f:%d", hours, minutes, seconds);
    }
    return string;
}
PS. If someone didn't understand, to timer counts hours:minuteseconds, like 00:05:12.
Reply
#2

The timer should increase or decrease?

I think it should increase so try this:

Код:
    stock ConvertTime(time)
    {
     new minutes = (time % (1000*60*60)) / (1000*60);
     new seconds = ((time % (1000*60*60)) % (1000*60)) / 1000;
     new ms = time - (minutes*60*1000) - (seconds*1000);
     new str[128];

         format(str,sizeof(str),"%02d:%02d.%03d",minutes,seconds,ms);
        return str;
    }
Reply
#3

Quote:
Originally Posted by SpikY_
Посмотреть сообщение
The timer should increase or decrease?

I think it should increase so try this:

Код:
    stock ConvertTime(time)
    {
     new minutes = (time % (1000*60*60)) / (1000*60);
     new seconds = ((time % (1000*60*60)) % (1000*60)) / 1000;
     new ms = time - (minutes*60*1000) - (seconds*1000);
     new str[128];

         format(str,sizeof(str),"%02d:%02d.%03d",minutes,seconds,ms);
        return str;
    }
Thanks, I'll try it later, I have to check it with another player. Anyway, thanks for help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)