milliseconds conver 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: milliseconds conver to minutes and seconds (
/showthread.php?tid=662368)
milliseconds conver to minutes and seconds -
3417512908 - 30.12.2018
This is my code:
Код:
case 8455:
{
if (GetTickCount() - PlayerInfo[playerid][pLastPlay] >= 240000)
{
if(isnull(inputtext)) return SendClientMessage(playerid,COLOR_TOMATO,"请输入链接");
if(strlen(inputtext) > 256) return SendClientMessage(playerid,COLOR_TOMATO,"链接长度错误,最大为256");
foreach(new i : Player) PlayAudioStreamForPlayer(i, inputtext);
SendClientMessageToAll(COLOR_THISTLE, sprintf("[VIP]%s 为你点播了一首歌曲,希望你喜欢~",PlayerInfo[playerid][pName]));
PlayerInfo[playerid][pLastPlay] = GetTickCount();
}
else SendClientMessage(playerid,COLOR_TOMATO, sprintf("距离下次点播还剩 %d",(240000 - (GetTickCount() - PlayerInfo[playerid][pLastPlay])));
}
(240000 - (GetTickCount() - PlayerInfo[playerid][pLastPlay]) is milliseconds
How to conver it to minutes and seconds?
Re: milliseconds conver to minutes and seconds -
Calisthenics - 30.12.2018
Store milliseconds onto a variable:
pawn Код:
new mseconds = 240000 - (GetTickCount() - PlayerInfo[playerid][pLastPlay]);
you can now use in sprintf:
pawn Код:
"... %d:%d", mseconds / 60000, (mseconds / 1000) % 60);