Get duration
#1

Hello, i have this stock:

pawn Код:
stock GetDuration(time)
{
    new str[32];

    if (time < 0 || time == gettime())
    {
        format(str, sizeof(str), "Never");
        return str;
    }
    else if (time < 60)
        format(str, sizeof(str), "%d seconds", time);

    else if (time >= 0 && time < 60)
        format(str, sizeof(str), "%d seconds", time);

    else if (time >= 60 && time < 3600)
        format(str, sizeof(str), (time >= 120) ? ("%d minutes") : ("%d minute"), time / 60);

    else if (time >= 3600 && time < 86400)
        format(str, sizeof(str), (time >= 7200) ? ("%d hours") : ("%d hour"), time / 3600);

    else if (time >= 86400 && time < 2592000)
        format(str, sizeof(str), (time >= 172800) ? ("%d days") : ("%d day"), time / 86400);

    else if (time >= 2592000 && time < 31536000)
        format(str, sizeof(str), (time >= 5184000) ? ("%d months") : ("%d month"), time / 2592000);

    else if (time >= 31536000)
        format(str, sizeof(str), (time >= 63072000) ? ("%d years") : ("%d year"), time / 31536000);

    strcat(str, " ago");

    return str;
}
And i use in this way:

pawn Код:
new createDate;
    cache_get_value_int(0, "RegisterDate", createDate);
    new string[128];
    format(string, sizeof(string), "Creation: %s", GetDuration(gettime() - createDate));
    SendClientMessage(playerid, -1, string);
Basically, the GetDuration stock should return how much time passed since something. I used to check how much time passed since registration date of the player.

But ingame it says: Creation: 48 yeard ago. Wtf?

P.S The RegisterDate row saves CORRECTLY the registration time/date
Reply


Messages In This Thread
Get duration - by KinderClans - 19.08.2018, 13:51
Re: Get duration - by KinderClans - 20.08.2018, 20:00
Re: Get duration - by Gammix - 20.08.2018, 23:09
Re: Get duration - by KinderClans - 20.08.2018, 23:16
Re: Get duration - by Gammix - 20.08.2018, 23:52
Re: Get duration - by KinderClans - 21.08.2018, 00:04
Re: Get duration - by Gammix - 21.08.2018, 16:19

Forum Jump:


Users browsing this thread: 1 Guest(s)