dedimania record question

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
rez667
cyclist
cyclist
Posts: 41
Joined: 18 May 2008 18:37
Owned TM-games: nations, united

dedimania record question

Post by rez667 » 19 May 2008 18:10

Is there a way to enable dedimania records to always show? or a plug in for it.. i see alot of servers with it, but no one in them likes to help me it seems.:-( any help is much appreciated..


rez

User avatar
Slig
Pit Crew
Pit Crew
Posts: 2124
Joined: 05 Sep 2005 17:51
Owned TM-games: ALL
Location: TraxicoLand (Fr)
Contact:

Re: dedimania record question

Post by Slig » 19 May 2008 18:25

Actually, on Forever, Dedimania is supported by Fast and Xaseco, so you need to use one of these 2 server scripts

rez667
cyclist
cyclist
Posts: 41
Joined: 18 May 2008 18:37
Owned TM-games: nations, united

Re: dedimania record question

Post by rez667 » 19 May 2008 20:04

yeah.. I didnt explain to well.. I have Xaseco running, and the dedimania plugin is working great.. I was just wondering if there is a way to have it showing at all times.. not just at the begining and the end.. kinda like under the timer, or right abouve the speedometer? i hope that explains my question a little better.


rez

Xymph
Pit Crew
Pit Crew
Posts: 5685
Joined: 19 Aug 2007 12:58
Owned TM-games: TMN, TMU, TMF, TM²
Contact:

Re: dedimania record question

Post by Xymph » 19 May 2008 20:31

rez667 wrote:yeah.. I didnt explain to well.. I have Xaseco running, and the dedimania plugin is working great.. I was just wondering if there is a way to have it showing at all times.. not just at the begining and the end.. kinda like under the timer, or right abouve the speedometer? i hope that explains my question a little better.
You mean in a HUD panel. A TMF-style graphics interface is slated for v1.00, and will likely include such a records widget.
Developer of XASECO for TMF/TMN ESWC & XASECO2 for TM²: see XAseco.org
Find your way around the Mania community from the TMN ESWC hub, TMF hub, TM² hub, and SM hub

rez667
cyclist
cyclist
Posts: 41
Joined: 18 May 2008 18:37
Owned TM-games: nations, united

Re: dedimania record question

Post by rez667 » 19 May 2008 22:07

cool man.. any idea of the approximate launch? Not really concerned.. just curious.. Also makes me hapy.. now i can stop driving myself crazy trying to get Mistrals aseco workin.. All this stuff is new to me.. thx for your patience..


rez

Xymph
Pit Crew
Pit Crew
Posts: 5685
Joined: 19 Aug 2007 12:58
Owned TM-games: TMN, TMU, TMF, TM²
Contact:

Re: dedimania record question

Post by Xymph » 19 May 2008 22:35

rez667 wrote:cool man.. any idea of the approximate launch? Not really concerned.. just curious.. Also makes me hapy.. now i can stop driving myself crazy trying to get Mistrals aseco workin.. All this stuff is new to me.. thx for your patience..
v0.99 is coming really soon (could be tomorrow). But building TMF-style windows and widgets and so on will take quite a while, so I can't predict an approximate launch for the following release yet.
Developer of XASECO for TMF/TMN ESWC & XASECO2 for TM²: see XAseco.org
Find your way around the Mania community from the TMN ESWC hub, TMF hub, TM² hub, and SM hub

starsoft
wheelbarrow operator
wheelbarrow operator
Posts: 18
Joined: 22 Apr 2008 06:47
Owned TM-games: TMN

Re: dedimania record question

Post by starsoft » 20 May 2008 04:19

I created a script like that on my server.
There are probably more of those scripts out there, but i wanted the creating of plugins a go. I'm not sure if i did it the right way but it works...
It currently (and thats the way i want it) only shows a persons PB on the server. The data is shown right beneath the best and last times and shows up with the command /pba. Here is the code, maybe Xymph is willing to throw an eye over it to see if i did something wrong or things could be done a cleaner/nicer way.
I hope it is of any use for you.

Code: Select all

<?php
/**
 * Personal best plugin
 * Shows an onscreen window with that players personal best in it.
 * Does not only show ranked times, but also unranked times.
 * Created by StarSoft
 *
 * Dependencies: None
 */
 
Aseco::addChatCommand('pba', 'Shows personal best in the screen during the round.');

Aseco::registerEvent('onPlayerConnect', 'pba_setupPB');
Aseco::registerEvent('onPlayerFinish', 'pba_roundStart');
Aseco::registerEvent('onPlayerDisconnect', 'pba_unsetPB');

function pba_setupPB($aseco, $player) {
	global $pba_settings;
  $pba_settings[$player->login]['showpb'] = -1;
}


function pba_unsetPB($aseco, $player) {
	global $pba_settings;

	if (!$pba_settings[$player->login]['showpb']) {
		unset($pba_settings[$player->login]);
	}
}


function chat_pba($aseco, $command){
  global $pba_settings;
  $player = $command['author'];
  $loginName = $player->login;
  $trackId = $pba_settings['trackId'];
  if (($pba_settings[$loginName]['showpb'] == 0) || ($pba_settings[$loginName]['showpb'] == -1)){
    $pba_settings[$loginName]['showpb'] = 1;
    $message = '{#server}> Onscreen personal best records:  Activated{#server}';
    $aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $loginName);
    $pb = getPB($trackId, $loginName);
    showPB($aseco, $loginName, $pb);
  }else{
    $pba_settings[$loginName]['showpb'] = 0;
    $message = '{#server}> Onscreen personal best records:  Deactivated{#server}';
    $aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $loginName);
    hidePB($aseco, $loginName);
  }
}


function pba_roundStart($aseco, $round_item){

  global $pba_settings;
  
  $loginName = $round_item->player->login;
  $trackId = $round_item->challenge->id;
  
  $pba_settings['trackId'] = $trackId;

  if ($pba_settings[$loginName]['showpb'] == 1){
    $pb = getPB($trackId, $loginName);
    showPB($aseco, $loginName, $pb);  
  }else if($pba_settings[$loginName]['showpb'] == 0){
    hidePB($aseco, $loginName);
  }
}

function showPB($aseco, $loginName, $pb){
  $manialink = '<manialink posx="-0.8" posy="0.5125" id="99">
  <type>default</type>
  <line height="0.05">
    <cell width="0.2" bgcolor="0004">
      <text textsize="2.0" textcolor="FFFF" halign="center">    PB   '. $pb .' </text>
    </cell>
  </line>
  </manialink>';
  $aseco->client->query('SendDisplayManialinkPageToLogin', $loginName, $manialink, 0, false);
}


function hidePB($aseco, $loginName){
  $aseco->client->query('SendHideManialinkPageToLogin', $loginName);
}


function getPB($trackId, $loginName){
  global $pba_settings;
  $sql = "SELECT records.Score FROM records LEFT JOIN players ON records.playerId = players.Id WHERE records.ChallengeId = ". $trackId ." AND players.Login = '". $loginName ."'";
  $qs = @mysql_query($sql);
  if (@mysql_num_rows($qs) < 1){
    $sql2 = "SELECT rs_times.score FROM rs_times LEFT JOIN players ON rs_times.playerID = players.Id WHERE players.Login = '". $loginName ."' AND challengeID = ". $trackId ." ORDER BY score ASC LIMIT 0,1";
    $qs2 = @mysql_query($sql2);
    if (@mysql_num_rows($qs2) < 1){
      $pb = '   -';
    }else{
      $rs2 = mysql_fetch_array($qs2);
      $pb = convertScore($rs2['score']);
    }
  }else{
    $rs = mysql_fetch_array($qs);
    $pb = convertScore($rs['Score']);
  }
  return $pb;
}

function convertScore($score){
  if ($score == -1){
    return "???";
  }else{
    $minutes = floor($score / 60000);
    $seconds = ($score - ($minutes * 60000))/1000;
    if ($seconds < 10){
      return $minutes .":0". number_format($seconds, 2);
    }else{
      return $minutes .":". number_format($seconds, 2);
    }
  }
}

?>

rez667
cyclist
cyclist
Posts: 41
Joined: 18 May 2008 18:37
Owned TM-games: nations, united

Re: dedimania record question

Post by rez667 » 20 May 2008 04:57

thanks man.. I'll use that one to.. Do you guys use n app to make these php scripts? or just notepad.. cause i have noticed alot, if not all of them, are very complex.. at least it seems like that to me..

thx again man..

rez

starsoft
wheelbarrow operator
wheelbarrow operator
Posts: 18
Joined: 22 Apr 2008 06:47
Owned TM-games: TMN

Re: dedimania record question

Post by starsoft » 20 May 2008 05:14

Well, any text editor will do. It is basic PHP but to get used to the aseco structure is a little different.
But i see now you ask for dedimania records... :oops: I dont have dedimania enabled on my server, so dont know about that. This is just record stored in your local database.
But i guess it is not too hard to show those times in the screen. Maybe someone who is more familiar with the dedimania plugin can modify it.

Post Reply