SA-MP Forums Archive
Convert seconds to minutes and seconds - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Convert seconds to minutes and seconds (/showthread.php?tid=487434)



Convert seconds to minutes and seconds - SomebodyAndMe - 13.01.2014

Hello,

I'm trying to convert seconds, to minutes and seconds. For example 119 seconds, would be 1 minute and 59 seconds.

How do I do that in PAWN? This is what I got so far, probably totally wrong:

pawn Код:
new string[128], timeTotal, minutes, secondss, seconds, secondsinstring;
                timeTotal = gettime() - PInfo[playerid][StartTime];
                minutes = timeTotal / 60;
                sscanf(minutes, "p<.>ii", minutes, secondss);
                format(string, sizeof(string), "0.%d", secondss);
                sscanf(string, "i", seconds);
                secondsinstring = seconds * 60;
Anyone who could help me out with this?

Thanks!


Re: Convert seconds to minutes and seconds - cessil - 13.01.2014

seconds / 60 = minutes, remainder would be seconds

new minutes = floatround(seconds / 60,floatround_floor);
new remainder = seconds % 60;


Re: Convert seconds to minutes and seconds - SomebodyAndMe - 13.01.2014

I've found the solution by using this:

http://forum.sa-mp.com/showpost.php?...&postcount=973

Though thanks for the effort.