Thread: [Solved] Get remain time problem
View Single Post
Author Message
loiraolhosazul
Member
Join Date: May 2020
Old 08-21-2021 , 20:28   Get remain time problem
Reply With Quote #1

I'm trying to get the rest of the hour, but I'm in trouble.

HTML Code:
Now: 20 horas 26 minutos 50 segundos
Remain: 0 hora -60 minuto 0 segundo
Code:
public xdxd()
{
	new h, m, s, i, mm, d, now, start, discount, remain_time, gethours[3], xfmt[128]

	time(gethours[0], gethours[1], gethours[2])

	start = 22
	discount = floatround(float(start - gethours[0]), floatround_ceil)

	now = get_systime()
	remain_time = get_systime(3600 * discount) - now


	UnixToTime(now, i, mm, d, h, m, s, UT_TIMEZONE_SERVER)
	formatex(xfmt, charsmax(xfmt), "Now: %d hora%s %d minuto%s %d segundo%s", h, h > 1 ? "s" : "", m, m > 1 ? "s" : "", s, s > 1 ? "s" : "")
	
	server_print(xfmt)


	UnixToTime(remain_time, i, mm, d, h, m, s, UT_TIMEZONE_SERVER)
	formatex(xfmt, charsmax(xfmt), "Remain: %d hora%s %d minuto%s %d segundo%s", h, h > 1 ? "s" : "", m, m > 1 ? "s" : "", s, s > 1 ? "s" : "")
	
	server_print(xfmt)
}

Last edited by loiraolhosazul; 08-21-2021 at 21:38.
loiraolhosazul is offline