Page 1 of 1

convert clock time (database "records")

Posted: 23 Aug 2021, 09:51
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

Re: convert clock time (database "records")

Posted: 23 Aug 2021, 12:44
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

Re: convert clock time (database "records")

Posted: 23 Aug 2021, 15:10
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>';

Re: convert clock time (database "records")

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

Code: Select all

$aseco->formatTime($row->Temps)
a greeting

Re: convert clock time (database "records")

Posted: 24 Aug 2021, 17:16
by bern
Is there any possibility to change the colors to the time format of each numbering (red minutes) (green seconds) (yellow milliseconds)? :?:

Re: convert clock time (database "records")

Posted: 24 Aug 2021, 20:02
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)

Re: convert clock time (database "records")

Posted: 25 Aug 2021, 13:43
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 !!!

Re: convert clock time (database "records")

Posted: 30 Aug 2021, 20:18
by undef.de
:thumbsup: 8-)