convert clock time (database "records")

UASECO is a fork of the XAseco2/1.03 controller for Trackmania and has been overhauled to support the Modescript Gamemodes of Trackmania².

Moderators: undef.de, NADEO

Post Reply
User avatar
bern
Posts: 121
Joined: 26 Dec 2013, 21:38
Contact:

convert clock time (database "records")

Post by bern »

Is there any chain or formula to change the data in the "records" database and present it in the game panel in clock (time) format ?
regards.
Bern
User avatar
undef.de
Posts: 2095
Joined: 06 Apr 2011, 21:57
Location: Germany, North Sea Coast
Contact:

Re: convert clock time (database "records")

Post by undef.de »

bern wrote: 23 Aug 2021, 09:51 Is there any chain or formula to change the data in the "records" database and present it in the game panel in clock (time) format ?
regards.
Bern
You mean you want to change the format how it is stored in the database? If true, there is no need (and no reason) to change that, because if you request data from the database you can get every format you want within the SQL request: https://www.w3schools.com/mysql/func_my ... format.asp
Developer of UASECO, a controller with support of the Modescript Gamemodes for TM².
Visit the official website for more: UASECO.org


Developer of various plugins for XAseco/XAseco2 and MPAseco, visit my lab: www.undef.name

You like what I do? Then award a ManiaStar.
User avatar
bern
Posts: 121
Joined: 26 Dec 2013, 21:38
Contact:

Re: convert clock time (database "records")

Post by bern »

undef.de wrote: 23 Aug 2021, 12:44
bern wrote: 23 Aug 2021, 09:51 Is there any chain or formula to change the data in the "records" database and present it in the game panel in clock (time) format ?
regards.
Bern
You mean you want to change the format how it is stored in the database? If true, there is no need (and no reason) to change that, because if you request data from the database you can get every format you want within the SQL request: https://www.w3schools.com/mysql/func_my ... format.asp
I don't know if I have explained myself well, I never learned English ^^
I put a photo of what I would like to appear in the game
Image

Could this be the possible code? $formatTime

Code: Select all

$xml .='<label pos="59 '. $hauteur .'" z-index="0.005" size="30 7.5" textcolor="FFF" halign="right" style="TextSPScoreMedium" text="' . $formatTime. $row->Temps.'"></label>';
User avatar
bern
Posts: 121
Joined: 26 Dec 2013, 21:38
Contact:

Re: convert clock time (database "records")

Post by bern »

I found the correct code ...... :3

Code: Select all

$aseco->formatTime($row->Temps)
a greeting
User avatar
bern
Posts: 121
Joined: 26 Dec 2013, 21:38
Contact:

Re: convert clock time (database "records")

Post by bern »

Is there any possibility to change the colors to the time format of each numbering (red minutes) (green seconds) (yellow milliseconds)? :?:
User avatar
undef.de
Posts: 2095
Joined: 06 Apr 2011, 21:57
Location: Germany, North Sea Coast
Contact:

Re: convert clock time (database "records")

Post by undef.de »

bern wrote: 24 Aug 2021, 09:42 I found the correct code ...... :3

Code: Select all

$aseco->formatTime($row->Temps)
bern wrote: 24 Aug 2021, 17:16 Is there any possibility to change the colors to the time format of each numbering (red minutes) (green seconds) (yellow milliseconds)? :?:

Untested... but should do it.:

Paste the function formatTimeColored() into your plugin...

Code: Select all

private function formatTimeColored ($MwTime) {

	if ($MwTime > 0) {
		$tseconds = ((strlen($MwTime) > 3) ? substr($MwTime, strlen($MwTime)-3) : $MwTime);
		$MwTime = floor($MwTime / 1000);
		$hours = floor($MwTime / 3600);
		$MwTime = $MwTime - ($hours * 3600);
		$minutes = floor($MwTime / 60);
		$MwTime = $MwTime - ($minutes * 60);
		$seconds = floor($MwTime);
		if ($tsec) {
			if ($hours) {
				return sprintf('$F00%d$FFF:$0C0%02d$FFF:$FF0%02d$FFF.$FF0%03d', $hours, $minutes, $seconds, $tseconds);
			}
			else {
				return sprintf('$F00%d$FFF:$0C0%02d$FFF.$FF0%03d', $minutes, $seconds, $tseconds);
			}
		}
		else {
			if ($hours) {
				return sprintf('$F00%d$FFF:$0C0%02d$FFF:$FF0%02d', $hours, $minutes, $seconds);
			}
			else {
				return sprintf('$F00%d$FFF:$0C0%02d', $minutes, $seconds);
			}
		}
	}
	else {
		return '0:00:000';
	}
}
... and call:

Code: Select all

$this->formatTimeColored($row->Temps)
Developer of UASECO, a controller with support of the Modescript Gamemodes for TM².
Visit the official website for more: UASECO.org


Developer of various plugins for XAseco/XAseco2 and MPAseco, visit my lab: www.undef.name

You like what I do? Then award a ManiaStar.
User avatar
bern
Posts: 121
Joined: 26 Dec 2013, 21:38
Contact:

Re: convert clock time (database "records")

Post by bern »

undef.de wrote: 24 Aug 2021, 20:02
bern wrote: 24 Aug 2021, 09:42 I found the correct code ...... :3

Code: Select all

$aseco->formatTime($row->Temps)
bern wrote: 24 Aug 2021, 17:16 Is there any possibility to change the colors to the time format of each numbering (red minutes) (green seconds) (yellow milliseconds)? :?:

Untested... but should do it.:

Paste the function formatTimeColored() into your plugin...

Code: Select all

private function formatTimeColored ($MwTime) {

	if ($MwTime > 0) {
		$tseconds = ((strlen($MwTime) > 3) ? substr($MwTime, strlen($MwTime)-3) : $MwTime);
		$MwTime = floor($MwTime / 1000);
		$hours = floor($MwTime / 3600);
		$MwTime = $MwTime - ($hours * 3600);
		$minutes = floor($MwTime / 60);
		$MwTime = $MwTime - ($minutes * 60);
		$seconds = floor($MwTime);
		if ($tsec) {
			if ($hours) {
				return sprintf('$F00%d$FFF:$0C0%02d$FFF:$FF0%02d$FFF.$FF0%03d', $hours, $minutes, $seconds, $tseconds);
			}
			else {
				return sprintf('$F00%d$FFF:$0C0%02d$FFF.$FF0%03d', $minutes, $seconds, $tseconds);
			}
		}
		else {
			if ($hours) {
				return sprintf('$F00%d$FFF:$0C0%02d$FFF:$FF0%02d', $hours, $minutes, $seconds);
			}
			else {
				return sprintf('$F00%d$FFF:$0C0%02d', $minutes, $seconds);
			}
		}
	}
	else {
		return '0:00:000';
	}
}
... and call:

Code: Select all

$this->formatTimeColored($row->Temps)
First of all thanks for the support and resolution of the problem :)
I have changed your code a bit to add "day" "hour" "minutes" "seconds" "milliseconds"
Because in the league of teams and nations enters the format "day"

Code: Select all

	private function formatTimeColored ($MwTime) {

	if ($MwTime > 0) {
		$tseconds = ((strlen($MwTime) > 3) ? substr($MwTime, strlen($MwTime)-3) : $MwTime);
		$MwTime = floor($MwTime / 1000);
		$days = floor($MwTime / 86400);
		$MwTime = $MwTime - ($days * 86400);		
		$hours = floor($MwTime / 3600);
		$MwTime = $MwTime - ($hours * 3600);
		$minutes = floor($MwTime / 60);
		$MwTime = $MwTime - ($minutes * 60);
		$seconds = floor($MwTime);
		if ($tseconds) {
			if ($days) {
				return sprintf('$FF9%d$FFF:$FFF%02d$FFF:$FF9%02d$FFF:$FFC%03d', $days, $hours, $minutes, $seconds, $tseconds);
			}
			else {
				return sprintf('$FF9%d$FFF:$FFF%02d$FFF:$FF9%02d$FFF:$FFC%03d', $hours, $minutes, $seconds, $tseconds);
			}
		}
	}
	else {
		return '0:00:00:000';
	}
}
And as it is with the changes

Image

all perfect !!! :thumbsup: :clap:
Just wait for some players who suffer with the colors !!!
User avatar
undef.de
Posts: 2095
Joined: 06 Apr 2011, 21:57
Location: Germany, North Sea Coast
Contact:

Re: convert clock time (database "records")

Post by undef.de »

:thumbsup: 8-)
Developer of UASECO, a controller with support of the Modescript Gamemodes for TM².
Visit the official website for more: UASECO.org


Developer of various plugins for XAseco/XAseco2 and MPAseco, visit my lab: www.undef.name

You like what I do? Then award a ManiaStar.
Post Reply

Return to “UASECO”

Who is online

Users browsing this forum: No registered users and 4 guests