TM-FORUM

The TrackMania universal forum ^_^
It is currently 29 Apr 2016 11:23

All times are UTC + 1 hour




Post new topic Reply to topic  [ 68 posts ]  Go to page Previous  1, 2, 3, 4, 5
Author Message
 Post subject: Re: [Xaseco]Best Runs widget
PostPosted: 01 Feb 2012 16:51 
Offline
smooth traffic navigator
smooth traffic navigator

Joined: 21 May 2008 09:39
Posts: 192
Owned TM-games: TMUF
Hi,

Awesome, thank you very much :)

Regards,

Yorkshire.


Top
 Profile  
 
 Post subject: Re: [Xaseco]Best Runs widget
PostPosted: 19 Feb 2012 01:27 
Offline
speedy pilot
speedy pilot

Joined: 12 Mar 2011 00:44
Posts: 313
Owned TM-games: TMN, TMU, TMF,TM2all
Hi Afisse

Is it possible to put the scale factor in youre best cp plugin ?
Very handy that scale factor !

I tried to get cp times look like this :

CP1. time. Name driver.

But when I put CP in front of nr , all get mixed up !

Anyone suggestions ?


Top
 Profile  
 
 Post subject: Re: [Xaseco]Best Runs widget
PostPosted: 21 Feb 2012 22:46 
Offline
speedy pilot
speedy pilot

Joined: 12 Mar 2011 00:44
Posts: 313
Owned TM-games: TMN, TMU, TMF,TM2all
You still active ???


Top
 Profile  
 
 Post subject: Re: [Xaseco]Best Runs widget
PostPosted: 07 Apr 2012 23:03 
Offline
speedy pilot
speedy pilot

Joined: 12 Mar 2011 00:44
Posts: 313
Owned TM-games: TMN, TMU, TMF,TM2all
can not get this plugin to clear at score.

so it looks realy messy !

I tried what Ant said but it's not working for me , and that was ver. 1.4


Top
 Profile  
 
 Post subject: Re: [Xaseco]Best Runs widget
PostPosted: 08 Apr 2012 00:18 
Offline
TM-Patrol
TM-Patrol
User avatar

Joined: 01 Dec 2007 18:04
Posts: 1845
Location: London, England
Owned TM-games: TMN, TMUF, TM Wii
Try this for v1.5 to clear it at score (un-tested but looks ok to me)

plugin.bestruns.php
Code:
<?php
/*==============================================================================
Description : Display the best runs of the current track of all playerInfo,
Last Revision : 02/01/2011
Version : 1.5
Author : galaad
==============================================================================*/
Aseco::registerEvent('onStartup',          'OnStartup_bestruns');
Aseco::registerEvent('onNewChallenge',     'OnNewChallenge_bestruns');
Aseco::registerEvent('onPlayerFinish',     'OnPlayerFinish_bestruns');
Aseco::registerEvent('onEndRace',          'Clear_bestruns');
Aseco::addChatCommand('bestruns',        'Load config file of bestruns plugin');

/* Variables globales */
$bestruns;
$count;
$cps;
/* Config file */
$x;
$y;
$scale;
$nb_bestruns;
$nb_bestruns_with_cp;
$nb_max_checkpoints;

function chat_bestruns($aseco, $command){
    $author = $command["author"];
   if ($aseco->isMasterAdmin($author) OR $aseco->isAdmin($author)){
      $aseco->client->query('ChatSendServerMessage',
         $aseco->formatColors("Load Config BestRuns OK"));
      LoadConfig_bestruns();
   }
}

function OnStartup_bestruns($aseco, $empty){
   global $bestruns, $count;
   $bestruns = array();
   $count = 0;
   LoadConfig_bestruns ();
}

function OnNewChallenge_bestruns($aseco, $challenge){
   global $count, $cps;
   $cps = $challenge->nbchecks - 1;
   $count = 0;
   Clear_bestruns($aseco, $challenge);
}

function OnPlayerFinish_bestruns($aseco, $record){
   global $bestruns, $nb_bestruns, $count;
   if ($record->score > 0){
      if ($count == 0){
         $bestruns[0] = $record;
         $count++;
      }
      else if ($count < $nb_bestruns){
         for ($pos = 0; $pos < $count; $pos++){
            if ($record->score < $bestruns[$pos]->score){
               break;
            }
         }
         for ($i = $count - 1; $i >= $pos; $i--){
            $bestruns[$i + 1] = $bestruns[$i];
         }
         $bestruns[$pos] = $record;
         $count++;
      }
      else{
         if ($record->score < $bestruns[$nb_bestruns - 1]->score){
            for ($pos = 0; $pos < $count; $pos++){
            if ($record->score < $bestruns[$pos]->score){
               break;
            }
         }
         for ($i = $count - 1; $i >= $pos; $i--){
            $bestruns[$i + 1] = $bestruns[$i];
         }
         $bestruns[$pos] = $record;
         }
      }   
      Display_bestruns($aseco);
   }
}

function LoadConfig_bestruns(){
   global $x, $y, $scale, $orientation, $nb_bestruns;
   global $nb_bestruns_with_cp, $nb_max_checkpoints;
   $config = simplexml_load_file('bestruns.xml');
   $x = $config->x;
   $y = $config->y;
   $scale = floatval($config->scale);
   $nb_bestruns = $config->nb_bestruns;
   $nb_bestruns_with_cp = $config->nb_bestruns_with_cp;
   $nb_max_checkpoints = $config->nb_max_checkpoints;
}

function Display_bestruns($aseco){ // affiche les best runs
   global $x, $y, $nb_bestruns_with_cp, $nb_max_checkpoints, $scale;
   global $bestruns, $count, $cps;
   
   /* Frame widget */
   $x_frame_widget = $x;
   $y_frame_widget = $y;
   
   /* Internal Config */
   $textsize = 1;
   
   /* Cps config */
   $nb_col = 3;
   $textsize_cp = 0.9;
   
   $width_bestrun = 14;
   $height_main = 2.2;
   
   $xml='<?xml version="1.0" encoding="UTF-8"?>' . "\n";
   $xml.='<manialink id="342312">'. "\n";
   $xml.='<frame posn="' .$x_frame_widget. ' ' .$y_frame_widget. '">'. "\n";
   $xml.='<format textsize="'. $textsize .'"/>'. "\n";
   
   for($i = 0; $i < $count; $i++) { //for each bestruns
      /* Frame Best Run */
      $x_frame_bestrun = $i * $width_bestrun * $scale;
      echo "FRAME BEST RUN X = $x_frame_bestrun , scale = $scale, i = $i, w = $width_bestrun\n";
      $y_frame_bestrun = 0;
      
      /* Frame Main */
      $x_frame_main = 0;
      $y_frame_main = 0;
      
      $x_quad_main = 0;
      $y_quad_main = 0;
      $width_quad_main = $width_bestrun;
      $height_quad_main = $height_main;
      
      $x_offset_label_time = 0.6;
      $y_offset_label_time = -0.3;
      $x_label_time = (0 + $x_offset_label_time) * $scale;
      $y_label_time = (0 + $y_offset_label_time) * $scale;
      $width_label_time = 5.8;
      $height_label_time = 2;
      
      $x_offset_label_nickname = 0.6;
      $y_offset_label_nickname = -0.3;
      $x_label_nickname = ($width_label_time + $x_offset_label_nickname) * $scale;
      $y_label_nickname = (0 + $y_offset_label_nickname) * $scale;
      $width_label_nickname = 6.9;
      $height_label_nickname = 2;
      
      /* Frame Checkpoints */
      $x_frame_cps = 0;
      $y_frame_cps = (-$height_main) * $scale;
      
      /* Time */
      $minutes = (int) ($bestruns[$i]->score / 60000);
      $secondes = (int) (($bestruns[$i]->score - $minutes * 60000) / 1000);
      $centiemes = (int) (($bestruns[$i]->score - $minutes*60000 - $secondes*1000) / 10);
      $time ="$z". ($i + 1) .". $fff";
      $time .= "$minutes:";
      if ($secondes < 10) $time .= "0";   
      $time .= $secondes.'.';
      if ($centiemes < 10) $time .= "0";
      $time .= $centiemes;
      
      $xml.='<frame posn="'.$x_frame_bestrun.' '.$y_frame_bestrun.'">' ."\n";
      $xml.='<frame posn="'.$x_frame_main.' '.$y_frame_main.'">' . "\n";
      $xml.='<quad scale="'.$scale.'" posn="0 0" '
         .'sizen="'. $width_quad_main .' '. $height_quad_main
         .'" halign="left" valign="top" style="Bgs1InRace" substyle="NavButton" />' ."\n";
      ;
      $xml.='<label scale="'.$scale.'" posn="'.$x_label_time.' '
         .$y_label_time.'" sizen="'.$width_label_time.' '.$height_label_time
         .'" halign="left" valign="top" text="'.$time.'"/>'."\n";
         
      $xml.='<label scale="'.($scale).'" posn="' .$x_label_nickname. ' '
         .$y_label_nickname.'" sizen="'.$width_label_nickname.' '.$height_label_nickname
         .'" halign="left" valign="top" text="'.$bestruns[$i]->player->nickname.'"/>'."\n";
      $xml.='</frame>'."\n";
      
      /* Checkpoints */
      if ($i < $nb_bestruns_with_cp){
         $xml.='<frame posn="'.$x_frame_cps.' '.$y_frame_cps.'">'. "\n";
         $xml.='<format textsize="'. $textsize_cp .'"/>'. "\n";
         $j = 0;
         for ($j = 0; $j < $cps  AND $j < $nb_max_checkpoints; $j++){
         
            $cp = $bestruns[$i]->checks[$j];
            $minn = (int) (($cp) / 60000);
            $secc = (int) ((($cp) - $minn * 60000) / 1000);
            $cenn = (int) (($cp - $minn*60000 - $secc*1000) / 10);
            $textee ='$z$fff';
            $textee .= "$minn:";
            if ($secc < 10) $textee .= "0";   
            $textee .= $secc.'.';
            if ($cenn < 10) $textee .= "0";
            $textee .= $cenn;
            
            $width_quad_cp = 4.6;
            $height_quad_cp = 1.6;
            $x_quad_cp = ($j % $nb_col) * $width_quad_cp * $scale;
            $y_quad_cp = (- floor($j/$nb_col) * $height_quad_cp) * $scale;
            
            $y_offset_label_cp = -0.3;
            $x_label_cp =
               (($j % $nb_col) * $width_quad_cp + $width_quad_cp/2) * $scale;
            $y_label_cp = ((- floor($j/$nb_col) * $height_quad_cp)  + $y_offset_label_cp) * $scale;
            $width_label_cp = $width_quad_cp;
            $height_label_cp = $height_quad_cp;
            
            
            $xml.='<quad scale="'.$scale.'" posn="' .$x_quad_cp. " "
               . $y_quad_cp
               . '" sizen="'.$width_quad_cp.' '.$height_quad_cp
               .'" halign="left" valign="top" style="Bgs1InRace" substyle="NavButton" />' . "\n";
            $xml.='<label scale="'.$scale.'" posn="'
               .$x_label_cp. " "
               . $y_label_cp
               . '" sizen="'.$width_label_cp.' '.$height_label_cp
               .'" halign="center" valign="top" text="'.$textee.'"/>' . "\n";
         }
         $xml .= '</frame>'. "\n";
      }
      $xml .= '</frame>'. "\n";
   }
   
   $xml.= '</frame>' . "\n"
      .'</manialink>'."\n";
   echo $xml;
   $aseco->client->query("SendDisplayManialinkPage", $xml, 0, false); //requete d'affichage
}


function Clear_bestruns($aseco, $challenge){//efface le widget entre 2 challenges
   $xml = '<manialink id="342312"></manialink>';
    $aseco->client->query("SendDisplayManialinkPage", $xml, 1, false);
}
?>

The xml config from the download of v1.5 is still needed with this.

_________________
My TMF Hub --- Server


Top
 Profile  
 
 Post subject: Re: [Xaseco]Best Runs widget
PostPosted: 08 Apr 2012 01:44 
Offline
speedy pilot
speedy pilot

Joined: 12 Mar 2011 00:44
Posts: 313
Owned TM-games: TMN, TMU, TMF,TM2all
The above : copy and past and save as plugin. thats all ?

Ok I will try it , and let you know if it works .

Thanks a lot.

Do you have time to look into a cp plugin ?
I found a realy nice one , but it's very small.
I can not get it bigger, may I pm you about that ?


Top
 Profile  
 
 Post subject: Re: [Xaseco]Best Runs widget
PostPosted: 08 Apr 2012 12:04 
Offline
speedy pilot
speedy pilot

Joined: 12 Mar 2011 00:44
Posts: 313
Owned TM-games: TMN, TMU, TMF,TM2all
Oke Ant , I installed like you said.

It's working !!! :) Thanks man.

Btw can this shutdown ( dissapear ) at score also done with fufimenu ?
I have fufimenu at standard place , and at score it overlaps: Top rank.


Top
 Profile  
 
 Post subject: Re: [Xaseco]Best Runs widget
PostPosted: 08 Apr 2012 21:36 
Offline
TM-Patrol
TM-Patrol
User avatar

Joined: 01 Dec 2007 18:04
Posts: 1845
Location: London, England
Owned TM-games: TMN, TMUF, TM Wii
No problem, I only added one line of code so it was a simple fix really. As far as doing the same thing for the menu, you can follow this guide that achieves this perfectly - viewtopic.php?f=127&t=17450&start=150#p194871
If you still want to pm me about the cp plugin, thats fine - but I make no promises on whether I can solve anything with it or not :wink:

_________________
My TMF Hub --- Server


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 68 posts ]  Go to page Previous  1, 2, 3, 4, 5

All times are UTC + 1 hour


Who is online

Users browsing this forum: Google [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group