Convert a timestamp to countdown
#1

Hello guys,

I want to convert a timestamp to a hour, minute and second countdown in SA:MP, (xx hours, xxminutes and xxseconds left to the next period) but I don't know how. Does anyone know, how it works? I thanks for any reply.

Regards, ThomasTailor93

------------------------------------------------------------------------------------------

Ok, well. I think, I need to explain a bit more (just my fault for bad explanation).

I've muted a guy for 500 minutes (~ 8,3** hours).

Time, when I muted him: 1335060000 (4:00am CET)
Time, when he become unmuted: 1335090000 (12:20pm CET)

Now It is 5:00am CET and the muted guy wants to know, how long he is muted. So he checks it with /mutetime and the server will tell: "You are in 7 hours, 20 minutes and 0 seconds unmuted."

I really don't know how to do it in PAWN. I hope, anyone can help me.

Regards, ThomasTailor93
Reply
#2

pawn Код:
stock Countdown(&hours, &minutes, &seconds, countdown)
{
    new count = countdown - gettime();
    while(count > 3600)
    {
        hours ++;
        count = count - 3600;
    }
    while(count > 60)
    {
        minutes ++;
        count = count - 60;
    }
    seconds = count;
    retrun 1;
}
Do you mean something along the lines of that? Returns the hours, minutes and seconds from the current timestamp to the one specified.
Reply
#3

Ok, well. I think, I need to explain a bit more (just my fault for bad explanation).

I've muted a guy for 500 minutes (~ 8,3** hours).

Time, when I muted him: 1335060000 (4:00am CET)
Time, when he become unmuted: 1335090000 (12:20pm CET)

Now It is 5:00am CET and the muted guy wants to know, how long he is muted. So he checks it with /mutetime and the server will tell: "You are in 7 hours, 20 minutes and 0 seconds unmuted."

I really don't know how to do it in PAWN. I hope, anyone can help me.

Regards, ThomasTailor93
Reply
#4

Muted for 8 hours? O_O
Reply
#5

Цh.. It is just an example, but not the answer for my question ^^
Reply
#6

Well first you need to get the number of seconds left, so do time_he_will_be_unmuted-gettime(), that will give you how many seconds are left, then divide by 60 to find out how many hours, then use modulo (%) to find out how many minutes/seconds.
Reply
#7

In this case: 30000 seconds = 500 minutes = 8,3333~ hours

Now: which function (maybe as a format ?) do I need to use?
Reply
#8

//Edit: Okay, I got it!

Thanks anyway.

Regards, ThomasTailor93
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)