Plugin: Rounds finish panel mod

Discuss everything about Xymph's Aseco flavoured server control scripts for TM Forever / classic TMN and for TM² Canyon.

Moderators: Xymph, TM-Patrol

eekcage
cyclist
cyclist
Posts: 41
Joined: 19 Apr 2008 13:52
Owned TM-games: TMUF

Plugin: Rounds finish panel mod

Post by eekcage » 19 Dec 2008 17:49

Hey all,

I chucked this together to make a nice Xmass change for the dark dark rounds finish panel. One hell of a code mess. Not had the decency to clean for you guys sry. If somebody has some time to look over and replace my bad lines with 'tidy' code, please do.

Oh noo can't make a printscreen with my KVM :) oh wait can with on screen keyboard..
Image

Note's
  • the existing black panel only removes after a mapchange
  • I only stripped $n(narrow) to invoke it as standard later but it looks better off.
  • The rpoints (10,6,4,3,2, .... didn't have time to find out Get so i Set - improvement for next


earlymorning edit: I just added this to make times resort ascending. Other tweeks 1.7 text for names looks much better

Code: Select all

foreach ($round_times as $key => $row) {
    $BestTime[$key]  = $row['BestTime'];
    $NickName[$key] = $row['NickName'];
}
array_multisort($BestTime, SORT_ASC, $round_times);

Code: Select all

<?php
//////////////////////////////////////////////////////////////////////////////////////////
//Replacement for the black rounds finish panel .. work in prog
//<plugin>plugin.nicofinish.php</plugin>
//////////////////////////////////////////////////////////////////////////////////////////

Aseco::registerEvent("onBeginRound", "nico_finish_clear");
Aseco::registerEvent('onNewChallenge', 'nico_finish_clear');
Aseco::registerEvent('onPlayerFinish', 'store_time');
Aseco::registerEvent('onPlayerFinish', 'nico_finish');
Aseco::registerEvent('onStartup', 'Startupcustomui');
Aseco::registerEvent('onEndRace', 'nico_finish_clear');

//////////////////////////////////////////////////////////////////////////////////////////
// Xaseco only 4 moment - only updates on nextmap after load

		function Startupcustomui(){
		setCustomUIField('round_scores', false);	

	}
//////////////////////////////////////////////////////////////////////////////////////////
// On finish - rounds only save times


function store_time($aseco, $finish_item) {
	global $round_times;
	global $round_finishes;
		
	if (($aseco->server->gameinfo->mode == 0 ||
	     $aseco->server->gameinfo->mode == 2 ||
	     $aseco->server->gameinfo->mode == 5) && $finish_item->score > 0) {
		$round_times[$finish_item->player->login] = $finish_item->score;
		$round_finishes++;
}
}  // f end


//////////////////////////////////////////////////////////////////////////////////////////
// On finish
function nico_finish($aseco, $finish_item) {
	
	global $rounds_count, $round_times, $round_finishes, $rpointsnico; 

	$maniapos = -1;	
	$linkmaniapos = -0.2;
	$linkmaniapos2 = -0;
	$xml = '<manialinks><manialink id="3849955">';
	$xml .= '<frame posn="68.2 15 0">';
	$rpointinc = 0;
	$strip = "$n";

foreach ($round_times as $key => $row) {
    $BestTime[$key]  = $row['BestTime'];
    $NickName[$key] = $row['NickName'];
}
array_multisort($BestTime, SORT_ASC, $round_times);

foreach($round_times as $pl => $tm){
			if ($player = $aseco->server->players->getPlayer($pl))
				$nick = $player->nickname;
			else  // fall back on login
				$nick = $pl;
			$new = false;

	$namestriped = str_replace($strip, "", $nick);

//I suck at code :)
$rpointinc++;
$linkmaniapos--;
	$linkmaniapos--;
	$linkmaniapos--;
$linkmaniapos2--;
	$linkmaniapos2--;
	$linkmaniapos2--;
$maniapos--;
	$maniapos--;
	$maniapos--;

if ($rpointinc <= 12) {  //set max 12

$xml .= '<format textsize="1"/><label posn="-19.3 ' . $linkmaniapos. ' 1.5" sizen="30 3 2" halign="center" text="$0f0$o+' . $rpointsnico[$rpointinc] . ' "/>';
$xml .= '<format textsize="1"/><label posn="-27.5 ' . $linkmaniapos . ' 1.5" sizen="30 3 2" halign="left" text="$000$o' . formatTime($tm) . ' "/>';	
$xml .= '<format textsize="1.7"/><label posn="-16.5 ' . $linkmaniapos . ' 1.6" sizen="12 3 2" halign="left" text="$000' . $namestriped . ' "/>';
$xml .= '<quad sizen="6.2 3" posn="-24.9 ' . $maniapos . ' 1"  valign="center" halign="center" style="BgsPlayerCard" substyle="BgRacePlayerName" />';
$xml .= '<quad sizen="4 3" posn="-19.6 ' . $maniapos . ' 1"  valign="center" halign="center" style="BgsPlayerCard" substyle="BgRacePlayerName" />';
$xml .= '<quad sizen="17 3" posn="-17.4 ' . $maniapos . ' 1.1"  valign="center" halign="left" style="BgsPlayerCard" substyle="BgRacePlayerName" />';
$xml .= '<quad sizen="6.2 3" posn="-24.9 ' . $maniapos . ' 1"  valign="center" halign="center" style="BgsPlayerCard" substyle="BgRacePlayerName" />';
$xml .= '<quad sizen="4 3" posn="-19.6 ' . $maniapos . ' 1"  valign="center" halign="center" style="BgsPlayerCard" substyle="BgRacePlayerName" />';
$xml .= '<quad sizen="17 3" posn="-17.4 ' . $maniapos . ' 1.1"  valign="center" halign="left" style="BgsPlayerCard" substyle="BgRacePlayerName" />';

//$xml .= '<quad sizen="0.7 36.2" posn="-28.3 -20.5  1"  valign="center" halign="center" style="Bgs1InRace" substyle="BgTitle2" />'; // looks sh1t
}
else {
}
}

$xml .= '</frame>';
$xml .= '</manialink></manialinks>';
$aseco->client->query("SendDisplayManialinkPage", $xml, 0, false);

} //f end


//////////////////////////////////////////////////////////////////////////////////////////
// clear mania and reset times

function nico_finish_clear($aseco) {

	global $round_times, $round_finishes, $rpointsnico;
		$xml = '<manialinks><manialink id="3849955"></manialink></manialinks>';
		$aseco->client->query("SendDisplayManialinkPage", $xml, 1, false);
	$round_finishes = -1;
/////////////////////////////////////////////////////////////////////////////////////////
		// Set point array, Get in future
		$rpointsnico = array (0, 10, 6, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
			// & clear times
			$round_times = array();
} //f end

?>
Ugly :roflol: but works fine

edit: um, should add its only for TMF for the moment.. not even sure if you can disable the rounds panel custom_ui in TMN
Last edited by eekcage on 20 Dec 2008 13:45, edited 2 times in total.

acrox999
tricycle manager
tricycle manager
Posts: 27
Joined: 13 Dec 2008 07:23
Owned TM-games: Nations Forever, DS
Location: Selangor, Malaysia
Contact:

Re: Plugin: Rounds finish panel mod

Post by acrox999 » 20 Dec 2008 11:07

That is sooooooooooo nice!!!!!!!!!!!!!!!!! :thumbsup: :3 :3 :3
Join TrackMania Unity now! Be one of us!
For Malaysian, join the first Malaysia dedicated server ever!!! Join Malaysia Forever server now!

nouseforname
swift roadking
swift roadking
Posts: 840
Joined: 20 Apr 2008 08:58
Owned TM-games: TMUF,TMNF, TMN
Manialink(s): therookies
Location: Germany
Contact:

Re: Plugin: Rounds finish panel mod

Post by nouseforname » 17 Jan 2009 17:08

i use it now a few days, looks nice and works.
just now i recognized an error in logfile which is there all the time it seems.

Code: Select all

[PHP Warning] array_multisort(): Argument #1 is expected to be an array or a sort flag on line 56 in file /TMN/xasecoHL/plugins/plugin.nicofinish.php
any idea?
Owner of the Rookie servers and some more. :)
Rookies HP
My Project
Rookies Manialinkcolor>

Bueddl
speedy pilot
speedy pilot
Posts: 458
Joined: 05 Apr 2008 12:37
Owned TM-games: TMO, TMS, TMU/N(F)
Location: Germany
Contact:

Re: Plugin: Rounds finish panel mod

Post by Bueddl » 10 Feb 2009 18:34

nouseforname wrote:i use it now a few days, looks nice and works.
just now i recognized an error in logfile which is there all the time it seems.

Code: Select all

[PHP Warning] array_multisort(): Argument #1 is expected to be an array or a sort flag on line 56 in file /TMN/xasecoHL/plugins/plugin.nicofinish.php
any idea?

Code: Select all

array_multisort($BestTime, SORT_ASC, $round_times);
about line 56 in /plugins/plugin.nicofinish.php

bug fixed, replace the line below with:

Code: Select all

if (is_array($BestTime)) {
	array_multisort($BestTime, SORT_ASC, $round_times);
}
to disable the default roundspanel, open includes/manialinks.inc.php and...

find the line:

Code: Select all

	       '<round_scores visible="' . bool2text($ml_custom_ui['round_scores']) . '"/>' .
it is about the last 10 lines. and change to:

Code: Select all

	       '<round_scores visible="false"/>' .
then save. now it should not be displayed any more and you have a free view on the new plugin :D
cause of that we can make the new panel for the roundspoints transparent

and make it look like this:

WARNING: YOU HAVE TO ENABLE THE RPOINTS PLUGIN IN pluginx.xml!
Image

in this version it takes without chaning the code of the plugin to current given points, perhaps, if you change the pointsarray or set one in plugins.rpoints.php, SO no change is now needed in the plugin, it takes automatically the given points.

Code: Select all

<?php
//////////////////////////////////////////////////////////////////////////////////////////
//Replacement for the black rounds finish panel .. work in prog
//<plugin>plugin.nicofinish.php</plugin>
//////////////////////////////////////////////////////////////////////////////////////////

Aseco::registerEvent("onBeginRound", "nico_finish_clear");
Aseco::registerEvent('onNewChallenge', 'nico_finish_clear');
Aseco::registerEvent('onPlayerFinish', 'nico_finish_store_time');
Aseco::registerEvent('onPlayerFinish', 'nico_finish');
Aseco::registerEvent('onStartup', 'nico_finishStartupcustomui');
Aseco::registerEvent('onEndRace', 'nico_finish_clear');

//////////////////////////////////////////////////////////////////////////////////////////
// Xaseco only 4 moment - only updates on nextmap after load

      function nico_finishStartupcustomui(){
      setCustomUIField('round_scores', false);   

   }
//////////////////////////////////////////////////////////////////////////////////////////
// On finish - rounds only save times


function nico_finish_store_time($aseco, $finish_item) {
   global $round_times;
   global $round_finishes;
      
   if (($aseco->server->gameinfo->mode == 0 ||
        $aseco->server->gameinfo->mode == 2 ||
        $aseco->server->gameinfo->mode == 5) && $finish_item->score > 0) {
      $round_times[$finish_item->player->login] = $finish_item->score;
      $round_finishes++;
}
}  // f end


//////////////////////////////////////////////////////////////////////////////////////////
// On finish
function nico_finish($aseco, $finish_item) {
   
   global $rounds_count, $round_times, $round_finishes, $rpointsnico;

   $maniapos = -1;   
   $linkmaniapos = -0.2;
   $linkmaniapos2 = -0;
   $xml = '<manialinks><manialink id="3849955">';
   $xml .= '<frame posn="68.2 15 0">';
   $rpointinc = 0;
   $strip = "$n";

foreach ($round_times as $key => $row) {
    $BestTime[$key]  = $row['BestTime'];
    $NickName[$key] = $row['NickName'];
}
if (is_array($BestTime)) {
	array_multisort($BestTime, SORT_ASC, $round_times);
}

foreach($round_times as $pl => $tm){
			 if ($player = $aseco->server->players->getPlayer($pl))
				$nick = $player->nickname;
			 else  // fall back on login
				$nick = $pl;
			 $new = false;

	   $namestriped = str_replace($strip, "", $nick);

	//I suck at code :)
	$rpointinc++;
	$linkmaniapos--;
	   $linkmaniapos--;
	   $linkmaniapos--;
	$linkmaniapos2--;
	   $linkmaniapos2--;
	   $linkmaniapos2--;
	$maniapos--;
	   $maniapos--;
	   $maniapos--;

	if ($rpointinc <= 12) {  //set max 12

		$xml .= '<format textsize="1"/><label posn="-19.3 ' . $linkmaniapos. ' 1.5" sizen="30 3 2" scale="0.3" style="TextRaceChrono" halign="center" text="$s$0f0+'.$rpointsnico[$rpointinc-1] .' "/>';
		$xml .= '<format textsize="1"/><label posn="-27.5 ' . $linkmaniapos . ' 1.5" sizen="30 3 2" halign="left" scale="0.3" style="TextRaceChrono" text="$s$fff'.formatTime($tm).' "/>';   
		$xml .= '<format textsize="1.7"/><label posn="-16.5 ' . $linkmaniapos . ' 1.6" sizen="12 3 2" halign="left" text="$000' . $namestriped . ' "/>';

		$xml .= '<quad sizen="4 3" posn="-19.6 ' . $maniapos . ' 1"  valign="center" halign="center" style="Bgs1InRace" substyle="NavButton" />';
		$xml .= '<quad sizen="6.2 3" posn="-24.9 ' . $maniapos . ' 1"  valign="center" halign="center" style="Bgs1InRace" substyle="NavButton" />';
		$xml .= '<quad sizen="17 3" posn="-17.4 ' . $maniapos . ' 1.1"  valign="center" halign="left" style="Bgs1InRace" substyle="NavButton"/>';
	} else {
	}
}

$xml .= '</frame>';
$xml .= '</manialink></manialinks>';
$aseco->client->query("SendDisplayManialinkPage", $xml, 0, false);

} //f end


//////////////////////////////////////////////////////////////////////////////////////////
// clear mania and reset times

function nico_finish_clear($aseco) {
   global $rounds_points;
   global $round_times, $round_finishes, $rpointsnico;
      $xml = '<manialinks><manialink id="3849955"></manialink></manialinks>';
      $aseco->client->query("SendDisplayManialinkPage", $xml, 1, false);
   $round_finishes = -1;
/////////////////////////////////////////////////////////////////////////////////////////
      // Set point array, Get in future
	  $system = $aseco->settings['default_rpoints'];
	  $rpointsnico = $rounds_points[$system][1];
         $round_times = array();
} //f end
?>
have fun using this modification of nicos plugin ;-)

Edited: no problems now with same function names ;-)
Last edited by Bueddl on 18 Feb 2009 16:25, edited 1 time in total.

ods
pedestrian
pedestrian
Posts: 14
Joined: 14 Jan 2009 20:15
Owned TM-games: TMO TMS TMN TMUF NDS
Manialink(s): DD

Re: Plugin: Rounds finish panel mod

Post by ods » 15 Feb 2009 19:06

I have install the Plugin and in the Manialink.php from includes i have make it to False.
But if i drive on my server a Round, the panel comes for 1 sek.
not stay to End of Round. Why ??

Plz Help me

THX

User avatar
Basskid
road tourist
road tourist
Posts: 81
Joined: 07 Sep 2008 12:40
Owned TM-games: TMO, TMS, TMN, TMUF
Manialink(s): Basskid, mwl, 100k, bk.ladder
Location: Germany
Contact:

Re: Plugin: Rounds finish panel mod

Post by Basskid » 15 Feb 2009 21:57

I've got following Error
Image

The Code is the same of Bueddls Post (i like the Style of it...) manialinks.inc.php edited like Bueddl say... Rpoints Plugin activated.

Any Idea?

BBMV
sunday driver
sunday driver
Posts: 55
Joined: 18 Dec 2008 11:48
Owned TM-games: TMUF, TMS, TMO, TM2
Location: Germany -> Hessen -> Wiesbaden

Re: Plugin: Rounds finish panel mod

Post by BBMV » 16 Feb 2009 00:05

Try both please in your plugins list to disable plugin.rounds

<!-- <plugin>plugin.rounds.php</plugin> --> ;-)

User avatar
Basskid
road tourist
road tourist
Posts: 81
Joined: 07 Sep 2008 12:40
Owned TM-games: TMO, TMS, TMN, TMUF
Manialink(s): Basskid, mwl, 100k, bk.ladder
Location: Germany
Contact:

Re: Plugin: Rounds finish panel mod

Post by Basskid » 16 Feb 2009 01:13

Thx :D

User avatar
Basskid
road tourist
road tourist
Posts: 81
Joined: 07 Sep 2008 12:40
Owned TM-games: TMO, TMS, TMN, TMUF
Manialink(s): Basskid, mwl, 100k, bk.ladder
Location: Germany
Contact:

Re: Plugin: Rounds finish panel mod

Post by Basskid » 16 Feb 2009 07:51

ods wrote:I have install the Plugin and in the Manialink.php from includes i have make it to False.
But if i drive on my server a Round, the panel comes for 1 sek.
not stay to End of Round. Why ??

Plz Help me

THX
I*ve got the same Problem now^^

ods
pedestrian
pedestrian
Posts: 14
Joined: 14 Jan 2009 20:15
Owned TM-games: TMO TMS TMN TMUF NDS
Manialink(s): DD

Re: Plugin: Rounds finish panel mod

Post by ods » 16 Feb 2009 08:52

at my server work it now. thx. but i dont deactivate the plugin.rounds.php

Xymph
Pit Crew
Pit Crew
Posts: 5650
Joined: 19 Aug 2007 12:58
Owned TM-games: TMN, TMU, TMF, TM²
Contact:

Re: Plugin: Rounds finish panel mod

Post by Xymph » 16 Feb 2009 12:56

It's bad programming practice to use a function name ('store_time' in this case) in a plugin when that name is already in use by the main system. Rather than removing a plugin that may be useful or even needed, the above plugin should be modified to use a unique function name.
Developer of XASECO for TMF/TMN ESWC & XASECO2 for TM²: see XAseco.org
Find your way around the Mania community from the TMN ESWC hub, TMF hub, TM² hub, and SM hub

Bueddl
speedy pilot
speedy pilot
Posts: 458
Joined: 05 Apr 2008 12:37
Owned TM-games: TMO, TMS, TMU/N(F)
Location: Germany
Contact:

Re: Plugin: Rounds finish panel mod

Post by Bueddl » 16 Feb 2009 17:06

unique like: nicofinish_storetime()

;-)

this is the problem of xaseco. It dont use a plugin class. With something like that, it would be easyer ;-)

User avatar
f*ckfish
Pit Crew
Pit Crew
Posts: 1302
Joined: 15 Jun 2007 07:59
Owned TM-games: TMNF, TMUF
Location: Dresden, Germany
Contact:

Re: Plugin: Rounds finish panel mod

Post by f*ckfish » 16 Feb 2009 18:08

For Xaseco development, just get used to name all functions like that:

Code: Select all

function pluginname_functionName()
and there won't be any problems =)
inactive, sorry

nouseforname
swift roadking
swift roadking
Posts: 840
Joined: 20 Apr 2008 08:58
Owned TM-games: TMUF,TMNF, TMN
Manialink(s): therookies
Location: Germany
Contact:

Re: Plugin: Rounds finish panel mod

Post by nouseforname » 22 Feb 2009 11:04

i am wondering, the panel shows:

time " + " nickname


the round points like 25,20,18.... are missing

what did i wrong?
Owner of the Rookie servers and some more. :)
Rookies HP
My Project
Rookies Manialinkcolor>

User avatar
BReMFoX
smooth traffic navigator
smooth traffic navigator
Posts: 275
Joined: 05 Sep 2006 08:53
Owned TM-games: TMUF
Location: The Netherlands

Re: Plugin: Rounds finish panel mod

Post by BReMFoX » 22 Feb 2009 12:06

nouseforname wrote:i am wondering, the panel shows:

time " + " nickname


the round points like 25,20,18.... are missing

what did i wrong?
In your config.xml you must add the default_rpoints, like:

Code: Select all

<default_rpoints>f1gp</default_rpoints>
Last edited by BReMFoX on 22 Feb 2009 12:09, edited 1 time in total.

Post Reply