[XASECO] Plugin: Panels (FIX) hiding the records panel in spectator view

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

Moderators: Xymph, TM-Patrol

Post Reply
User avatar
L3cKy
happy cruiser
happy cruiser
Posts: 163
Joined: 05 Sep 2007 13:55
Owned TM-games: TMUF
Location: Berlin
Contact:

[XASECO] Plugin: Panels (FIX) hiding the records panel in spectator view

Post by L3cKy » 14 Feb 2018 12:42

Hej Hej.

I`ve added a new event handler at the plugin.panels.php to hide the records panel at the spectator view.

Before:
Image

After:
Image


Changings
Open and edit "plugin.panels.php" (located at xaseco->plugins folder)

Add after line 23:

Code: Select all

Aseco::registerEvent('onPlayerInfoChanged', 'recspanel_spec');
Add after line 547 (or 549): (A NEW FUNCTION)

Code: Select all

function recspanel_spec ($aseco) {

	if ($aseco->server->gamestate != Server::SCORE) {
		foreach ($aseco->server->players->player_list as $player) {
			if ($player->isspectator) {
				// Records Panel
				$xml = '<manialink id="4"></manialink>';
				$aseco->client->query('SendDisplayManialinkPageToLogin', $player->login, $xml, 0, false);
       		} else {
       			update_recpanel($aseco, $player, $player->panels['pb']);
			}
		}
   	} else {
   	   		$xml = '<manialink id="4"></manialink>';
		$aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));
	}
}// hide records panel in spectator view
----------------------------------------------------------------------

Replace/change this:

Code: Select all

// called @ onNewChallenge2
function update_allrecpanels($aseco, $data) {
	global $rasp;

	if ($aseco->server->getGame() == 'TMF') {
		// update records panel for all players
		foreach ($aseco->server->players->player_list as &$player) {
			// remember personal best at start of track
			if ($data) {
				$pb = $rasp->getPb($player->login, $aseco->server->challenge->id);
			    $player->panels['pb'] = $pb['time'];
			}
			update_recpanel($aseco, $player, $player->panels['pb']);
		}
	}
}  // update_allrecpanels
Into this:

Code: Select all

// called @ onNewChallenge2
function update_allrecpanels($aseco, $data) {
	global $rasp;

	if ($aseco->server->getGame() == 'TMF') {
		// update records panel for all players
		
		foreach ($aseco->server->players->player_list as &$player) {
			// remember personal best at start of track
			if ($data) {
			   $pb = $rasp->getPb($player->login, $aseco->server->challenge->id);
			   $player->panels['pb'] = $pb['time'];
			}
			if ($player->isspectator) {
				// Records Panel
				$xml = '<manialink id="4"></manialink>';
				$aseco->client->query('SendDisplayManialinkPageToLogin', $player->login, $xml, 0, false);
			} else {
				update_recpanel($aseco, $player, $player->panels['pb']);
			}
		}
	}
}  // update_allrecpanels
----------------------------------------------------------------------

And Replace/change this:

Code: Select all

// called @ onPlayerConnect
function load_recpanel($aseco, $player) {
	global $rasp;

	if ($aseco->server->getGame() == 'TMF') {
		// remember personal best
		$pb = $rasp->getPb($player->login, $aseco->server->challenge->id);
		$player->panels['pb'] = $pb['time'];

		update_recpanel($aseco, $player, $pb['time']);
	}
}  // load_recpanel

Into this:

Code: Select all

// called @ onPlayerConnect
function load_recpanel($aseco, $player) {
	global $rasp;

	if ($aseco->server->getGame() == 'TMF') {
		// remember personal best
		$pb = $rasp->getPb($player->login, $aseco->server->challenge->id);
		$player->panels['pb'] = $pb['time'];
		
		if ($player->isspectator) {
		   // Records Panel
		   $xml = '<manialink id="4"></manialink>';
		   $aseco->client->query('SendDisplayManialinkPageToLogin', $player->login, $xml, 0, false);
		} else {
			update_recpanel($aseco, $player, $pb['time']);
		}
	}
}  // load_recpanel
Greetings L3cKy
Last edited by L3cKy on 02 Jul 2018 23:02, edited 13 times in total.

TheBigG
smooth traffic navigator
smooth traffic navigator
Posts: 233
Joined: 16 Oct 2010 19:45
Owned TM-games: TMN! TMF
Location: Germany

Re: [XASECO] Plugin: Panels (FIX) hiding the records panel in spectator view

Post by TheBigG » 14 Feb 2018 22:35

nice idea.
but XAseco does crash as soon as there is no player anymore.

Code: Select all

PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function recspanel_spec(), 2 passed in /home/tmf/master_xaseco/aseco.php on line 1249 and exactly 3 expected in /home/tmf/master_xaseco/plugins/plugin.panels.php:550
Stack trace:
#0 /home/tmf/master_xaseco/aseco.php(1249): recspanel_spec(Object(Aseco), Array)
#1 /home/tmf/master_xaseco/aseco.php(1338): Aseco->releaseEvent('onPlayerInfoCha...', Array)
#2 /home/tmf/master_xaseco/aseco.php(1106): Aseco->playerInfoChanged(Array)
#3 /home/tmf/master_xaseco/aseco.php(760): Aseco->executeCallbacks()
#4 /home/tmf/master_xaseco/aseco.php(2562): Aseco->run('config.xml')
#5 {main}
  thrown in /home/tmf/master_xaseco/plugins/plugin.panels.php on line 550

User avatar
L3cKy
happy cruiser
happy cruiser
Posts: 163
Joined: 05 Sep 2007 13:55
Owned TM-games: TMUF
Location: Berlin
Contact:

Re: [XASECO] Plugin: Panels (FIX) hiding the records panel in spectator view

Post by L3cKy » 15 Feb 2018 00:30

Sorry i forgot to delete the $pb ...

This should work ^^

Change:

Code: Select all

function recspanel_spec ($aseco, $player, $pb)
to

Code: Select all

function recspanel_spec ($aseco, $player)
Last edited by L3cKy on 15 Feb 2018 02:02, edited 6 times in total.

TheBigG
smooth traffic navigator
smooth traffic navigator
Posts: 233
Joined: 16 Oct 2010 19:45
Owned TM-games: TMN! TMF
Location: Germany

Re: [XASECO] Plugin: Panels (FIX) hiding the records panel in spectator view

Post by TheBigG » 15 Feb 2018 00:37

Now it works.
Thank you

User avatar
L3cKy
happy cruiser
happy cruiser
Posts: 163
Joined: 05 Sep 2007 13:55
Owned TM-games: TMUF
Location: Berlin
Contact:

Re: [XASECO] Plugin: Panels (FIX) hiding the records panel in spectator view

Post by L3cKy » 15 Feb 2018 05:29

Update: look first post.
Last edited by L3cKy on 25 Mar 2018 17:37, edited 1 time in total.

TheBigG
smooth traffic navigator
smooth traffic navigator
Posts: 233
Joined: 16 Oct 2010 19:45
Owned TM-games: TMN! TMF
Location: Germany

Re: [XASECO] Plugin: Panels (FIX) hiding the records panel in spectator view

Post by TheBigG » 17 Feb 2018 16:17

Hi L3cKy,
one thing i noticed is that after a map change the panel gets displayed again even though you are still spectator

User avatar
L3cKy
happy cruiser
happy cruiser
Posts: 163
Joined: 05 Sep 2007 13:55
Owned TM-games: TMUF
Location: Berlin
Contact:

Re: [XASECO] Plugin: Panels (FIX) hiding the records panel in spectator view

Post by L3cKy » 25 Mar 2018 17:50

Update: look first post

Post Reply