ASECO2.x Plugin | Player join/leave message on chat

This forum is dedicated to the Aseco/Rasp 2 server records and control script by Flo and Assembler Maniac. Announcements and issues can be discussed in this forum.

Moderators: Flo, f*ckfish, Assembler Maniac, TM-Patrol

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

Re: ASECO2 Plugin | Player join/leave message on chat

Post by Xymph » 06 May 2008 22:13

w1lla wrote:well i just wanted to help but i do miss 1 thing in your plugin a zone feature
Ok ok. :) But I'm not sure what you mean by 'zone feature'. My version extracts the country zone from the entire location string and displays that where TMN has its 3-character nation string. Displaying the full location would make the entire message way too long, with some subzones being nested three levels deep.
And your version appears to do the same, so what do you mean?
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
daemon
sunday driver
sunday driver
Posts: 68
Joined: 09 Mar 2006 17:28
Location: México
Contact:

Re: ASECO2 Plugin | Player join/leave message on chat

Post by daemon » 06 May 2008 23:15

xis101 wrote:thanks for this plugin. is it possible to get a more detailed info about the zone?

I mean, can you display for example "from country/region/city"? :)
Hi, this version displays zone info where available.

Example:

Code: Select all

xuser from Germany|Bavaria|Munich connected [World Rank: 12 123 | Local Rank: 13/37]
Download:
http://www.fileden.com/files/2008/4/22/ ... thzone.rar
Image
It's the decisions you make, when you have no time to make them, that define who you are.

User avatar
w1lla
TM-Patrol
TM-Patrol
Posts: 1466
Joined: 23 May 2007 07:20
Owned TM-games: TMU, TMN, TMF
Manialink(s): intr
Location: Venray

Re: ASECO2 Plugin | Player join/leave message on chat

Post by w1lla » 07 May 2008 06:27

Xymph wrote:
w1lla wrote:well i just wanted to help but i do miss 1 thing in your plugin a zone feature
Ok ok. :) But I'm not sure what you mean by 'zone feature'. My version extracts the country zone from the entire location string and displays that where TMN has its 3-character nation string. Displaying the full location would make the entire message way too long, with some subzones being nested three levels deep.
And your version appears to do the same, so what do you mean?
I mean that it will show something like; xuser joined the game from limburg NED.

thats what i meant but no worries about your original code i just want to help people get there plugin usefull to others even if an other program uses a kinda of code allready

Code: Select all

tmnforever is nations and united makes it special. tmnforever has united. I need united!

User avatar
w1lla
TM-Patrol
TM-Patrol
Posts: 1466
Joined: 23 May 2007 07:20
Owned TM-games: TMU, TMN, TMF
Manialink(s): intr
Location: Venray

Re: ASECO2.x Plugin | Player join/leave message on chat

Post by w1lla » 07 May 2008 12:52

Code: Select all

<?php
/*
orginal code by daemon
edited by w1lla for xaseco.
7-5-08 : made it get good for xaseco with this line 
		$PlayerDetailedInfo = $aseco->client->getResponse();
		$path = $PlayerDetailedInfo['Path'];
		$zone = substr($path, strpos($path, '|')+1);
		
*/
Aseco::registerEvent('onPlayerConnect', 'pconnect');
Aseco::registerEvent('onPlayerDisconnect', 'pdisconnect');


	function pconnect($aseco, $player)
	{
	global $rasp, $feature_ranks;
	
		$aseco->client->query('GetDetailedPlayerInfo', $player->login);
		$PlayerDetailedInfo = $aseco->client->getResponse();
		$path = $PlayerDetailedInfo['Path'];
		$zone = substr($path, strpos($path, '|')+1);	
		$srank = $GetPlayerInfo['LadderStats']['PlayerRankings']['0']['Ranking'];
		$rank = str_replace(' ', '$n $m', number_format($player->ladderrank, 0, ' ', ' '));
		$message = stripColors($player->nickname).$player.' $39ffrom $fff'.$zone.' $39fconnected [World Rank: $fff'.$rank.' $39f| '.$rasp.''.$rasp.'';
		if ($feature_ranks) {
		$message .= $white.'Local Rank: $fff'.$rasp->getRank($player->login);
	}
		$aseco->client->query('ChatSendServerMessage', $message);
		
	}  

	function pdisconnect($aseco, $player)
	{
	global $rasp, $feature_ranks;
		$message = stripColors($player->nickname).' $39fdisconnected';
		$aseco->client->query('ChatSendServerMessage', $message);
	}  

	function showRank($login) {
		global $minrank;

		$pid = $aseco->getPlayerId($login);
		$query = 'SELECT avg FROM rs_rank
		          WHERE playerID=' . $pid;
		$res = mysql_query($query);
		if (mysql_num_rows($res) > 0) {
			$row = mysql_fetch_array($res);
			$query2 = 'SELECT playerid FROM rs_rank ORDER BY avg ASC';
			$res2 = mysql_query($query2);
			$rank = 1;
			while ($row2 = mysql_fetch_array($res2)) {
				if ($row2['playerid'] == $pid) break;
				$rank++;
			}
			$message = formatText($aseco->messages['RANK'][0],
			                      $rank, mysql_num_rows($res2),
			                      sprintf("%4.1F", $row['avg'] / 10000));
			$message = $aseco->formatColors($message);
			$aseco->client->query('ChatSendServerMessageToLogin', $message, $login);
			mysql_free_result($res2);
		} else {
			$message = formatText($aseco->messages['RANK_NONE'][0], $minrank);
			$message = $aseco->formatColors($message);
			$aseco->client->query('ChatSendServerMessageToLogin', $message, $login);
		}
		mysql_free_result($res);
		}
?>


this code works for xaseco.

Code: Select all

tmnforever is nations and united makes it special. tmnforever has united. I need united!

User avatar
J-S
happy cruiser
happy cruiser
Posts: 149
Joined: 24 Apr 2008 18:20
Owned TM-games: TMN,TMUF,TMO,TMS
Manialink(s): shark
Location: Grenoble - France
Contact:

Re: ASECO2.x Plugin | Player join/leave message on chat

Post by J-S » 07 May 2008 13:07

Code: Select all

<?php

class JoinLeave extends Plugin {

	function pconnect($player)
	{
		$this->Aseco->client->query('GetDetailedPlayerInfo', $player->login);
		$PlayerDetailedInfo = $this->Aseco->client->getResponse();
		$path = $PlayerDetailedInfo['Path'];
		$zone = substr($path, strpos($path, '|')+1);	
		$pos = strpos($zone, '|');
		if ($pos == false) {
			$zone = $zone; 
		}
		else {
			$zone = substr($zone, 0, $pos);	
		}
		$rank = $PlayerDetailedInfo['LadderStats']['PlayerRankings']['0']['Ranking'];
		$rank = str_replace(' ', '$n $m', number_format($rank, 0, ' ', ' '));
		$localrank = $this->sRank($player);
		if ($localrank[0] == 0){
			if($rank == -1)
			{
			$message = stripFormatting($player->nickname).' $39ffrom $fff'.$zone.' $39fconnected [World Rank: $fff Not Ranked $39f| Local Rank: $fff Not Ranked $39f]';
			}
			else {
			$message = stripFormatting($player->nickname).' $39ffrom $fff'.$zone.' $39fconnected [World Rank: $fff'.$rank.' $39f| Local Rank: $fff Not Ranked $39f]';
			}
		}
		else{
		$message = stripFormatting($player->nickname).' $39ffrom $fff'.$zone.' $39fconnected [World Rank: $fff'.$rank.' $39f| Local Rank: $fff'.$localrank[0].'/'.$localrank[1].'$39f]';
		}
		$this->Aseco->addCall('ChatSendServerMessage', array($message));	
	}  

	function pdisconnect($player)
	{
		$message = stripFormatting($player->nickname).' $39fdisconnected';
		$this->Aseco->addCall('ChatSendServerMessage', array($message));
	}  

	function sRank($player) {
		$mode = $this->Aseco->server->gameinfo->getMode();
		$pid = $this->Aseco->plugins['LocalDb']->dbGetPlayerId($player);
		$query = 'SELECT avg FROM rs_rank WHERE playerID=' . $pid . ' ORDER BY avg ASC';
		$res = mysql_query($query);
		if (mysql_num_rows($res) > 0) {
			$row = mysql_fetch_array($res);
			$query2 = 'SELECT * FROM rs_rank WHERE avg>0 and avg <' . $row['avg'];
			$res2 = mysql_query($query2);
			$query3 = 'SELECT * FROM rs_rank';
			$res3 = mysql_query($query3);
			$message[0] = mysql_num_rows($res2)+1;
			$message[1] = mysql_num_rows($res3);
			mysql_free_result($res2);
			mysql_free_result($res3);
			return ($message);
		} else {
			$message[0] = 0;
			$message[1] = 0;
			return ($message);
		}
		mysql_free_result($res);
	}

}

$_PLUGIN = new JoinLeave();
$_PLUGIN->addEvent('onPlayerConnect', 'pconnect');
$_PLUGIN->addEvent('onPlayerDisconnect', 'pdisconnect');
$_PLUGIN->setAuthor('Lacho aka daemon');
$_PLUGIN->setVersion(0.1);
$_PLUGIN->setDescription('When a player joins or leaves, it displays the info on the chat (including Nation, World Rank and Local Rank)');
?>
hi Everybody !
Personally, I change a little part of the code. Instead of display : World Rank: -1 and Local Rank:0/0 when the player haven't classification on the server or on the ladder, i display "Not Ranked"

Ptitzizi
road tourist
road tourist
Posts: 104
Joined: 03 May 2008 15:13
Owned TM-games: TMF

Re: ASECO2.x Plugin | Player join/leave message on chat

Post by Ptitzizi » 08 May 2008 01:00

Hi,

thank you very much for your plugin, I love it !
Now I'd like to see if the player wich connected is an admin of the server and if he plays on TMUF or TMNF... I tried to lookin for but I did'nt find anything.
Someone knows about that ?

Thanks again and good luck for the next :)

xis101
happy cruiser
happy cruiser
Posts: 154
Joined: 14 Aug 2006 01:22
Owned TM-games: TMUF
Manialink(s): gn
Contact:

Re: ASECO2 Plugin | Player join/leave message on chat

Post by xis101 » 08 May 2008 06:13

daemon wrote: Hi, this version displays zone info where available.

Example:

Code: Select all

xuser from Germany|Bavaria|Munich connected [World Rank: 12 123 | Local Rank: 13/37]
Download:
http://www.fileden.com/files/2008/4/22/ ... thzone.rar
thx deamon, works fine :D

User avatar
J-S
happy cruiser
happy cruiser
Posts: 149
Joined: 24 Apr 2008 18:20
Owned TM-games: TMN,TMUF,TMO,TMS
Manialink(s): shark
Location: Grenoble - France
Contact:

Re: ASECO2.x Plugin | Player join/leave message on chat

Post by J-S » 08 May 2008 08:39

J-S wrote:

Code: Select all

<?php

class JoinLeave extends Plugin {

	function pconnect($player)
	{
		$this->Aseco->client->query('GetDetailedPlayerInfo', $player->login);
		$PlayerDetailedInfo = $this->Aseco->client->getResponse();
		$path = $PlayerDetailedInfo['Path'];
		$zone = substr($path, strpos($path, '|')+1);	
		$pos = strpos($zone, '|');
		if ($pos == false) {
			$zone = $zone; 
		}
...}

$_PLUGIN = new JoinLeave();
$_PLUGIN->addEvent('onPlayerConnect', 'pconnect');
$_PLUGIN->addEvent('onPlayerDisconnect', 'pdisconnect');
$_PLUGIN->setAuthor('Lacho aka daemon');
$_PLUGIN->setVersion(0.1);
$_PLUGIN->setDescription('When a player joins or leaves, it displays the info on the chat (including Nation, World Rank and Local Rank)');
?>
hi Everybody !
Personally, I change a little part of the code. Instead of display : World Rank: -1 and Local Rank:0/0 when the player haven't classification on the server or on the ladder, i display "Not Ranked"
my change update with the zone ... :

Code: Select all

<?php

class JoinLeave extends Plugin {

	function pconnect($player)
	{
		$this->Aseco->client->query('GetDetailedPlayerInfo', $player->login);
		$PlayerDetailedInfo = $this->Aseco->client->getResponse();
		$path = $PlayerDetailedInfo['Path'];
		$zone = substr($path, strpos($path, '|')+1);	
		$rank = $PlayerDetailedInfo['LadderStats']['PlayerRankings']['0']['Ranking'];
		$rank = str_replace(' ', '$n $m', number_format($rank, 0, ' ', ' '));
		$localrank = $this->sRank($player);
		if ($localrank[0] == 0){
			if($rank == -1)
			{
			$message = stripFormatting($player->nickname).' $39ffrom $fff'.$zone.' $39fconnected [World Rank: $fff Not Ranked $39f| Shark Rank: $fff Not Ranked $39f]';
			}
			else {
			$message = stripFormatting($player->nickname).' $39ffrom $fff'.$zone.' $39fconnected [World Rank: $fff'.$rank.' $39f| Shark Rank: $fff Not Ranked $39f]';
			}
		}
		else{
		$message = stripFormatting($player->nickname).' $39ffrom $fff'.$zone.' $39fconnected [World Rank: $fff'.$rank.' $39f| Shark Rank: $fff'.$localrank[0].'/'.$localrank[1].'$39f]';
		}
		$this->Aseco->addCall('ChatSendServerMessage', array($message));	
	}  

	function pdisconnect($player)
	{
		$message = stripFormatting($player->nickname).' $39fdisconnected';
		$this->Aseco->addCall('ChatSendServerMessage', array($message));
	}  

	function sRank($player) {
		$mode = $this->Aseco->server->gameinfo->getMode();
		$pid = $this->Aseco->plugins['LocalDb']->dbGetPlayerId($player);
		$query = 'SELECT avg FROM rs_rank WHERE playerID=' . $pid . ' ORDER BY avg ASC';
		$res = mysql_query($query);
		if (mysql_num_rows($res) > 0) {
			$row = mysql_fetch_array($res);
			$query2 = 'SELECT * FROM rs_rank WHERE avg>0 and avg <' . $row['avg'];
			$res2 = mysql_query($query2);
			$query3 = 'SELECT * FROM rs_rank';
			$res3 = mysql_query($query3);
			$message[0] = mysql_num_rows($res2)+1;
			$message[1] = mysql_num_rows($res3);
			mysql_free_result($res2);
			mysql_free_result($res3);
			return ($message);
		} else {
			$message[0] = 0;
			$message[1] = 0;
			return ($message);
		}
		mysql_free_result($res);
	}

}

$_PLUGIN = new JoinLeave();
$_PLUGIN->addEvent('onPlayerConnect', 'pconnect');
$_PLUGIN->addEvent('onPlayerDisconnect', 'pdisconnect');
$_PLUGIN->setAuthor('Lacho aka daemon');
$_PLUGIN->setVersion(0.1);
$_PLUGIN->setDescription('When a player joins or leaves, it displays the info on the chat (including Nation, World Rank and Local Rank)');
?>

User avatar
J-S
happy cruiser
happy cruiser
Posts: 149
Joined: 24 Apr 2008 18:20
Owned TM-games: TMN,TMUF,TMO,TMS
Manialink(s): shark
Location: Grenoble - France
Contact:

Re: ASECO2.x Plugin | Player join/leave message on chat

Post by J-S » 08 May 2008 10:05

What it would be necessary it is that the plugin announces if it is a admin which is connected or only a player, no ??

Ptitzizi
road tourist
road tourist
Posts: 104
Joined: 03 May 2008 15:13
Owned TM-games: TMF

Re: ASECO2.x Plugin | Player join/leave message on chat

Post by Ptitzizi » 10 May 2008 14:44

Small UP for the J-S request ;)

cdrw700
happy cruiser
happy cruiser
Posts: 129
Joined: 03 Dec 2006 09:15
Contact:

Re: ASECO2.x Plugin | Player join/leave message on chat

Post by cdrw700 » 10 May 2008 16:00

Me too i'd like that feature, i'm too lazy to write it ^^

User avatar
daemon
sunday driver
sunday driver
Posts: 68
Joined: 09 Mar 2006 17:28
Location: México
Contact:

Re: ASECO2.x Plugin | Player join/leave message on chat

Post by daemon » 10 May 2008 17:50

Hi, 1st post updated with new version, now shows if player is an admin, and also with J-S' fix.

Will see if I can make tmuf/tmnf feat work but don't think it is possible, since the player array doesn't contain such info. :?
Image
It's the decisions you make, when you have no time to make them, that define who you are.

Ptitzizi
road tourist
road tourist
Posts: 104
Joined: 03 May 2008 15:13
Owned TM-games: TMF

Re: ASECO2.x Plugin | Player join/leave message on chat

Post by Ptitzizi » 11 May 2008 15:29

You're a GOD :D

cdrw700
happy cruiser
happy cruiser
Posts: 129
Joined: 03 Dec 2006 09:15
Contact:

Re: ASECO2.x Plugin | Player join/leave message on chat

Post by cdrw700 » 11 May 2008 20:46

works perfectly but there's a little error .

at line 22:

Code: Select all

		if ($this->Aseco->isAdmin($player->login))  {	// Checks for admin privileges
			$adminornot = '[$0f3Admin]';
		}
should be replaced with :

Code: Select all

		if ($this->Aseco->isAdmin($player->login))  {	// Checks for admin privileges
			$adminornot = '$0f3[Admin]';
		}
the '[' wasn't colored, just a little thing ^^

nocturne
solid chaser
solid chaser
Posts: 1390
Joined: 08 Jun 2007 18:48
Owned TM-games: all
Contact:

Re: ASECO2.x Plugin | Player join/leave message on chat

Post by nocturne » 31 May 2008 22:48

Why not create a all-in-one version with some config parameters? You could even make the formatting customizable, or snag Xymph's country code function to give ppl the option of using the 3-digit country codes.... just an idea.

Post Reply