SA-MP Forums Archive
Problem with jail time. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem with jail time. (/showthread.php?tid=270665)



Problem with jail time. - budelis - 21.07.2011

Hi all.I need some help with jail time.All is good,but i don't know how to do when player jail player for ex:3600 min.He don't get time like that:

Jail time:3600 min

But he get time like that:

JailTime:01:00:00
00:59:59
00:59:58
00:59:57

How to do that?


Re: Problem with jail time. - iPLEOMAX - 21.07.2011

Try this method:

pawn Код:
public OnFilterScriptInit()
{
    new sec = 120; // 120 here is the value of the input seconds
    //Change this into your required value...

    printf("Day(s):  %i ", (sec/(24*60*60))); //Converting second into Day: sec divided by 24*60*60
    printf("Hour(s): %i ", (sec/(60*60))%24); //similar way..
    printf("Minute(s):  %i ", (sec/60)%60); //here too..
    printf("Second(s):  %i ", sec%60); //and here...
   
    return true;
}
a test command::

pawn Код:
CMD:formatseconds(playerid, cmdtext[])
{
    new seconds;
    if (sscanf (cmdtext, "i", seconds) return SendClientMessage(playerid, -1, "Usage: /formatseconds [seconds]");
   
    new string[32];

    format(string, sizeof(string), "Days: %i ", (seconds/(24*60*60)) );
    SendClientMessage(playerid, -1, string);

    format(string, sizeof(string), "Hours: %i ", (sec/(60*60))%24 );
    SendClientMessage(playerid, -1, string);

    format(string, sizeof(string), "Minutes: %i ", (sec/60)%60 );
    SendClientMessage(playerid, -1, string);

    format(string, sizeof(string), "Seconds: %i ", sec%60 );
    SendClientMessage(playerid, -1, string);

    return true;
}