[XAseco] Plugin ShowInfo

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

Moderators: Xymph, TM-Patrol

kevlarsoft
cyclist
cyclist
Posts: 33
Joined: 01 Nov 2006 12:25
Contact:

[XAseco] Plugin ShowInfo

Post by kevlarsoft » 01 Sep 2008 17:12

So this is it. My first plugin for XAseco. :D

To be honest it is not mine. I just "stole" the code from here and there, and put it together. :wink:

After Forever came out, there was no real alternative to the old Aseco by Xymph from TMN. So I used Aseco/Rasp 2. As the first Xaseco for Forever was released I immediately switched to it. But there was one thing I missed from Aseco/Rasp 2. It was the end race display, which consist of:

* Top 5 times
* Next track info
* Karma question
and with Basti504's plugin collection also the
* Top 25 ranks

I put this all together , changed it slightly and made a plugin of it. This is how it looks:

Image

I tested it on my server KosheenMini for some time now, and had no problems with it. So I hope it will work for you as well.

Here is the link to download.

Installation is basic. Put it in the plugins folder, make a new entry in plugins.xml ang that's it. Oh of cource you will have to disable the Karma Widget in Scorepanel state, because it overlaps slightly with the next track information. NextTrack widget can be disabled also.

I hope you will like it. Have fun.

kev

jeffroselier
road tourist
road tourist
Posts: 102
Joined: 25 Oct 2006 07:59
Location: MARSEILLE

Re: [XAseco] Plugin ShowInfo

Post by jeffroselier » 02 Sep 2008 09:22

Good morning,

Good Job :thumbsup:

The two window curent top 5 rank and next track info overlaps with other especially with the plugin "fufipanel.

Is it possible to move them under the counter right?

Thank you.

User avatar
k4nm4n
smooth traffic navigator
smooth traffic navigator
Posts: 262
Joined: 11 Feb 2008 10:30
Owned TM-games: TMUF
Location: Slovenia
Contact:

Re: [XAseco] Plugin ShowInfo

Post by k4nm4n » 02 Sep 2008 09:45

Thanks man, works great. :thumbsup:

kevlarsoft
cyclist
cyclist
Posts: 33
Joined: 01 Nov 2006 12:25
Contact:

Re: [XAseco] Plugin ShowInfo

Post by kevlarsoft » 02 Sep 2008 11:00

jeffroselier wrote: The two window curent top 5 rank and next track info overlaps with other especially with the plugin "fufipanel.

Is it possible to move them under the counter right?
I will look at it, and post the modifications needed.

User avatar
SPM Razor
pedestrian
pedestrian
Posts: 13
Joined: 29 Jun 2008 10:43
Owned TM-games: TMF
Location: Madrid
Contact:

Re: [XAseco] Plugin ShowInfo

Post by SPM Razor » 03 Sep 2008 11:41

you´re the best :thumbsup:
Visite our [J&B] Drinking and [J&B] Rounds on Spain

Image
Image

jeffroselier
road tourist
road tourist
Posts: 102
Joined: 25 Oct 2006 07:59
Location: MARSEILLE

Re: [XAseco] Plugin ShowInfo

Post by jeffroselier » 17 Sep 2008 18:59

kevlarsoft wrote:
jeffroselier wrote: The two window curent top 5 rank and next track info overlaps with other especially with the plugin "fufipanel.

Is it possible to move them under the counter right?
I will look at it, and post the modifications needed.
someone took the time to look?

tchamba
cyclist
cyclist
Posts: 39
Joined: 06 Jul 2008 11:29
Owned TM-games: tmu
Location: France (28)

Re: [XAseco] Plugin ShowInfo

Post by tchamba » 02 Oct 2008 13:59

hi Kevlarsoft !

Basti504 has created the plugins "StatInfo for Aseco.
please see this picture.viewtopic.php?f=124&t=16070&p=133842#p1338
It is possible for you to addionnal in your plugin "Show Info", the Dedimania Record, the top winners, and the total Playtimes ??

Tank You

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

Re: [XAseco] Plugin ShowInfo

Post by biloudeprovence » 02 Oct 2008 14:06

Whoo
I thing it's a great idear tchamba

kevlarsoft
cyclist
cyclist
Posts: 33
Joined: 01 Nov 2006 12:25
Contact:

Re: [XAseco] Plugin ShowInfo

Post by kevlarsoft » 02 Oct 2008 18:48

Sorry I had no time recently to maintain the plugin. I hope I can make an update soon, but no promises...

kev.

User avatar
FoxShadow
smooth traffic navigator
smooth traffic navigator
Posts: 247
Joined: 03 Nov 2006 20:37
Owned TM-games: TMNF, TMUF
Location: Puerto Esperanza, Misiones, Argentina
Contact:

Re: [XAseco] Plugin ShowInfo

Post by FoxShadow » 25 Oct 2008 02:44

kevlarsoft wrote:Sorry I had no time recently to maintain the plugin. I hope I can make an update soon, but no promises...

kev.
Very nice, I was looking for it, thanks :D

But, I had some problems with some nicks especial characters, the plugin simply stop work when a player with these special characters enter in the top25 or top5.
I've sent a PM to you with the fixed php (i hope) :thumbsup:
Image
Image
Image

User avatar
Sithnar
cyclist
cyclist
Posts: 38
Joined: 29 Sep 2008 13:11
Owned TM-games: TMNF TMU
Location: UK

Re: [XAseco] Plugin ShowInfo

Post by Sithnar » 31 Oct 2008 13:19

Very good plugin, although i have customised it so it fits on the screen better in places
ĐLЯ»ѕιтнηαя
ĐѧяқLoяמs Rэѧιм [ Join ]

harrii
pedestrian
pedestrian
Posts: 9
Joined: 27 Nov 2008 15:31
Owned TM-games: TMNF, TMUF

Re: [XAseco] Plugin ShowInfo

Post by harrii » 27 Nov 2008 15:33

FoxShadow wrote: But, I had some problems with some nicks especial characters, the plugin simply stop work when a player with these special characters enter in the top25 or top5.
I've sent a PM to you with the fixed php (i hope) :thumbsup:
Can you upload the fixed plugin? Because I have the same problem.

User avatar
FoxShadow
smooth traffic navigator
smooth traffic navigator
Posts: 247
Joined: 03 Nov 2006 20:37
Owned TM-games: TMNF, TMUF
Location: Puerto Esperanza, Misiones, Argentina
Contact:

Re: [XAseco] Plugin ShowInfo

Post by FoxShadow » 27 Nov 2008 19:44

harrii wrote:
FoxShadow wrote: But, I had some problems with some nicks especial characters, the plugin simply stop work when a player with these special characters enter in the top25 or top5.
I've sent a PM to you with the fixed php (i hope) :thumbsup:
Can you upload the fixed plugin? Because I have the same problem.
I've waiting for kevlarsoft post it, but i think he is very busy.
I will post it soon. :)
Image
Image
Image

User avatar
FoxShadow
smooth traffic navigator
smooth traffic navigator
Posts: 247
Joined: 03 Nov 2006 20:37
Owned TM-games: TMNF, TMUF
Location: Puerto Esperanza, Misiones, Argentina
Contact:

Re: [XAseco] Plugin ShowInfo

Post by FoxShadow » 27 Nov 2008 19:58

Sorry the double post


Beware, I've modified some functions (like rank shows the 20 best ranked players now) and I've disabled some functions that I don't need because i'm also using Fufiwidgets plugin.
I haven't checked or modified, these disabled functions..


Here is:

Code: Select all

<?php
/* Xaseco Plugin Showinfo v1.0 by kevlarsoft
 * Inlcudes code from Flo and AssemblerManiac (Aseco/Rasp 2) , from Basti 504 (Plugin Collectin)
 * and from FuFi (FuFi Widgets)
 * Display next track info, local records, local ranks and karma vote, during intermission
 *
 *
 * Currently used ManiaLink id's and action's:
 *        id= "201": Local records
 *            "202": Next track info
 *            "203": Local ranks
 *            "204": Karma Vote
 *    action= "11111": Karma vote good
 *            "22222": Karma vote bad
 *            "33333": Karma vote undiceded
*/


//dummy plugin class for XAseco
if (!class_exists('PluginShowInfo')){
		class PluginShowInfo{
			var $author, $version, $description, $Aseco, $dependencies;
			function setAuthor($auth){
				$this->author = $auth;
			}
			function setVersion($version){
				$this->version = $version;
			}
			function setDescription($description){
				$this->description = $description;
			}
		}
}


class ShowInfo extends PluginShowInfo {
	function onEndRace(){
		$challenge = $this->Aseco->server->challenge->name;
		foreach($this->Aseco->server->players->player_list as $player) {
			$query = 'SELECT Id FROM players WHERE Login=' . quotedString($player->login);
			$res = mysql_query($query);
			if (mysql_num_rows($res) > 0){
				$row = mysql_fetch_row($res);
				$pid = $row[0];
			}
			else{
				$this->Aseco->console_text('no player!');
			 	return;
			}
			mysql_free_result($res);

			$popwin = true;
			$query2 = 'SELECT Id, Score FROM rs_karma WHERE PlayerId=' . $pid . ' AND ChallengeId=' . $this->Aseco->server->challenge->id;

			$res2 = mysql_query($query2);
			if (mysql_num_rows($res2) > 0){
				$popwin = false;
			}
			mysql_free_result($res2);

			if ( $popwin ){
    			
    		$xmlheader = "<?xml version='1.0' encoding='utf-8' ?>
          <manialinks><custom_ui>
          <notice visible='true'/>
          <challenge_info visible='false'/>
          <net_infos visible='true'/>
          <chat visible='true'/>
          <checkpoint_list visible='true'/>
          <round_scores visible='true'/>
          <scoretable visible='true'/>
          <global visible='true'/>
          </custom_ui>
          <manialink posx='0.9' posy='-0.39' id='204'>
          <type>default</type>
          <format textsize='2' textcolor='000f' />
          <background bgcolor='999F' bgborderx='0.01' bgbordery='0.01'/>";
		
				$xmlfooter = "</manialink></manialinks>";

				$content = $xmlheader;

				$content .= "<line><cell><text textcolor='ee0'>How did you like \$i'" . htmlspecialchars($this->stripFormatting($challenge)). "'\$i ?</text></cell>";
				$content .= "<cell><text textcolor='0e0' halign='center' action='11111'> Good</text></cell>
							<cell><text textcolor='e00' halign='center' action='22222'> Bad</text></cell>
							<cell><text textcolor='333' halign='center' action='33333'> Undecided</text></cell></line>";

				$content.= $xmlfooter;
				
				//$this->Aseco->console_text($content);
				$this->sendMLtoLogin($player->login, $content);
				
				}
		}
	}  //  onEndRace


	function showRecords(){ //show server ranking
		
				
		//Number of records displayed
		$NumberRecords = 25;
				
		$xmlheader = "<?xml version='1.0' encoding='utf-8' ?>
		<manialinks><custom_ui>
		<notice visible='true'/>
		<challenge_info visible='false'/>
		<net_infos visible='true'/>
		<chat visible='true'/>
		<checkpoint_list visible='true'/>
		<round_scores visible='true'/>
		<scoretable visible='true'/>
		<global visible='true'/>
		</custom_ui>
		<manialink posx='-0.63' posy='0.27' id='201'>
		<type>default</type>
		<format textsize='1' textcolor='000f' />
	    <background bgcolor='000F' bgborderx='0' bgbordery='0'/>";
		
    $xmlfooter = "</manialink></manialinks>";
        
		$content = $xmlheader;
		
		$leftcell = "<cell width='.03' bgcolor='000F'><text textcolor='ddd' halign='center'>";
		$timecell = "<cell width='.1' bgcolor='000F'><text textcolor='8af' halign='center'>";
		$rightcell = "<cell width='0.28' bgcolor='000F'><text textcolor='8af' halign='left'>";
		
		$content .= "<line><cell bgcolor='888F' width='.37'><text textcolor='FF0' halign='center'>Current Track top$NumberRecords records</text></cell></line>";
		
		for ($i = 0; $i < $NumberRecords; $i++)
				{
				$cur_record = $this->Aseco->server->records->getRecord($i);

				// as long as score is not 0 ...
				if ($cur_record->score == 0) break;

				// format record score for displaying ...
				if ($this->Aseco->server->gameinfo->getMode() == 'Stunts') {
  					$record_score = $cur_record->score;
  			}		
				else{
  					$record_score = formatTime($cur_record->score);
				}

				$content .= "<line height='.03'>". $leftcell . ($i + 1) . '.</text></cell>';
				$content .= $timecell . $record_score . '</text></cell>';
				$nickname = str_replace("\$w", '', $cur_record->player->nickname);
// original				$content .= $rightcell . htmlspecialchars($nickname) . '</text></cell></line>' . CRLF;
        $content .= $rightcell . htmlspecialchars($this->getValidUTF8String($nickname)) . '</text></cell></line>' . CRLF;

  	}
		
		
		
		$content.= $xmlfooter;
		
		foreach($this->Aseco->server->players->player_list as $pl){
				  $this->sendMLtoLogin($pl->login, $content);
		}
		
	}  //  showRecords

	function showTrackInfo(){  //show next track info
		
		// get next server mode
		$this->Aseco->client->query('GetNextGameInfo');
		$GameInfo = $this->Aseco->client->getResponse();
		$GameMode = $GameInfo['GameMode'];

		$failpoint = '';
		$failed = false;
		$this->Aseco->client->query("GetNextChallengeIndex");
		$next_index = $this->Aseco->client->getResponse();
		// do GetChallengeList and send it the next index, this way you avoid looping through data to find the right one later
		$this->Aseco->client->query("GetChallengeList", 1, $next_index);
		$challenge = $this->Aseco->client->getResponse();
		
		if ( $challenge['faultString'] == 'Start index out of bound.' ){		// tried to get track xx, but only xx-1 tracks exist, get track 0 instead - using getnextchallengeindex this should NEVER occur
			$this->Aseco->client->query("GetChallengeList", 1, 0);
			$challenge = $this->Aseco->client->getResponse();
			$this->Aseco->client->error->code = 0;
			$this->Aseco->client->error->message = '';
		}
		else{
			$filename = $challenge[0]['FileName'];
		}

		if ( !$failed ){
			$this->Aseco->client->query("GetChallengeInfo", $filename);
			$result = $this->Aseco->client->getResponse();
			if ( isset($result['faultCode'] ) ){
				$this->Aseco->console_text('[RaspShowNext] - \'' . $filename . '\' - unable to get track info');
				$this->Aseco->console_text('[RaspShowNext] - GetChallengeInfo failed - [' . $result['faultCode'] . '] - ' . $result['faultString']);
				$failed = true;
				$failpoint = 'GetChallengeInfo';
			}
		}

		if ( $failed ){
			$automsg = $failpoint . ' failed, no data shown';
			$trackinfo = array();		// clear it out so it doesn't crash
		}
		else{
			$trackinfo = $result;
		}

/*
Datablock in $result[0][0]

Array
(
    [UId] => nIGJHQkY_Wy5mt11GnWtcLo_zaf
    [Name] => $s$f80new mix on the block$ffc$sz
    [FileName] => new mix on the blockz.Challenge.gbx
    [Author] => z3383z
    [Environnement] => Stadium
    [Mood] => Sunset
    [BronzeTime] => 74000
    [SilverTime] => 59000
    [GoldTime] => 52000
    [AuthorTime] => 48790
    [CopperPrice] => 3779
    [LapRace] =>
)
 */

		$this->Aseco->client->query("GetTimeAttackLimit", $newtime);
		$result = $this->Aseco->client->getResponse();
		if (!$result){
			trigger_error('[' . $this->Aseco->client->getErrorCode() . '] ' . $this->Aseco->client->getErrorMessage());
		}
		else
		{
			$nexttime = $result['NextValue'];


      // xml content
      $xmlheader = "<?xml version='1.0' encoding='utf-8' ?>
      <manialinks><custom_ui>
      <notice visible='true'/>
      <challenge_info visible='false'/>
      <net_infos visible='true'/>
      <chat visible='true'/>
      <checkpoint_list visible='true'/>
      <round_scores visible='true'/>
      <scoretable visible='true'/>
      <global visible='true'/>
      </custom_ui>
      <manialink posx='-0.5' posy='0.745' id='202'>
      <type>default</type>
      <format textsize='1' textcolor='000f' />
	    <background bgcolor='000F' bgborderx='0' bgbordery='0'/>";
		
      $xmlfooter = "</manialink></manialinks>";

		  $content = $xmlheader;

			$leftcell = "<cell width='0.125' bgcolor='000F'><text textcolor='8af' halign='right'>";
			$rightcell = "<cell width='0.275' bgcolor='000F'><text textcolor='ddd' halign='left'>";
			$content .= "<line><cell bgcolor='888F' width='.4'><text textcolor='0E0' halign='center'>Next Track Info</text></cell></line>
						<line height='.03'>
							" . $leftcell . "Name: </text></cell>"
							. $rightcell . htmlspecialchars($this->stripFormatting($trackinfo['Name'])) . "</text></cell>
						</line>
						<line height='.03'>
							" . $leftcell . "Env: </text></cell>"
							. $rightcell . $trackinfo['Environnement'] . "</text></cell>
						</line>
						<line height='.03'>
							" . $leftcell . "Mood: </text></cell>"
							. $rightcell . $trackinfo['Mood'] . "</text></cell>
						</line>
						<line height='.03'>
							" . $leftcell . "Author: </text></cell>"
							. $rightcell . $trackinfo['Author'] . "</text></cell>
						</line>";

    	switch ($GameMode)
			{
      	case 0:		// Rounds
					$c1l = 'Mode:';
					$c1r = 'Rounds';
					$c2l = 'Points:';
					$c2r = $GameInfo['RoundsPointsLimit'];
					break;

				case 1:		// TimeAttack
					$c1l = 'Author Time:';
					$c1r = formatTime($trackinfo['AuthorTime']);
					$c2l = 'Time Limit:';
					$c2r = formatTime($nexttime);
					break;

				case 2:		// Teams
					$c1l = 'Mode:';
					$c1r = 'Teams';
					$c2l = 'Points:';
					$c2r = 'Limit ' . $GameInfo['TeamsPointsLimit'] . ' / Max ' . $GameInfo['TeamMaxPoints'];
					break;

				case 3:		// Laps
					$c1l = 'Laps:';
					$c1r = $GameInfo['LapsNbLaps'];
					$c2l = 'Time Limit:';
					$c2r = formatTime($GameInfo['LapsTimeLimit']);
					break;

				case 4:		// Stunts
					$c1l = 'Mode:';
					$c1r = 'Stunts';
					$c2l = '';
					$c2r = '';
					break;
			}

			$content .= "<line height='.03'>
							" . $leftcell . $c1l . " </text></cell>"
							. $rightcell . $c1r . "</text></cell>
						</line>
						<line height='.03'>
							" . $leftcell . $c2l . " </text></cell>"
							. $rightcell . $c2r . "</text></cell>
						</line>";

			$content .= $xmlfooter;

				foreach($this->Aseco->server->players->player_list as $pl){
				  $this->sendMLtoLogin($pl->login, $content);
				}
		}
	}  //  showTrackInfo
	
	function showRanks(){
		
		$xmlheader = "<?xml version='1.0' encoding='utf-8' ?>
		<manialinks><custom_ui>
		<notice visible='true'/>
		<challenge_info visible='false'/>
		<net_infos visible='true'/>
		<chat visible='true'/>
		<checkpoint_list visible='true'/>
		<round_scores visible='true'/>
		<scoretable visible='true'/>
		<global visible='true'/>
		</custom_ui>
		<manialink posx='1' posy='0.27' id='203'>
		<type>default</type>
		<format textsize='1' textcolor='000f' />
	    <background bgcolor='000F' bgborderx='0' bgbordery='0'/>";
		
    $xmlfooter = "</manialink></manialinks>";

		$content = $xmlheader;


    $leftcell = "<cell width='0.033' bgcolor='000F'><text textcolor='ddd' halign='center'>";
		$rightcell = "<cell width='0.28' bgcolor='000F'><text textcolor='8af' halign='left'>";
		$avgcell = "<cell width='0.06' bgcolor='000F'><text textcolor='8af' halign='left'>";
		
		$content .= "<line><cell bgcolor='888F' width='.37'><text textcolor='FF0' halign='center'>Current top20 Ranking</text></cell></line>";
		

		$query = 'SELECT p.NickName, r.avg, ROUND(r.avg/10000, 2) as rank FROM players p LEFT JOIN rs_rank r ON (p.Id=r.PlayerId) WHERE r.avg!=0 ORDER BY r.avg ASC LIMIT 20';
		$res = mysql_query($query);
		$i = 1;
		$top = 20;
		while ($row = mysql_fetch_object($res)) {
			$content .= "<line height='.03'>" . $leftcell . $i . ". </text></cell>";
			$nickname = str_replace("\$w", '', $row->NickName);
// original			$content .= $rightcell . htmlspecialchars($nickname) . "</text></cell>";
			$content .= $rightcell . htmlspecialchars($this->getValidUTF8String($nickname)) . "</text></cell>";
			
			$content .= $avgcell . $row->rank . "</text></cell></line>";
			$i++;
    }
        		
    $content .= $xmlfooter;

		foreach($this->Aseco->server->players->player_list as $pl) {
				  $this->sendMLtoLogin($pl->login, $content);
		} 
	} //showRanks
	
	
	function onStatusChange3() { // Hide everything
		$content = "<?xml version='1.0' encoding='UTF-8'?>
 					<manialinks>
		              <manialink id='201'></manialink>
		              
		              <manialink id='203'></manialink>
              
   		 			</manialinks>";
   		 			// 		              <manialink id='202'></manialink>  <manialink id='204'></manialink>		
		foreach($this->Aseco->server->players->player_list as $pl)
			{
	           $this->sendMLtoLogin($pl->login, $content);
			}
	}  //  onStatusChange3

	function start($aseco_ext) {
		$this->Aseco = $aseco_ext;
  }

	function sendMLtoLogin($login, $xml){
		//$this->Aseco->console_text($xml);
		$this->Aseco->client->addCall("SendDisplayManialinkPageToLogin", array($login, $xml, 0, false));
	}

	/**
	 * Handles mouse click on Karma questions
	 *
	 * @param mixed $command
	 */
	function doHandleClick($aseco, $command){
		
		if (($command[2] == 11111) || ($command[2] == 22222) || ($command[2] == 33333)) {
		
			$action = substr($command[2], 0, 1);
			$this->executeKarma($command[1], $action);
			$content = "<?xml version='1.0' encoding='UTF-8'?>
 					<manialinks>
		              <manialink id='204'></manialink>		              
   		 			</manialinks>";

			$this->sendMLtoLogin($command[1], $content);		
    }

	}
	 
	/**
	 * Executes Karma votes
	 *
	 * @param String $login
	 * @param String $action
	 */
	function executeKarma($login, $action){
		$cmd=array();
		$cmd['author'] = $this->Aseco->server->players->getPlayer($login);
		if ($action==1){
			$vote = 1;
		} else if ($action==2){
			$vote = -1;
		} else return;

		KarmaVote($this->Aseco, $cmd, $vote);
	}


// added by FoxShadow *********************************************************************	
	/**
	 * Returns a valid UTF String and replaces faulty byte values with a given string
	 * Thanks a lot to Slig for his original tm_substring function.
	 *
	 * @param String $str
	 * @param String $replaceInvalidWith
	 * @return String
	 */
	function getValidUTF8String($str, $replaceInvalidWith = ''){
		$s = strlen($str); // byte string length
		$pos = 0; // current byte pos in string
		$newStr = '';

		while($pos < $s){
			$c = $str[$pos];
			$co = ord($c);

			if($co >= 240 && $co <248){ // 4 bytes utf8 => 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
				if(($pos+3 < $s ) &&
				(ord($str[$pos+1]) >= 128) && (ord($str[$pos+1]) < 192) &&
				(ord($str[$pos+2]) >= 128) && (ord($str[$pos+2]) < 192) &&
				(ord($str[$pos+3]) >= 128) && (ord($str[$pos+3]) < 192)){
					// ok, it was 1 character, increase counters
					$newStr.=substr($str, $pos, 4);
					$pos += 4;
				}else{
					// bad multibyte char
					$newStr.= $replaceInvalidWith;
					$pos++;
				}

			}elseif($co >= 224){ // 3 bytes utf8 => 1110xxxx 10xxxxxx 10xxxxxx
				if(($pos+2 < $s ) &&
				(ord($str[$pos+1]) >= 128) && (ord($str[$pos+1]) < 192) &&
				(ord($str[$pos+2]) >= 128) && (ord($str[$pos+2]) < 192)){
					// ok, it was 1 character, increase counters
					$newStr.=substr($str, $pos, 3);
					$pos += 3;
				}else{
					// bad multibyte char
					$newStr.= $replaceInvalidWith;
					$pos++;
				}

			}elseif($co >= 192){ // 2 bytes utf8 => 110xxxxx 10xxxxxx
				if(($pos+1 < $s ) &&
				(ord($str[$pos+1]) >= 128) && (ord($str[$pos+1]) < 192)){
					$newStr.=substr($str, $pos, 2);
					$pos += 2;
				}else{
					// bad multibyte char
					$newStr.=$replaceInvalidWith;
					$pos++;
				}

			}else{
				// ascii char or erroneus middle multibyte char
				if($co >=128)
				$newStr.=$replaceInvalidWith;
				else
				$newStr.=$str[$pos];

				$pos++;

			}
		}
		return $newStr;
	}
// end of added     *********************************************************************


  function stripFormatting($input) {
		return
        //Replace all occurances of a null character back with a pair of dollar
        //signs again
        str_replace("\0", '$$',
            //Replace links (introduced with the advent of TMU)
            preg_replace(
                '/
                #Strip TMU H, L and P links by stripping everything between each
                #square bracket pair until another $H, $L or $P sequence is found.
                #This allows a $H to close a $L and vice versa, as does the game
                \\$[hlp](.*?)(?:\\[.*?\\](.*?))*(?:\\$[hlp]|$)
                /ix',
                //Keep the second and third capturing groups if present
                '$1$2',
                //Replace various patterns beginning with an unescaped dollar
                preg_replace(
                    '/
                    #Match a single dollar sign and any of the following:
                    \\$
                    (?:
                        #Strip colour codes by matching any hexadecimal character
                        #and any other two characters following it
                        [0-9a-f]..
                        #Strip any single character that does not match the above rule
                        #and is not an H, L or P link
                        |[^hlp]
                        #Strip the dollar sign if it is at the end of the string
                        |$
                    )
                    #Ignore alphabet case, ignore whitespace in pattern & use UTF-8 mode
                    /ixu',
                    //Replace any matches with nothing (i.e. strip matches)
                    '',
                    //Replace all occurances of dollar sign pairs with a null character
                    str_replace('$$', "\0", $input)
                )
            )
        )
     ;
	} //stripformatting


}


Aseco::registerEvent('onStartup', 'showranks_startUp');
	
	function showranks_startUp($aseco) {
		global $ShowInfo;
		$ShowInfo = new ShowInfo();
		$ShowInfo->setAuthor('Assembler Maniac');
		$ShowInfo->setVersion(1.0);
		$ShowInfo->setDescription('Show Ranks Info During Intermission');
		$ShowInfo->start($aseco);
  }
	
Aseco::registerEvent('onEndRace', 'showranks_endRace');

	function showranks_endRace(){
		global $ShowInfo;
		$ShowInfo->showRecords();
//	    $ShowInfo->showTrackInfo();
	    $ShowInfo->showRanks();
//	    $ShowInfo->onEndRace();
	}
	
Aseco::registerEvent('onStatusChangeTo3', 'showranks_statusChange');

	function showranks_statusChange(){
		global $ShowInfo;
		$ShowInfo->onStatusChange3();
	}

Aseco::registerEvent('onPlayerManialinkPageAnswer', 'handleClick');

	function handleClick($aseco, $command){
		global $ShowInfo;
		$ShowInfo->doHandleClick($aseco, $command);
	}


Image
Image
Image

harrii
pedestrian
pedestrian
Posts: 9
Joined: 27 Nov 2008 15:31
Owned TM-games: TMNF, TMUF

Re: [XAseco] Plugin ShowInfo

Post by harrii » 01 Dec 2008 20:48

Thanks FoxShadow, that seemed to fix the problem :)

I have here my own version to my own needs (with your fix):
- it shows only ranks and karma question
- top 25 ranks are shown and they fit better to the screen (thanks to Samppa)

http://koti.mbnet.fi/hluoma/muuta/plugi ... fo.php.zip

Post Reply