Convert a timestamp to countdown -
ThomasTailor93 - 21.04.2012
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
Re: Convert a timestamp to countdown -
[HiC]TheKiller - 22.04.2012
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.
AW: Convert a timestamp to countdown -
ThomasTailor93 - 22.04.2012
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
Re: Convert a timestamp to countdown -
MP2 - 22.04.2012
Muted for 8 hours? O_O
AW: Convert a timestamp to countdown -
ThomasTailor93 - 22.04.2012
Цh.. It is just an example, but not the answer for my question ^^
Re: Convert a timestamp to countdown -
MP2 - 22.04.2012
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.
AW: Convert a timestamp to countdown -
ThomasTailor93 - 22.04.2012
In this case: 30000 seconds = 500 minutes = 8,3333~ hours
Now: which function (maybe as a format ?) do I need to use?
AW: Convert a timestamp to countdown -
ThomasTailor93 - 22.04.2012
//Edit: Okay, I got it!
Thanks anyway.
Regards, ThomasTailor93