Custom messages in chat

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

Moderators: Xymph, TM-Patrol

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

Custom messages in chat

Post by k4nm4n »

Hi,
I'm using now TMN-ASM 0.1, but I must have a cronjob program for displaying messages every 30 seconds. My friend Amisxp had this from Slig for Fast and I'm asking if someone can set this for Xaseco (because I don't know how). I'll be happy if someone can give me some links for learning how to create those scripts.

GG :1
User avatar
f*ckfish
Pit Crew
Pit Crew
Posts: 1302
Joined: 15 Jun 2007 07:59
Owned TM-games: TMNF, TMUF
Location: Dresden, Germany
Contact:

Re: Custom messages in chat

Post by f*ckfish »

In './includes/jfreu.config.php' you can create own messages that will randomly be shown at the end of a race (just have a look at all the $messages**-variables). If you really want to display timer based messages you'll have to write you own plugin (which is not that complicated either).
Just create a php file in the './plugins' folder with your name of choice (like 'plugin.infos.php') with the following content:

Code: Select all

<?php

Aseco::registerEvent('onEverySecond', 'infos_everysecond');

global $lastinfotime;
global $infointerval;
global $infos;
$infointerval = 30; //message interval in seconds
$infos = array();

//define your messages
$infos[] = 'Fufi is nice!';
$infos[] = 'TrackMania is awesome!';
$infos[] = 'Yay, this Plugin rocks bigtime!';
// ...

$lastinfotime = 0;

function infos_everysecond($aseco){
	global $lastinfotime, $infointerval, $infos;
	$time = time();
	if ($lastinfotime + $infointerval <= $time){
		$lastinfotime = $time;
		
		//get a random index
		$index = rand(0, count($infos) - 1);
		//output info
		$aseco->client->query('ChatSendServerMessage', $infos[$index]);
		
	}
}

?>
Of course you'll have to activate this plugin by including it into the 'plugins.xml' file:

Code: Select all

<plugin>plugin.infos.php</plugin>
(everything is totally untested)
Last edited by f*ckfish on 04 Jan 2009 20:48, edited 2 times in total.
inactive, sorry
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: Custom messages in chat

Post by k4nm4n »

f*ckfish wrote:In './includes/jfreu.config.php' you can create own messages that will randomly be shown at the end of a race (just have a look at all the $messages**-variables). If you really want to display timer based messages you'll have to write you own plugin (which is not that complicated either).
Thanks Fufi. I tried to do with the fast plugin but I didn't know that I must insert this: "Aseco::registerEvent"
Do you have some links for learn this type of coding? Is this php or something else?
I'll try this now. :1 :lovetm

Ps. I know for Jfreu plugin but this isn't what I need, because Jfreu displays randomly.
User avatar
f*ckfish
Pit Crew
Pit Crew
Posts: 1302
Joined: 15 Jun 2007 07:59
Owned TM-games: TMNF, TMUF
Location: Dresden, Germany
Contact:

Re: Custom messages in chat

Post by f*ckfish »

This is php and you best learn how to create plugins by looking at and trying to understand existing ones. That's the way I learned how to develop for (X)Aseco and (a little) Fast. Of course you should have a basic understanding of how php works, too ;-)
inactive, sorry
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: Custom messages in chat

Post by k4nm4n »

Sorry to bother but I tried the plugin and it goes crazy. Displays randomly more messages together every few seconds.
User avatar
f*ckfish
Pit Crew
Pit Crew
Posts: 1302
Joined: 15 Jun 2007 07:59
Owned TM-games: TMNF, TMUF
Location: Dresden, Germany
Contact:

Re: Custom messages in chat

Post by f*ckfish »

Yeah, typo, change

Code: Select all

$interval = 30; //message interval in second
to

Code: Select all

$infointerval = 30; //message interval in second
(also changed it in the original post)
inactive, sorry
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: Custom messages in chat

Post by k4nm4n »

Now works, but displays messages randomly. I tried tu insert numbers in [], but it doesn't go :roflol: You know, I don't know what I'm doing.
I tried this:

Code: Select all

    
$infos[1] = 'Fufi is nice!';
$infos[2] = 'TrackMania is awesome!';
$infos[3] = 'Yay, this Plugin rocks bigtime!';

:1
User avatar
f*ckfish
Pit Crew
Pit Crew
Posts: 1302
Joined: 15 Jun 2007 07:59
Owned TM-games: TMNF, TMUF
Location: Dresden, Germany
Contact:

Re: Custom messages in chat

Post by f*ckfish »

What exactly do you want to display?
If it's just one message, just change

Code: Select all

 
$infos[] = 'Fufi is nice!';
$infos[] = 'TrackMania is awesome!';
$infos[] = 'Yay, this Plugin rocks bigtime!';
´
to

Code: Select all

$infos[] = 'Fufi is nice!';
and it will always show "Fufi is nice!"
inactive, sorry
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: Custom messages in chat

Post by k4nm4n »

It's more than one message I have. I have messages like: View your server status, War dates or qualifications, Some basic tips,... etc. For that is important the order of messages, but if is to complicated to do that I will not bother you with this. I thought it will be cool to have a plugin in Xaseco without other external tools like cronjob.
User avatar
f*ckfish
Pit Crew
Pit Crew
Posts: 1302
Joined: 15 Jun 2007 07:59
Owned TM-games: TMNF, TMUF
Location: Dresden, Germany
Contact:

Re: Custom messages in chat

Post by f*ckfish »

It's not complicated at all, I just don't know for sure, what you mean. Is it like that?

wait 30 seconds
"View your server status"
"War dates or qualifications"
"Some basic tips"
wait 30 seconds
"View your server status"
"War dates or qualifications"
"Some basic tips"

or like that:

wait 30 seconds
"View your server status"
wait 30 seconds
"War dates or qualifications"
wait 30 seconds
"Some basic tips"
wait 30 seconds
"View your server status"
wait 30 seconds
"War dates or qualifications"
wait 30 seconds
"Some basic tips"
inactive, sorry
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: Custom messages in chat

Post by k4nm4n »

Sorry, because I wasn't clear about that. :oops:
Like that:
wait 30 seconds
"View your server status"
wait 30 seconds
"War dates or qualifications"
wait 30 seconds
"Some basic tips"
wait 30 seconds
"View your server status"
wait 30 seconds
"War dates or qualifications"
wait 30 seconds
"Some basic tips"
User avatar
f*ckfish
Pit Crew
Pit Crew
Posts: 1302
Joined: 15 Jun 2007 07:59
Owned TM-games: TMNF, TMUF
Location: Dresden, Germany
Contact:

Re: Custom messages in chat

Post by f*ckfish »

okay, then that one should do the trick:

Code: Select all

<?php

Aseco::registerEvent('onEverySecond', 'infos_everysecond');

global $lastinfotime;
global $infointerval;
global $infos;
global $startindex;
$infointerval = 30; //message interval in seconds
$infos = array();

//define your messages
$infos[] = 'Fufi is nice!';
$infos[] = 'TrackMania is awesome!';
$infos[] = 'Yay, this Plugin rocks bigtime!';
// ...

$lastinfotime = 0;
$startindex = 0;

function infos_everysecond($aseco){
   global $lastinfotime, $infointerval, $infos, $startindex;
   $time = time();
   if ($lastinfotime + $infointerval <= $time){
      $lastinfotime = $time;
      
      //output info
      $aseco->client->query('ChatSendServerMessage', $infos[$startindex]);
      $startindex = ($startindex+1)%count($infos);
      
   }
}

?>
inactive, sorry
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: Custom messages in chat

Post by k4nm4n »

Tnx, I'll try when I come home. I Looked the script and a saw the change "global $startindex;". Do you have a link to the one good web page for all php commands?

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

Re: Custom messages in chat

Post by Xymph »

k4nm4n wrote:Do you have a link to the one good web page for all php commands?
Manual. :wink:
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
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: Custom messages in chat

Post by k4nm4n »

Tnx, Xymph :D And now I can start to learn something. :gobananas:
Post Reply