milliseconds conver to minutes and seconds
#1

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?
Reply
#2

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);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)