21.07.2011, 10:52
Try this method:
a test command::
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;
}
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;
}