[TMF]New plugin for medals

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
Olymptor
sunday driver
sunday driver
Posts: 59
Joined: 16 May 2009 00:15
Owned TM-games: TMUF, TMO, TMS

[TMF]New plugin for medals

Post by Olymptor » 16 Jan 2012 18:08

Hi, i restart to try my old project : try to display for each player his PB and corresponding medal manialink picture on playerconnect, new challenge and palyerfinish if new PB.

I know what i want, i know what use but i'm always big noob in coding :ftw: so i try to code for better explanation.
This plugin doesn't work at all ^^ because gestion of functions is catastrophic and call of existing functions in anothers plugin too...

So i hope some of you are better than me and can take a moment for help me to make this functionnal.

Note : $oly_gbx_info works and i can use it in.

Thx
Oly.

Code: Select all

<?php
 
 /**
  ** Get current or new PB and display corresponding nadeo medals in a manialink for each player connected
  *
  * (Later : display an array in a manialink with all connected players (nickname is 'medal' in PB) where medal is manialink picture too.)
  */

  Aseco::registerEvent('onNewChallenge', 'oly_info_track');
  Aseco::registerEvent('onNewChallenge', 'update_player_list');
  Aseco::registerEvent('onPlayerConnect', 'update_all');
  Aseco::registerEvent('onEndRound', 'mask_medals');
   
	global $medals_posx, $medals_posy, $oly_gbx_info, $rasp, $aseco;
	
	
	// --> START CONFIG <-- //

	$medals_posx = -40;
	$medals_posy = 40;
	
	
	//onNewChallenge
	function oly_info_track ($lambda, $info){
	global $oly_gbx_info;
	
	$oly_gbx_info = array('TrackName'=>'','Okolje'=>'','Authortime'=>'','Gold'=>'','Silver'=>'','Bronze'=>'');
	
	$oly_gbx_info['TrackName'] = $info->name;
	$oly_gbx_info['Okolje'] = $info->environment; //'alpine', 'bay', 'coast', 'island', 'rally', 'speed', 'stadium'
	$oly_gbx_info['Authortime'] = $info->authortime;
	$oly_gbx_info['Gold'] = $info->goldtime;
	$oly_gbx_info['Silver'] = $info->silvertime;
	$oly_gbx_info['Bronze'] = $info->bronzetime;
	
	}
	
	function update_player_list ($aseco, $data) {
	global $rasp;

		if ($aseco->server->getGame() == 'TMF') {
			// update records panel for all players
			$ml_id = 0
			foreach ($aseco->server->players->player_list as &$player) {
				// remember personal best at start of track
				if ($data) {
					$pb_nb = $rasp->getPb($player->login, $aseco->server->challenge->id);
					$ml_id = $ml_id + 1;
					
				}
	
				find_medal ($aseco, $player, $pb_nb);
			}
		}
	}  // 
	
	function find_medal ($aseco, $player, $pb_nb) {
	global $aseco, $oly_gbx_info;
	
		if $pb_nb > $oly_gbx_info['Bronze'] {
			$medal = 'MedalSlot';
		}
		if $pb_nb > $oly_gbx_info['Silver'] {
			$medal = 'MedalSilver';
		}
		if $pb_nb > $oly_gbx_info['Gold'] {
			$medal = 'MedalGold';
		}
		if $pb_nb > $oly_gbx_info['AuthorTime'] {
			$medal = 'MedalGold';
		}
		else $medal = 'MedalSlot'; //No time on track
		
		display_oly_medals ($aseco, $player, $pb_nb, $medal);
	}
		
	
	function display_oly_medals ($aseco, $player, $pb, $medal) {
	global $aseco, $medals_posx, $medals_posy, $oly_gbx_info;
	
	$pb_str = strval($pb_nb);
	$player_str = strval($player);
		
	$ml = '<?xml version="1.0" encoding="UTF-8"?>';
	$ml .= '<manialink id="1758508'.$ml_id.'">';
	$ml .= '<frame posn="'.$medals_posx.' '.$medals_posy.' 0">';
	$ml .= '<quad posn="0 0 0" sizen="50 10 20" halign="left" valign="center" style="Bgs1InRace" substyle="NavButton"/>';
	$ml .= '<label sizen="45 9" posn="0 0" halign="left" valign="center" text="$f00TEST"/>';
	$ml .= '<label sizen="15 4" posn="-5 2" halign="left" valign="center" text="'.$oly_gbx_info['TrackName'].'"/>';
	$ml .= '<quad posn="1 2 0.11" sizen="75 3 0" halign="left" valign="top" style="Icons128x128_1" substyle="Solo"/>';
	$ml .= '<quad posn="4 2 0.11" sizen="75 3 0" halign="left" valign="top" style="MedalsBig" substyle="'.$medal.'"/>';
	$ml .= '<label sizen="15 4" posn="7 2" halign="left" valign="center" text=" in '.$pb_str.'"/>';
	$ml .= '</frame>';
	$ml .= '</manialink>';
	$aseco->client->query('SendDisplayManialinkPageToLogin', $player_str,  $ml, 0, false);
	}
	
	//onPlayerFinish
		
	// !!!! update PB and update Manialink if new medal !!!!
	
	//onEndRound
	function mask_medals ($lambda){
		
	$ml = '<?xml version="1.0" encoding="UTF-8"?>';
	$ml .= '<manialink id="1758508'.$ml_id.'"></manialink>';
		
	$lambda->client->query('SendDisplayManialinkPage', $ml, 1, false);
	}
	//onPlayerConnect
	mask_medals;
	update_player_list;
	
?>

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

Re: [TMF]New plugin for medals

Post by undef.de » 16 Jan 2012 18:57

Olymptor wrote:Hi, i restart to try my old project : try to display for each player his PB and corresponding medal manialink picture on playerconnect, new challenge and palyerfinish if new PB.

I know what i want, i know what use but i'm always big noob in coding :ftw: so i try to code for better explanation.
This plugin doesn't work at all ^^ because gestion of functions is catastrophic and call of existing functions in anothers plugin too...

So i hope some of you are better than me and can take a moment for help me to make this functionnal.
Very interesting idea! Let me take a look into your code. ;)
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: 1349
Joined: 31 Aug 2009 18:38
Owned TM-games: TMF, TM2C/S/V, SM
Manialink(s): undef, tmkarma
Location: Germany
Contact:

Re: [TMF]New plugin for medals

Post by undef.de » 18 Jan 2012 21:40

For everybody who is interested, here are my releases:

XAseco1: viewtopic.php?f=127&t=29278
XAseco2: viewtopic.php?f=127&t=29277
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

Post Reply