[XASECO] Plugin: Personal Best Checkpoints 1.3.2 (UPDATE)

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

Moderators: Xymph, TM-Patrol

User avatar
undef.de
Pit Crew
Pit Crew
Posts: 1305
Joined: 31 Aug 2009 18:38
Owned TM-games: TMF, TM2C/S/V, SM
Manialink(s): undef, tmkarma
Location: Germany
Contact:

Re: [XASECO] Plugin: Personal Best Checkpoints 1.0 (UPDATE)

Post by undef.de » 31 Aug 2010 18:23

New Bugfix version 1.0 released, see release notes for details.
Developer of various plugins for XAseco/XAseco2 and MPAseco,
like Records-Eyepiece, TM-Karma, Alternate Scoretable...
Visit my Lab: www.undef.name

Get it now:
» TM2 Valley
» TM2 Canyon
» TM2 Stadium
» SM Storm

User avatar
undef.de
Pit Crew
Pit Crew
Posts: 1305
Joined: 31 Aug 2009 18:38
Owned TM-games: TMF, TM2C/S/V, SM
Manialink(s): undef, tmkarma
Location: Germany
Contact:

Re: [XASECO] Plugin: Personal Best Checkpoints 1.1 (UPDATE)

Post by undef.de » 05 Sep 2010 11:10

Just wanna say: There is an update out there... see my first post.
Developer of various plugins for XAseco/XAseco2 and MPAseco,
like Records-Eyepiece, TM-Karma, Alternate Scoretable...
Visit my Lab: www.undef.name

Get it now:
» TM2 Valley
» TM2 Canyon
» TM2 Stadium
» SM Storm

biloudeprovence
road tourist
road tourist
Posts: 82
Joined: 24 Jul 2008 09:49
Owned TM-games: TMU

Re: [XASECO] Plugin: Personal Best Checkpoints 1.1 (UPDATE)

Post by biloudeprovence » 06 Sep 2010 06:26

HI undef.de :D
Personal Best Checkpoints 1.0 works perfect
so with v1.1 I have this error when I start xaseco 1.11
Have you a idear why ?
see printscreen here:

http://img269.imageshack.us/img269/2937 ... tcheck.jpg

Thx a lot
and GG to your plugin :thumbsup:

Greco
happy cruiser
happy cruiser
Posts: 144
Joined: 13 May 2009 18:40
Owned TM-games: TMN

Re: [XASECO] Plugin: Personal Best Checkpoints 1.1 (UPDATE)

Post by Greco » 12 Sep 2010 12:01

very good :thumbsup:

User avatar
undef.de
Pit Crew
Pit Crew
Posts: 1305
Joined: 31 Aug 2009 18:38
Owned TM-games: TMF, TM2C/S/V, SM
Manialink(s): undef, tmkarma
Location: Germany
Contact:

Re: [XASECO] Plugin: Personal Best Checkpoints 1.1 (UPDATE)

Post by undef.de » 14 Sep 2010 17:21

biloudeprovence wrote:HI undef.de :D
Personal Best Checkpoints 1.0 works perfect
so with v1.1 I have this error when I start xaseco 1.11
Have you a idear why ?
see printscreen here:

http://img269.imageshack.us/img269/2937 ... tcheck.jpg
Yes, found the bug... i have not tested this plugin without Players connected. The next release are fixed, but not yet released. Maybe next week. :?
Developer of various plugins for XAseco/XAseco2 and MPAseco,
like Records-Eyepiece, TM-Karma, Alternate Scoretable...
Visit my Lab: www.undef.name

Get it now:
» TM2 Valley
» TM2 Canyon
» TM2 Stadium
» SM Storm

biloudeprovence
road tourist
road tourist
Posts: 82
Joined: 24 Jul 2008 09:49
Owned TM-games: TMU

Re: [XASECO] Plugin: Personal Best Checkpoints 1.1 (UPDATE)

Post by biloudeprovence » 18 Sep 2010 22:35

Hi undef.de
ok I wait for
thx a lot

User avatar
undef.de
Pit Crew
Pit Crew
Posts: 1305
Joined: 31 Aug 2009 18:38
Owned TM-games: TMF, TM2C/S/V, SM
Manialink(s): undef, tmkarma
Location: Germany
Contact:

Re: [XASECO] Plugin: Personal Best Checkpoints 1.2 (UPDATE)

Post by undef.de » 17 Oct 2010 15:22

Just wanna say: There is an update out there... see my first post.
Developer of various plugins for XAseco/XAseco2 and MPAseco,
like Records-Eyepiece, TM-Karma, Alternate Scoretable...
Visit my Lab: www.undef.name

Get it now:
» TM2 Valley
» TM2 Canyon
» TM2 Stadium
» SM Storm

pro_info
cyclist
cyclist
Posts: 31
Joined: 19 Oct 2010 15:11
Owned TM-games: TMU

Re: [XASECO] Plugin: Personal Best Checkpoints 1.2 (UPDATE)

Post by pro_info » 26 Oct 2010 08:22

yo all
I would like to add a column or the results displayed but no way to find the line has changed in the plugin (is to adapt the maps rpg)
I have changed : Traduction by google I'm french sorry

Code: Select all

<?php

/*
 * Plugin Personal Best Checkpoints
 * This Plugin is useful on Train-Servers and maybe RPG-Servers. It displays the
 * differences between your own Checkpoint-Times for each run.
 *
 * The first run on a Challenge are now preset with a local driven record, so you can
 * compare from the first run your Checkpoint times. This feature is only active if
 * less then 32 Players connected to the Server to prevent long loads on Database access.
 *
 * Currently it supports the Gamemodes: Rounds, TimeAttack, Team, Laps, Stunts, Cup
 * This Plugin works only with TMF!
 * ----------------------------------------------------------------------------------
 * Author:	undef.de
 * Version:	1.2
 * Date:	2010-10-17
 * Copyright:	2009 - 2010 by undef.de
 * Home:	http://www.undef.de/Trackmania/Plugins/
 * System:	xaseco/1.06 and up
 * ----------------------------------------------------------------------------------
 *
 * LICENSE: This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as published
 * by the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 *
 * ----------------------------------------------------------------------------------
 *
 * Dependencies:	plugins/plugin.localdatabase.php
 */

/* The following manialink id's are used in this plugin (the 915 part of id can be changed on trouble):
 * 91500		id for manialinks
 * 91501		id for manialink for the Widget itself
 * 91502		id for manialink Checkpoint-Times and Differences
 * 91503		id for manialink for the Help
 * 91504		id for action to display Help
 * 91505		id for action to close Help
 */

Aseco::registerEvent('onStartup',			'pbcps_onStartup');
Aseco::registerEvent('onCheckpoint',			'pbcps_onCheckpoint');
Aseco::registerEvent('onNewChallenge2',			'pbcps_onNewChallenge2');
Aseco::registerEvent('onPlayerConnect',			'pbcps_onPlayerConnect');
Aseco::registerEvent('onPlayerInfoChanged',		'pbcps_onPlayerInfoChanged');
Aseco::registerEvent('onPlayerManialinkPageAnswer',	'pbcps_onPlayerManialinkPageAnswer');
Aseco::registerEvent('onPlayerFinish',			'pbcps_onPlayerFinish');
Aseco::registerEvent('onEndRace',			'pbcps_onEndRace');			// throw main 'end challenge' event
Aseco::registerEvent('onRestartChallenge',		'pbcps_onRestartChallenge');		// throw 'restarted challenge' event

global $pbcps_config;

/* Just a note for my editor -> utf-8 äöüß */

/*
#///////////////////////////////////////////////////////////////////////#
#									#
#///////////////////////////////////////////////////////////////////////#
*/

function pbcps_onStartup ($aseco) {
	global $pbcps_config;


	// Check for the right XASECO-Version
	if ( defined('XASECO_VERSION') ) {
		if ( version_compare(XASECO_VERSION, 1.06, '<') ) {
			trigger_error('[plugin.personal_best_checkpoints.php] Not supported xaseco version ('. XASECO_VERSION .')! Please update to min. version 1.11!', E_USER_ERROR);
		}
	}
	else {
		trigger_error('[plugin.personal_best_checkpoints.php] Can not identify the System, "XASECO_VERSION" is unset! This plugin runs only with XASECO/1.11 and up.', E_USER_ERROR);
	}

	// Check for dependencies
	if ( !function_exists('ldb_loadSettings') ) {
		trigger_error('[plugin.personal_best_checkpoints.php] Missing dependent plugin, please activate "plugin.localdatabase.php" in "plugins.xml" and restart.', E_USER_ERROR);
	}

	if ($aseco->server->getGame() != 'TMF') {
		trigger_error('[plugin.personal_best_checkpoints.php] This plugin supports only TMF, can not start with a '. $aseco->server->getGame() .' Dedicated-Server!', E_USER_ERROR);
	}

	// Set 'checkpoint_list' off, this place we need
	setCustomUIField('checkpoint_list', false);

	$pbcps_config['MANIALINK_ID'] = '915';
	$pbcps_config['VERSION'] = '1.2';

	$pbcps_config['WIDGET']['POSITION_X'] = 13;
	$pbcps_config['WIDGET']['POSITION_Y'] = -32.5;
	$pbcps_config['WIDGET']['TEXTSIZE'] = 1;
	$pbcps_config['WIDGET']['TEXTSCALE'] = 0.9;

	$pbcps_config['SHOW_MAX_CHECKPOINTS'] = 27;			// 30 is max.

	// Set current state
	$pbcps_config['CURRENT_STATE'] = 1;
	$pbcps_config['CHALLENGE'] = array();
}

/*
#///////////////////////////////////////////////////////////////////////#
#									#
#///////////////////////////////////////////////////////////////////////#
*/

function pbcps_onPlayerConnect ($aseco, $player) {
	global $pbcps_config;


	// Clean complete
	$player->data['BPCPS_TIMES'] = array();

	// Set PlayerId (from Database), cache the Id here for later use
	$player->data['BPCPS_DBPLAYERID'] = $aseco->getPlayerId( $player->login );

	// Need to do a trick, because on XASECO StartUp, there is no Challenge loaded
	// and XASECO can not give the number of Checkpoints. So just fill the maximum.
	// When the Challenge is loaded, then this get fixed to the correct number of
	// Checkpoints.
	// If a Player joins when XASECO runs a longer time, then there is the correct
	// number of Checkpoints, because the Challenge is already loaded.
	$pbcps_config['CHALLENGE']['NUM_CPS'] = (isset($pbcps_config['CHALLENGE']['NUM_CPS']) ? $pbcps_config['CHALLENGE']['NUM_CPS'] : $pbcps_config['SHOW_MAX_CHECKPOINTS']);

	// Preset the PBC-Array for current Player
	pbcps_resetPlayerArray($player);

	// Display the empty Widget
	pbcps_displayWidget($player->login);
}

/*
#///////////////////////////////////////////////////////////////////////#
#									#
#///////////////////////////////////////////////////////////////////////#
*/

// called @ onPlayerInfoChanged
function pbcps_onPlayerInfoChanged ($aseco, $info) {
	global $pbcps_config;


	// Nothing todo at Score
	if ($pbcps_config['CURRENT_STATE'] != 6) {

		// Get Player
		$player = $aseco->server->players->getPlayer($info['Login']);

		if ($player->isspectator == 1) {
			$xml =  '<?xml version="1.0" encoding="UTF-8"?>';
			$xml .= '<manialinks id="'. $pbcps_config['MANIALINK_ID'] .'00">';
			$xml .= '<manialink id="'. $pbcps_config['MANIALINK_ID'] .'01"></manialink>';
			$xml .= '<manialink id="'. $pbcps_config['MANIALINK_ID'] .'02"></manialink>';
			$xml .= '</manialinks>';

			// Hide at Scoretable
			$aseco->client->addCall("SendDisplayManialinkPageToLogin", array($player->login, $xml, 0, false));
		}
		else {
			// Display the empty Widget
			pbcps_displayWidget($player->login);

			// Display the personal checkpoints time for Player
			pbcps_displayPersonalCheckpointsTime($player, -1);
		}
	}
}

/*
#///////////////////////////////////////////////////////////////////////#
#									#
#///////////////////////////////////////////////////////////////////////#
*/

// called @ onPlayerManialinkPageAnswer


/*
#///////////////////////////////////////////////////////////////////////#
#									#
#///////////////////////////////////////////////////////////////////////#
*/

// called @ onPlayerFinish
function pbcps_onPlayerFinish ($aseco, $finish_item) {
	global $pbcps_config;


	// Refresh the times without any highlite Checkpoint
	if ($finish_item->score == 0) {
		// Display the personal checkpoint time for Player
		pbcps_displayPersonalCheckpointsTime($finish_item->player, -1);
	}

}

/*
#///////////////////////////////////////////////////////////////////////#
#									#
#///////////////////////////////////////////////////////////////////////#
*/

function pbcps_onNewChallenge2 ($aseco, $challenge_item) {
	global $pbcps_config;


	// Set current state
	$pbcps_config['CURRENT_STATE'] = 1;

	// Display the empty Widget
	pbcps_displayWidget(false);

	// Returns a struct containing the infos for the current challenge.
	// The struct contains the following fields:
	// Name, UId, FileName, Author, Environnement, Mood, BronzeTime, SilverTime, GoldTime, AuthorTime, CopperPrice, LapRace, NbLaps and NbCheckpoints.
	$aseco->client->query('GetCurrentChallengeInfo');
	$challenge = $aseco->client->getResponse();

	// Save the number of Checkpoints of this Map and if this Map is a Multilap
	$pbcps_config['CHALLENGE']['NUM_CPS'] = $challenge['NbCheckpoints'];
	$pbcps_config['CHALLENGE']['MULTILAP'] = $challenge['LapRace'];
	$pbcps_config['CHALLENGE']['DBID'] = $aseco->server->challenge->id;

	// Reset the PBC-Array for all connected Players
	pbcps_resetPlayerArray(false);
}

/*
#///////////////////////////////////////////////////////////////////////#
#									#
#///////////////////////////////////////////////////////////////////////#
*/

function pbcps_onRestartChallenge ($aseco, $challenge_item) {
	global $pbcps_config;


	// Set current state
	$pbcps_config['CURRENT_STATE'] = 1;

	// Returns a struct containing the infos for the current challenge.
	// The struct contains the following fields:
	// Name, UId, FileName, Author, Environnement, Mood, BronzeTime, SilverTime, GoldTime, AuthorTime, CopperPrice, LapRace, NbLaps and NbCheckpoints.
	$aseco->client->query('GetCurrentChallengeInfo');
	$challenge = $aseco->client->getResponse();

	// Save the number of Checkpoints of this Map
	$pbcps_config['CHALLENGE']['NUM_CPS'] = $challenge['NbCheckpoints'];

	// Preset the PBC-Array for all Players
	pbcps_resetPlayerArray(false);
}

/*
#///////////////////////////////////////////////////////////////////////#
#									#
#///////////////////////////////////////////////////////////////////////#
*/

// TMN: [0]=PlayerUid, [1]=Login, [2]=Time, [3]=Score, [4]=CheckpointIndex
// TMF: [0]=PlayerUid, [1]=Login, [2]=TimeScore, [3]=CurLap, [4]=CheckpointIndex
function pbcps_onCheckpoint ($aseco, $checkpt) {
	global $pbcps_config;


	// Set the author of this action
	$player = $aseco->server->players->getPlayer($checkpt[1]);
	$time = $checkpt[2];
	$round = $checkpt[3];
	$CheckpointId = $checkpt[4];


//	$aseco->console('***B CP:'. sprintf("%02d", $CheckpointId) .' RND:'. $round .' TIME:'. $time);

	// Special work for Multilaps Maps in Gamemode 'Laps'
	if ( ($aseco->server->gameinfo->mode == 3) && ($pbcps_config['CHALLENGE']['MULTILAP'] == true) ) {

		// Correct CheckpointId in Multilaps Maps
		$finish = false;
		if ( ($CheckpointId+1) == ($pbcps_config['CHALLENGE']['NUM_CPS'] * $round) ) {
			$round -= 1;

			// Was a finish "Checkpoint"
			$finish = $player->data['BPCPS_LAST_LAP_TIME'];

			// Store the total time for this lap
			$player->data['BPCPS_LAST_LAP_TIME'] = $time;
		}
		if ($round > 0) {
			// The Checkpoints counts up, but i need the Id of the Checkpoint
			$cp = ($CheckpointId - ($pbcps_config['CHALLENGE']['NUM_CPS'] * $round));
			if ($cp >= 0) {
				$CheckpointId = $cp;
			}

			// Calculate the right time for this Checkpoint only if it is not the finish "Checkpoint" for this lap
			if ($finish == false) {
				$time -= $player->data['BPCPS_LAST_LAP_TIME'];
			}
			else {
				$time -= $finish;
			}
		}
	}

//	$aseco->console('***A CP:'. sprintf("%02d", $CheckpointId) .' RND:'. $round .' TIME:'. $time .LF);


	// Calculate the difference between personal Checkpoint time and personal best Checkpoint time
	if ( (!isset($player->data['BPCPS_TIMES'][$CheckpointId]->best_time)) || ($player->data['BPCPS_TIMES'][$CheckpointId]->best_time == -1) ) {
		$differences = 0;
	}
	else {
		$differences = ($time - $player->data['BPCPS_TIMES'][$CheckpointId]->best_time);
	}


	// Prepare the times and style for this Checkpoint
	if ($differences < 0) {

		$differences = abs($differences);
		if ($aseco->server->gameinfo->mode == 4) {
			// Player has a lower Score at this Checkpoint
			$player->data['BPCPS_TIMES'][$CheckpointId]->diff_styled = '$F00-' . $differences;

		}
		else {
			// Player has a better time at this Checkpoint
			$player->data['BPCPS_TIMES'][$CheckpointId]->diff_styled = '$0F0-' . sprintf('%d.%02d', floor($differences/1000), (($differences - (floor($differences/1000) * 1000)) / 10));

			$player->data['BPCPS_TIMES'][$CheckpointId]->best_time = $time;
		}

	}
	elseif ($differences == 0) {

		if ($player->data['BPCPS_TIMES'][$CheckpointId]->best_time == -1) {
			// Player has not driven this Checkpoint before
			if ($aseco->server->gameinfo->mode == 4) {
				$player->data['BPCPS_TIMES'][$CheckpointId]->diff_styled = '$FFF---';
			}
			else {
				$player->data['BPCPS_TIMES'][$CheckpointId]->diff_styled = '$FFF-.--';
			}
			$player->data['BPCPS_TIMES'][$CheckpointId]->best_time = $time;

		}
		else {
			if ($aseco->server->gameinfo->mode == 4) {
				// Player has same Score at this Checkpoint
				$player->data['BPCPS_TIMES'][$CheckpointId]->diff_styled = '$0DF±' . $differences;
			}
			else {
				// Player has same time at this Checkpoint
				$player->data['BPCPS_TIMES'][$CheckpointId]->diff_styled = '$0DF±' . sprintf('%d.%02d', floor($differences/1000), (($differences - (floor($differences/1000) * 1000)) / 10));
			}

		}

	}
	else { // $differences > 0

		if ($aseco->server->gameinfo->mode == 4) {
			// Player has higher Score at this Checkpoint
			$player->data['BPCPS_TIMES'][$CheckpointId]->diff_styled = '$0F0+' . $differences;

			$player->data['BPCPS_TIMES'][$CheckpointId]->best_time = $time;
		}
		else {
			// Player has slower time at this Checkpoint
			$player->data['BPCPS_TIMES'][$CheckpointId]->diff_styled = '$F00+' . sprintf('%d.%02d', floor($differences/1000), (($differences - (floor($differences/1000) * 1000)) / 10));

		}

	}


	// Display the personal checkpoint time for Player
	pbcps_displayPersonalCheckpointsTime($player, $CheckpointId);

}

/*
#///////////////////////////////////////////////////////////////////////#
#									#
#///////////////////////////////////////////////////////////////////////#
*/

// called @ onEndRace
function pbcps_onEndRace ($aseco, $race) {
	global $pbcps_config;


	// Set current state
	$pbcps_config['CURRENT_STATE'] = 6;

	$xml =  '<?xml version="1.0" encoding="UTF-8"?>';
	$xml .= '<manialinks id="'. $pbcps_config['MANIALINK_ID'] .'00">';
	$xml .= '<manialink id="'. $pbcps_config['MANIALINK_ID'] .'01"></manialink>';
	$xml .= '<manialink id="'. $pbcps_config['MANIALINK_ID'] .'02"></manialink>';
	$xml .= '</manialinks>';

	// Hide at Scoretable
	$aseco->client->addCall("SendDisplayManialinkPage", array($xml, 0, false));
}

/*
#///////////////////////////////////////////////////////////////////////#
#									#
#///////////////////////////////////////////////////////////////////////#
*/

function pbcps_resetPlayerArray ($player = false) {
	global $aseco, $pbcps_config;


	// bail out immediately if no Player is connected
	if (count($aseco->server->players->player_list) == 0) {
		return;
	}

	if ( ($player == false) && (count($aseco->server->players->player_list) <= 32) ) {
		pbcps_playerArrayPersonal(false);
	}
	else if ( ($player != false) && (count($aseco->server->players->player_list) <= 32) ) {
		pbcps_playerArrayPersonal($player);
	}
	else {
		pbcps_playerArrayNice();
	}
}

/*
#///////////////////////////////////////////////////////////////////////#
#									#
#///////////////////////////////////////////////////////////////////////#
*/

function pbcps_playerArrayNice () {
	global $aseco, $pbcps_config;


	// Clean Players CP list (Nice-Mode)
	foreach ($aseco->server->players->player_list as $player) {

		// Clean complete
		$player->data['BPCPS_TIMES'] = array();

		// Preset all CPs with -1
		for ($i = 0 ; $i <= $pbcps_config['CHALLENGE']['NUM_CPS'] ; $i ++) {
			$player->data['BPCPS_TIMES'][$i]->best_time = -1;
			$player->data['BPCPS_TIMES'][$i]->diff_styled = '';

		}
		$player->data['BPCPS_LAST_LAP_TIME'] = 0;

		// Display the personal checkpoints time for Player (except Spectators)
		if ($player->isspectator != 1) {
			pbcps_displayPersonalCheckpointsTime($player, -1);
		}
	}
}

/*
#///////////////////////////////////////////////////////////////////////#
#									#
#///////////////////////////////////////////////////////////////////////#
*/

function pbcps_playerArrayPersonal ($player = false) {
	global $aseco, $pbcps_config;


	// bail out immediately if no Challenge Database Id was set
	if ( !isset($pbcps_config['CHALLENGE']['DBID']) ) {
		return;
	}

	// Preset with local saved Checkpoint times (if any)
	if ($player != false) {
		$query = "SELECT `PlayerId`,`Checkpoints` FROM `records` WHERE `ChallengeId`='". $pbcps_config['CHALLENGE']['DBID'] ."' AND `PlayerId`='". $player->data['BPCPS_DBPLAYERID'] ."' LIMIT 1;";
	}
	else {
		$query = "SELECT `PlayerId`,`Checkpoints` FROM `records` WHERE `ChallengeId`='". $pbcps_config['CHALLENGE']['DBID'] ."' AND `PlayerId` IN (";
		foreach ($aseco->server->players->player_list as $ply) {
			$query .= "'". $ply->data['BPCPS_DBPLAYERID'] ."',";

		}
		$query = substr($query, 0, strlen($query)-1);		// remove the last ,
		$query .= ');';
	}

	$res = mysql_query($query);
	if ($res != false) {

		// Clean complete
		foreach ($aseco->server->players->player_list as $player) {
				$player->data['BPCPS_TIMES'] = array();
		}

		// Fill with local record
		while ($row = mysql_fetch_object($res)) {
			foreach ($aseco->server->players->player_list as $player) {
				if ($player->data['BPCPS_DBPLAYERID'] == $row->PlayerId) {

					$cps = explode(',', $row->Checkpoints);
					for ($i = 0 ; $i <= $pbcps_config['CHALLENGE']['NUM_CPS'] ; $i ++) {
						$player->data['BPCPS_TIMES'][$i]->best_time = ((isset($cps[$i]) && $cps[$i]!='') ? $cps[$i] : -1);
						$player->data['BPCPS_TIMES'][$i]->diff_styled = '';

					}
					$player->data['BPCPS_LAST_LAP_TIME'] = 0;

					// Display the personal checkpoints time for Player (except Spectators)
					if ($player->isspectator != 1) {
						pbcps_displayPersonalCheckpointsTime($player, -1);
					}
				}
			}
		}

		// Find Players without a local record and preset with empty time
		foreach ($aseco->server->players->player_list as $player) {
			if (count($player->data['BPCPS_TIMES']) == 0) {
				// Preset all CPs with -1
				for ($i = 0 ; $i <= $pbcps_config['CHALLENGE']['NUM_CPS'] ; $i ++) {
					$player->data['BPCPS_TIMES'][$i]->best_time = -1;
					$player->data['BPCPS_TIMES'][$i]->diff_styled = '';

				}
				$player->data['BPCPS_LAST_LAP_TIME'] = 0;
			}
		}

	}
	else {
		$aseco->console('[plugin.personal_best_checkpoints.php] SQL error: '. mysql_error() .' [for statement "'. $query .'"]');
		pbcps_playerArrayNice();
	}
	mysql_free_result($res);
}

/*
#///////////////////////////////////////////////////////////////////////#
#									#
#///////////////////////////////////////////////////////////////////////#
*/

function pbcps_displayWidget ($login = false) {
	global $aseco, $pbcps_config;




	$xml .= '</frame>';
	$xml .= '</manialink>';
	$xml .= '</manialinks>';

	if ($login != false) {
		// Send to $login
		$aseco->client->addCall("SendDisplayManialinkPageToLogin", array($login, $xml, 0, false));
	}
	else {
		// Send to all Players
		$aseco->client->addCall("SendDisplayManialinkPage", array($xml, 0, false));
	}
}

/*
#///////////////////////////////////////////////////////////////////////#
#									#
#///////////////////////////////////////////////////////////////////////#
*/

function pbcps_displayHelp ($aseco, $login, $display = true) {
	global $pbcps_config;


	// Set the message
	$message = array(
		'With this Widget you can see the differences between your driven times for each Checkpoint.',
		'',
		'Detailed description of the times:',
		'  $F00+0.28 $FF0 You was slower as the run before',
		'  $0DF±0.00 $FF0 You was exact same fast as the run before',
		'  $0F0-0.32  $FF0 You was faster as the run before',
		'   $FFF---     $FF0 Checkpoint was first time reached',
		'',
		'The last reached Checkpoints blinks, so you can find quickly the last reached Checkpoint.',
		'',
		'The Bar at the right of this Widget changes the color in exact the same behavior as the Checkpoint-Times, so you does not need',
		'to look at every Checkpoint to this Widget, you can see your differences just out of the corners of your eyes.'
	);


	$xml =  '<?xml version="1.0" encoding="UTF-8"?>';
	$xml .= '<manialinks id="'. $pbcps_config['MANIALINK_ID'] .'00">';
	$xml .= '<manialink id="'. $pbcps_config['MANIALINK_ID'] .'03">';

	if ($display == true) {
		// Window

		// Header Line

		// Close Button


		// Set the width of MessageWindow
		$width = 75;
		$line_height = 1.65;
		$position = 0;

		$xml .= '<frame posn="3 -6 0">';
		foreach ($message as $msg) {
			if ($msg) {
				$xml .= '<label posn="0 '. $position .' 0.05" sizen="'. ($width-2.6) .' 0" halign="left" textsize="1" textcolor="FFFF" text="'. $msg .'"/>';
			}
			$position -= $line_height;
		}
		$xml .= '</frame>';


		$xml .= '</frame>';	// Window
	}

	$xml .= '</manialink>';
	$xml .= '</manialinks>';

	// Send Help to given Player
	$aseco->client->addCall('SendDisplayManialinkPageToLogin', array($login, $xml, 0, false));
}

/*
#///////////////////////////////////////////////////////////////////////#
#									#
#///////////////////////////////////////////////////////////////////////#
*/

function pbcps_displayPersonalCheckpointsTime ($player, $cpid = -1) {
	global $aseco, $pbcps_config;


	$CheckpointId = (($cpid != -1) ? $cpid : 0);

	$xml =  '<?xml version="1.0" encoding="UTF-8"?>';
	$xml .= '<manialinks id="'. $pbcps_config['MANIALINK_ID'] .'00">';
	$xml .= '<manialink id="'. $pbcps_config['MANIALINK_ID'] .'02">';
	$xml .= '<frame posn="'. $pbcps_config['WIDGET']['POSITION_X'] .' '. $pbcps_config['WIDGET']['POSITION_Y'] .' 3">';


	$lines = 1;
	$posx = 0;
	$posy = 0;
	$offsety = 1.37;
	$CheckpointCount = 0;
	foreach ($player->data['BPCPS_TIMES'] as $struct) {

		// Show max. $pbcps_config['SHOW_MAX_CHECKPOINTS'] Checkpoints
		if (($CheckpointCount+1) > $pbcps_config['SHOW_MAX_CHECKPOINTS']) {
			break;
		}

//		// Hide not passed Checkpoints
//		if ($CheckpointCount > $CheckpointId) {
//			break;
//		}

		// Do not show Finish
		if (($CheckpointCount+1) == $pbcps_config['CHALLENGE']['NUM_CPS']) {
			break;
		}


		// Check for max. line count
		if ($lines == 10) {
			$lines = 1;
		}
		$posy = -($offsety * $lines);

		// Check for next block
		if ( ($CheckpointCount == 9) || ($CheckpointCount == 18) ) {
			$posx += 12;
		}


		if ( ($CheckpointCount == $CheckpointId) && ($cpid != -1) ) {
			// Highlight current Checkpoint
 			$xml .= '<format style="TextTitle2Blink"/>';
		}
		else {
			// No Highlight
 			$xml .= '<format style="TextStaticMedium"/>';
		}

		$xml .= '<label posn="'. ($posx + 1.85) .' '. $posy .' 0.14" sizen="1.5 0" halign="right" textsize="'. $pbcps_config['WIDGET']['TEXTSIZE'] .'" scale="'. $pbcps_config['WIDGET']['TEXTSCALE'] .'" textcolor="FFFF" text="'. ($CheckpointCount+1) .'."/>';
		$xml .= '<label posn="'. ($posx + 6.3) .' '. $posy .' 0.14" sizen="4.3 0" halign="right" textsize="'. $pbcps_config['WIDGET']['TEXTSIZE'] .'" scale="'. $pbcps_config['WIDGET']['TEXTSCALE'] .'" textcolor="FFFF" text="'. (($aseco->server->gameinfo->mode == 4) ? $player->data['BPCPS_TIMES'][$CheckpointCount]->best_time : formatTime($player->data['BPCPS_TIMES'][$CheckpointCount]->best_time)) .'"/>';
		$xml .= '<label posn="'. ($posx + 10.6) .' '. $posy .' 0.14" sizen="4.3 0" halign="right" textsize="'. $pbcps_config['WIDGET']['TEXTSIZE'] .'" scale="'. $pbcps_config['WIDGET']['TEXTSCALE'] .'" text="'. $player->data['BPCPS_TIMES'][$CheckpointCount]->diff_styled .'"/>';

		$CheckpointCount++;
		$lines++;
	}

	$xml .= '</frame>';
	$xml .= '</manialink>';
	$xml .= '</manialinks>';

	$aseco->client->addCall("SendDisplayManialinkPageToLogin", array($player->login, $xml, 0, false));
}

?>
thank you for your help
Last edited by pro_info on 28 Oct 2010 12:15, edited 2 times in total.

User avatar
TheM
Pit Crew
Pit Crew
Posts: 286
Joined: 25 Feb 2009 16:43
Owned TM-games: TMU(F), TMN(F), TM2
Location: Brabant, Netherlands
Contact:

Re: [XASECO] Plugin: Personal Best Checkpoints 1.2 (UPDATE)

Post by TheM » 26 Oct 2010 09:03

Please use the [ code ] tag when posting codes!

User avatar
undef.de
Pit Crew
Pit Crew
Posts: 1305
Joined: 31 Aug 2009 18:38
Owned TM-games: TMF, TM2C/S/V, SM
Manialink(s): undef, tmkarma
Location: Germany
Contact:

Re: [XASECO] Plugin: Personal Best Checkpoints 1.2 (UPDATE)

Post by undef.de » 26 Oct 2010 17:19

pro_info wrote:yo all
I would like to add a column or the results displayed but no way to find the line has changed in the plugin (is to adapt the maps rpg)
I have changed : Traduction by google I'm french sorry

thank you for your help
Sorry here again, i realy did you understand what you want here. :( Maybe a screenshot with your wanted extention could help.
Developer of various plugins for XAseco/XAseco2 and MPAseco,
like Records-Eyepiece, TM-Karma, Alternate Scoretable...
Visit my Lab: www.undef.name

Get it now:
» TM2 Valley
» TM2 Canyon
» TM2 Stadium
» SM Storm

pro_info
cyclist
cyclist
Posts: 31
Joined: 19 Oct 2010 15:11
Owned TM-games: TMU

Re: [XASECO] Plugin: Personal Best Checkpoints 1.2 (UPDATE)

Post by pro_info » 28 Oct 2010 12:18

I try to modify the plugin to display 4 columns instead of 3 to have the opportunity to make them appear more checkpoints (for server RPG)
Image + Image + Image

I want to add columns
I hope you understand

User avatar
undef.de
Pit Crew
Pit Crew
Posts: 1305
Joined: 31 Aug 2009 18:38
Owned TM-games: TMF, TM2C/S/V, SM
Manialink(s): undef, tmkarma
Location: Germany
Contact:

Re: [XASECO] Plugin: Personal Best Checkpoints 1.2 (UPDATE)

Post by undef.de » 28 Oct 2010 16:49

pro_info wrote:I try to modify the plugin to display 4 columns instead of 3 to have the opportunity to make them appear more checkpoints (for server RPG)
Image + Image + Image

I want to add columns
I hope you understand
You can see at my Screenshots, that there is no space left to add one column to this plugin. So i can´t do it into this Plugin.

But i see at your Screenshots, that you have removed one "time column", i could build an new plugin that display the checkpoint counts and the driven time, when that is what you want to have for your RPG server.
Developer of various plugins for XAseco/XAseco2 and MPAseco,
like Records-Eyepiece, TM-Karma, Alternate Scoretable...
Visit my Lab: www.undef.name

Get it now:
» TM2 Valley
» TM2 Canyon
» TM2 Stadium
» SM Storm

pro_info
cyclist
cyclist
Posts: 31
Joined: 19 Oct 2010 15:11
Owned TM-games: TMU

Re: [XASECO] Plugin: Personal Best Checkpoints 1.2 (UPDATE)

Post by pro_info » 28 Oct 2010 17:13

my capture screenshot is a montage of several images so I did not delete but can we add a column?

I just simply remove the bar and the gray background

User avatar
undef.de
Pit Crew
Pit Crew
Posts: 1305
Joined: 31 Aug 2009 18:38
Owned TM-games: TMF, TM2C/S/V, SM
Manialink(s): undef, tmkarma
Location: Germany
Contact:

Re: [XASECO] Plugin: Personal Best Checkpoints 1.2 (UPDATE)

Post by undef.de » 28 Oct 2010 20:02

pro_info wrote:my capture screenshot is a montage of several images so I did not delete but can we add a column?

I just simply remove the bar and the gray background
If you are a programmer, then it should be a problem to add one column there. If not, then it´s too hard. But i could build a extra plugin which displays only the checkpoint count and the time... maybe the current place can have then maybe 4-5 columns (e.g. 40-50 checkpoints).
Developer of various plugins for XAseco/XAseco2 and MPAseco,
like Records-Eyepiece, TM-Karma, Alternate Scoretable...
Visit my Lab: www.undef.name

Get it now:
» TM2 Valley
» TM2 Canyon
» TM2 Stadium
» SM Storm

pro_info
cyclist
cyclist
Posts: 31
Joined: 19 Oct 2010 15:11
Owned TM-games: TMU

Re: [XASECO] Plugin: Personal Best Checkpoints 1.2 (UPDATE)

Post by pro_info » 28 Oct 2010 21:07

I always say as can add a column that is already well

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests