Looking for a plugin

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
shibster
pedestrian
pedestrian
Posts: 9
Joined: 12 May 2010 12:29
Owned TM-games: TMUF

Looking for a plugin

Post by shibster » 14 May 2010 23:57

Hey guys,

I tried to create plugins using other plugins and modify them, but they don't work at all ... (duh)
I was wondering if there is or if anyone wants to make the following plugins (or give me a hand in how to make em)

1) A plugin that shows the current song in a small window on the left hand side of the screen

2) A simple button that uses the command /music list

Thank you for readin ^^

nouseforname
swift roadking
swift roadking
Posts: 840
Joined: 20 Apr 2008 08:58
Owned TM-games: TMUF,TMNF, TMN
Manialink(s): therookies
Location: Germany
Contact:

Re: Looking for a plugin

Post by nouseforname » 15 May 2010 08:12

here we go. just add it to your plugin list.
have fun

plugin.nouse.song.php:

Code: Select all

<?php

// Xaseco plugin to display single manialink with actual song, button will execute "/music list
// by nouseforname

class nouseShowSong {

	private $buttonmainposition = '-53 24 1'; 	// manialink position x y z
	private $color = '$i$o$36f';				// color code of songname in button
	
	private $cur_song, $settings;

	// startup 
	function startUp($aseco){
		$this->Aseco = $aseco;
	}

	function nouseButtonOn() {
	
		$this->nouseGetCurrentSong();
		
		$xml = '<manialink id="0815470000133">
			<format style="TextCardInfoSmall" textsize="1" />
			<frame posn="'.$this->buttonmainposition.'">
				<quad posn="0 0 0" sizen="22 2.5"  halign="center" valign="center" style="Bgs1InRace" substyle="NavButton"  />
			<label posn="0 0.2 1" sizen="18 2" halign="center" valign="center" style="TextCardInfoSmall" text="'.$this->color . $this->cur_song.'" action="2009110574"/>
			</frame>
		</manialink>';
		$this->Aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));
	}

	function nouseButtonOff() {
		$xml = '<manialink id="0815470000133">
		<frame posn="0 0 0">
			<quad posn="0 0 0" sizen="0 0" halign="center" valign="center" action="2009110574" /> 
		</frame>
		</manialink>';
		$this->Aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));
	}

	function nouseGetCurrentSong() {
		global $music_server;
		// get current song and strip server path
		$this->Aseco->client->query('GetForcedMusic');
		$current = $this->Aseco->client->getResponse();
		if ($current['Url'] != '' || $current['File'] != '') {
			$current = str_replace($music_server->server, '',
			                       ($current['Url'] != '' ? $current['Url'] : $current['File']));
			if ($music_server->cachetags && isset($music_server->tags[$current]))
				$tags = $music_server->tags[$current];
			if ($music_server->stripdirs)
				$current = preg_replace('|.*[/\\\\]|', '', $current);
			if ($music_server->stripexts)
				$current = preg_replace('|\.[^.]+$|', '', $current);
			if ($music_server->cachetags && isset($tags))
				$current .= '{#music} : {#highlite}' . $tags['Title'] . '{#music} by {#highlite}' . $tags['Artist'];
		} else {
			$current = 'In-game music';
		}
		$this->cur_song = $current;
		return $this->cur_song;
	}
	
	function nouseButtonHandleClick($command) {
		$playerid = $command[0];
		$login = $command[1];
		$action = $command[2].'';
		
		if ($action == '2009110574'){
			$chat = array();
			$chat[0] = $playerid;
			$chat[1] = $login;
			$chat[2] = '/music list';
			$chat[3] = true;
			$this->Aseco->playerChat($chat);
		}
	}

}

global $nGCS;
$nGCS = new nouseShowSong(false);
Aseco::registerEvent('onStartup', array($nGCS, 'startUp'));
Aseco::registerEvent('onNewChallenge', array($nGCS, 'nouseButtonOn'));
Aseco::registerEvent('onPlayerConnect', array($nGCS, 'nouseButtonOn'));
Aseco::registerEvent('onEndRace', array($nGCS, 'nouseButtonOff'));
Aseco::registerEvent('onPlayerManialinkPageAnswer', 'nouseGetCurrentSongHandleButtonclick');

function nouseGetCurrentSongHandleButtonclick($aseco, $command) {
	global $nGCS;
	$nGCS->nouseButtonHandleClick($command);
}
?>
Owner of the Rookie servers and some more. :)
Rookies HP
My Project
Rookies Manialinkcolor>

User avatar
Dexu
speedy pilot
speedy pilot
Posts: 577
Joined: 10 Feb 2008 20:03
Owned TM-games: TMU

Re: Looking for a plugin

Post by Dexu » 15 May 2010 18:46

thanks..
Image
Image
Image

ccx
sunday driver
sunday driver
Posts: 55
Joined: 07 Feb 2009 22:41
Owned TM-games: TMUF

Re: Looking for a plugin

Post by ccx » 18 Nov 2010 23:24

Hello Nouse,

Thx for that nice plugin, I like it !
I just changed position for 'in game' (below chat area) and 'end of game' (above results, instead of hiding it).

A bug exists when you relaunch a map just some seconds before next challenge load : the map reload (normal) but name of song has changed to next, as the song has not changed ('cause same map).

I tried to correct that by catching the event onRestartChallenge in charge to call the new Function RestoreSong.
Before computing the new current song, I store previous one to be able to restore it in case of relaunching a map.

Here is my code (just focus on variables $previousx & $currentxx)

Code: Select all

<?php

// Xaseco plugin to display single manialink with actual song, button will execute "/music list
// by nouseforname

global $previousx ;
global $currentxx ;
class nouseShowSong {

   private $buttonmainposition = '-37.5 -46.9 1';	// ccx manialink position x y z
   private $buttonmainposend   = '-01.0 +30.7 1';	// ccx added a variable manialink position x y z for end of race.
   private $cur_song, $settings;

   // startup
   function startUp($aseco){
      $this->Aseco = $aseco;
   }

   function nouseButtonOn() {
   
      $this->nouseGetCurrentSong();
      
	$xml = '<manialink id="0815470000133">
		<format style="TextCardInfoSmall" textsize="1" />
		<frame posn="'.$this->buttonmainposition.'">
			<quad  posn="00.0 0.0 0" sizen="45.4 02.8" halign="center" valign="center" style="Bgs1InRace"   substyle="NavButton"/>
			<label posn="00.0 0.2 1" sizen="44.1 02.5" halign="center" valign="center" style="TextCardInfoSmall" text="'.$this->cur_song.'" action="2009110574"/>
			<quad  posn="22.5 1.8 0" sizen="03.0 03.0"                                 style="Icons64x64_1" substyle="Music"/>
		</frame>
	</manialink>';
	$this->Aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));
   }

   function nouseButtonOff() {
	$xml = '<manialink id="0815470000133">
		<format style="TextCardInfoSmall" textsize="1" />
		<frame posn="'.$this->buttonmainposend.'">
			<quad  posn="00.0 0.0 0" sizen="45.4 02.8" halign="center" valign="center" style="Bgs1InRace"   substyle="NavButtonBlink"/>
			<label posn="00.0 0.2 1" sizen="44.1 02.5" halign="center" valign="center" style="TextCardInfoSmall" text="'.$this->cur_song.'" action="2009110574"/>
			<quad  posn="22.5 1.8 0" sizen="03.0 03.0"                                 style="Icons64x64_1" substyle="Music"/>
		</frame>
	</manialink>';
	$this->Aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));
   }
   function RestoreSong() {
	  	  echo('3 '.$previousx.CRLF);
		  echo('4 '.$currentxx.CRLF);   
	$current = $previousx;
	$this->cur_song = $current;
	  	  echo('5 '.$previousx.CRLF);
		  echo('6 '.$currentxx.CRLF);	
   }

   function nouseGetCurrentSong() {
      global $music_server;
	  $previousx = $currentxx;
      // get current song and strip server path
      $this->Aseco->client->query('GetForcedMusic');
      $current = $this->Aseco->client->getResponse();
      if ($current['Url'] != '' || $current['File'] != '') {
         $current = str_replace($music_server->server, '',
                                ($current['Url'] != '' ? $current['Url'] : $current['File']));
         if ($music_server->cachetags && isset($music_server->tags[$current]))
            $tags = $music_server->tags[$current];
         if ($music_server->stripdirs)
            $current = preg_replace('|.*[/\\\\]|', '', $current);
         if ($music_server->stripexts)
            $current = preg_replace('|\.[^.]+$|', '', $current);
         if ($music_server->cachetags && isset($tags))
            $current .= '{#music} : {#highlite}' . $tags['Title'] . '{#music} by {#highlite}' . $tags['Artist'];
      } else {
         $current = 'In-game music';
      }
		$pos     = strpos($current, '$', 1);
		$artistx = '$i$w'.trim(substr($current, 0    , $pos));
		$songxxx =   '$o'.trim(substr($current, $pos , strlen($current) - $pos));
		$nbcar   = 60 - strlen($artistx) - strlen($songxxx);
		if ($nbcar < 2) {$nbcar = 2;}
		$current   = $artistx . str_repeat(" ", $nbcar) . $songxxx;
		$currentxx = $current;

      $this->cur_song = $current;

	  	  echo('1 '.$previousx.CRLF);
		  echo('2 '.$current.CRLF);
		  
      return $this->cur_song;
   }
   
   function nouseButtonHandleClick($command) {
      $playerid = $command[0];
      $login = $command[1];
      $action = $command[2].'';
      
      if ($action == '2009110574'){
         $chat = array();
         $chat[0] = $playerid;
         $chat[1] = $login;
         $chat[2] = '/music list';
         $chat[3] = true;
         $this->Aseco->playerChat($chat);
      }
   }
}

global $nGCS;
$nGCS = new nouseShowSong(false);
Aseco::registerEvent('onStartup', array($nGCS, 'startUp'));
Aseco::registerEvent('onNewChallenge', array($nGCS, 'nouseButtonOn'));
Aseco::registerEvent('onPlayerConnect', array($nGCS, 'nouseButtonOn'));
Aseco::registerEvent('onEndRace', array($nGCS, 'nouseButtonOff'));
Aseco::registerEvent('onPlayerManialinkPageAnswer', 'nouseGetCurrentSongHandleButtonclick');
Aseco::registerEvent('onRestartChallenge', array($nGCS, 'RestoreSong'));

function nouseGetCurrentSongHandleButtonclick($aseco, $command) {
   global $nGCS;
   $nGCS->nouseButtonHandleClick($command);
}
?>
Last edited by ccx on 18 Nov 2010 23:39, edited 2 times in total.

ccx
sunday driver
sunday driver
Posts: 55
Joined: 07 Feb 2009 22:41
Owned TM-games: TMUF

Re: Looking for a plugin

Post by ccx » 18 Nov 2010 23:29

Grrr... : bug ! I can't go to the bottom of my post, each time cursor come back at the top..

To finish my request : can you say me why the variables $previousx & $currentxx are losing memory ? As you can see with the Echo (just here for debug). The only Echo I have is for the '2' which just shows.. current song.
Great :(

Thx a lot if you can help me to make it perfect :1

ccx.

PS : My song files are all named as '$f00Artist $fffSong.ogg'. That explains my variables $artistx and $songxxx. They could be loaded with variables $tags['Artist'] and $tags['Title']...

jouko100
speedy pilot
speedy pilot
Posts: 375
Joined: 10 Mar 2007 09:33
Location: finland
Contact:

Re: Looking for a plugin

Post by jouko100 » 19 Nov 2010 11:16

some error here maybe missing }

class nouseShowSong {

private $buttonmainposition = '-37.5 -46.9 1'; // ccx manialink position x y z
private $buttonmainposend = '-01.0 +30.7 1'; // ccx added a variable manialink position x y z for end of race.
private $cur_song, $settings;


try http://www.meandeviation.com/tutorials/ ... -check.php

nouseforname
swift roadking
swift roadking
Posts: 840
Joined: 20 Apr 2008 08:58
Owned TM-games: TMUF,TMNF, TMN
Manialink(s): therookies
Location: Germany
Contact:

Re: Looking for a plugin

Post by nouseforname » 19 Nov 2010 12:00

i will check it today afternoon.

but i think there would be a better way.

keep the off ML as it is.
add another ML for th score mode and call it at beginning of score mode
reload the get current song at beginrace

will check it later, but guess that will work
Owner of the Rookie servers and some more. :)
Rookies HP
My Project
Rookies Manialinkcolor>

ccx
sunday driver
sunday driver
Posts: 55
Joined: 07 Feb 2009 22:41
Owned TM-games: TMUF

Re: Looking for a plugin

Post by ccx » 20 Nov 2010 17:19

No Jouko, Xaseco would crash at start if missing } ;)

Sorry Nouse, I don't understand what you mean,
keep the off ML as it is
hmmm.. and the rest too :(

I'm a very new (and poor) PHP programmer please apologize :sweet:

By the way, debug say :
1
2 $i$w$f00Motorhead $o$f80Norn To Raise Hell.ogg

And if I restart the map :
Restart Challenge
3
4
5
6

The result of your plugin with my new positions in bad images :

Race (see area below chat) : Image

End of challenge : Image

Many thanks for your help !

ccx.

nouseforname
swift roadking
swift roadking
Posts: 840
Joined: 20 Apr 2008 08:58
Owned TM-games: TMUF,TMNF, TMN
Manialink(s): therookies
Location: Germany
Contact:

Re: Looking for a plugin

Post by nouseforname » 20 Nov 2010 17:36

i tried a bit, but didnt solve it yet, but i saw, in score there is no sence for the button and also no sence for display,. the next song is loaded at endrace. thats why the display changes if u restart after that.
but even if u update the trackname at beginround its the old name. very strange for me.
my problem is i didnt found a event to be sure its time to save the current trackname in the prev file.

button in score dont have function at all
display in score is already the new name and no music playing.
soo i dont see sense for that, but the restart thing is not really ok.
Owner of the Rookie servers and some more. :)
Rookies HP
My Project
Rookies Manialinkcolor>

jouko100
speedy pilot
speedy pilot
Posts: 375
Joined: 10 Mar 2007 09:33
Location: finland
Contact:

Re: Looking for a plugin

Post by jouko100 » 20 Nov 2010 17:43

No Jouko, Xaseco would crash at start if missing } ;)

try what i say .U dont understood me neither. And i said maybe missing}

ccx
sunday driver
sunday driver
Posts: 55
Joined: 07 Feb 2009 22:41
Owned TM-games: TMUF

Re: Looking for a plugin

Post by ccx » 20 Nov 2010 19:48

Indeed, Jouko, I tried your PHP check tool, it says a bracket is missing. But I'm sure : it opens line 9 and closes line 105.
So I think there is a bug in this tool, or I miss something, as I said, I'm a noob PHP programmer.. if I made a mistake, please just tell me what it is :roflol:

Nouse, the only sense to display the name of song at end of the challenge : if a player has appreciate the song and want to have it, then he has time to note it somewhere ;)

Please keep me informed about the possibility not to change the name of song while the map is the same.
I keep on searching by my side, but I'm afraid to be very slower than you :scene:

Thx for attention, m88 :)

ccx.

Northern Lights
sunday driver
sunday driver
Posts: 64
Joined: 27 Apr 2010 17:30
Owned TM-games: TMU

Re: Looking for a plugin

Post by Northern Lights » 20 Apr 2012 11:53

Hello, I am new to trying to create music on a server, but so far I have done the following :

1. I have found an FTP client
2. I have converted music to .ogg files
3. Uploaded the files to the FTP client and enabled them for public sharing
4. And I have got a direct link for the files on the site

Can I put this direct link somewhere into the php file ?

I'm not sure if I am doing things correctly so any help would be gratefully received.

:sweet: :tmforever:

ccx
sunday driver
sunday driver
Posts: 55
Joined: 07 Feb 2009 22:41
Owned TM-games: TMUF

Re: Looking for a plugin

Post by ccx » 29 Apr 2012 12:57

Hello !

Sorry for the delay, I was not able to login in tm-forum :(
Well in my mind, you don't have to touch to the .php scripts !
Just add this line in your "plugins.xml" :
<plugin>plugin.musicserver.php</plugin>
And now add your links to your "musicserver.xml", that should look like this (not mandatory to use tinyurl, just my choice ;) ) :

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>
<settings>
	<override_track>True</override_track>
	<auto_nextsong>True</auto_nextsong>
	<auto_shuffle>True</auto_shuffle>	
	<allow_jukebox>True</allow_jukebox>
	<strip_subdirs>True</strip_subdirs>
	<strip_exts>True</strip_exts>
	<cache_tags>false</cache_tags>
	<cache_readonly>true</cache_readonly>
	<cache_file>musicoggtags.xml</cache_file>

	<music_server>http://tinyurl.com/MyMusicIntoTM</music_server>

  <song_files>
<song>$F00_Tm_ $F80Bo Gta Iv.ogg</song>
<song>$F00_Tm_ $F80Bo Saw.ogg</song>
<song>$F00_Tm_ $F80Requiem For A Dream.ogg</song>
<song>$F0016130 $F80Chinese Trip.ogg</song>
<song>$F002 Unlimited $F80Megamix.ogg</song>
<song>$F002 Unlimited $F80No Limits.ogg</song>
<song>$F002 Unlimited $F80Shelter For A Rainy Day.ogg</song>
<song>$F002 Unlimited $F80Tribal Dance.ogg</song>
<song>$F00666 $F802 The Maxx.ogg</song>
<song>$F00666 $F80The 666 Megamix.ogg</song>
<song>$F00A3 $F80Too Sick To Pray.ogg</song>
<song>$F00Ac Dc $F80Can I Sit Next You Girl.ogg</song>
<song>$F00Ac Dc $F80Girls Got The Rythm.ogg</song>
<song>$F00Zz Top $F80Planet Of Women.ogg</song>
<song>$F00Zz Top $F80Viva Las Vegas.ogg</song>
  </song_files>
	<messages>
		<current>{#server}> {#music}The current song is: {#highlite}{1}</current>
		<next>{#server}>> {#music}{1}$z$s {#highlite}{2}$z$s{#music} loaded the next song: {#highlite}{3}</next>
		<reloaded>{#server}>> {#music}{1}$z$s {#highlite}{2}$z$s{#music} reloaded music config and cleared jukebox!</reloaded>
		<sorted>{#server}>> {#music}{1}$z$s {#highlite}{2}$z$s{#music} sorted song list and cleared jukebox!</sorted>
		<shuffled>{#server}>> {#music}{1}$z$s {#highlite}{2}$z$s{#music} shuffled song list and cleared jukebox!</shuffled>
		<jukebox>{#server}>> {#highlite}{1}{#music} jukeboxed song: {#highlite}{2}</jukebox>
		<jukebox_already>{#server}> {#music}You already have a song in the jukebox! Wait till it's been played before adding another.</jukebox_already>
		<jukebox_dupl>{#server}> {#music}This song has already been added to the jukebox, pick another one.</jukebox_dupl>
		<jukebox_notfound>{#server}> {#music}Song_ID not found - Type {#highlite}/music list{#music} to see all songs.</jukebox_notfound>
		<jukebox_drop>{#server}>> {#music}{#highlite}{1}{#music} dropped his song {#highlite}{2}{#music} from jukebox!</jukebox_drop>
		<jukebox_nodrop>{#server}> {#music}You don't have a song in the jukebox, use {#highlite}/music Song_ID{#music} to add one...</jukebox_nodrop>
		<jukebox_empty>{#server}> {#music}No songs in the jukebox, use {#highlite}/music Song_ID{#music} to add one...</jukebox_empty>
		<no_jukebox>{#server}> {#highlite}/music #{#music} is not currently enabled on this server.</no_jukebox>
		<shutdown>{#server}>> {#music}{1}$z$s {#highlite}{2}$z$s{#music} disabled server music!</shutdown>
	</messages>
</settings>
Good luck :)
Last edited by Xymph on 29 Apr 2012 13:08, edited 1 time in total.
Reason: Use code tags for code/configs/logs...

Post Reply