Page 2 of 4

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

Posted: 06 May 2008 22:13
by Xymph
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?

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

Posted: 06 May 2008 23:15
by daemon
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

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

Posted: 07 May 2008 06:27
by w1lla
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

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

Posted: 07 May 2008 12:52
by w1lla

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.

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

Posted: 07 May 2008 13:07
by J-S

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"

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

Posted: 08 May 2008 01:00
by Ptitzizi
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 :)

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

Posted: 08 May 2008 06:13
by xis101
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

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

Posted: 08 May 2008 08:39
by J-S
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)');
?>

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

Posted: 08 May 2008 10:05
by J-S
What it would be necessary it is that the plugin announces if it is a admin which is connected or only a player, no ??

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

Posted: 10 May 2008 14:44
by Ptitzizi
Small UP for the J-S request ;)

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

Posted: 10 May 2008 16:00
by cdrw700
Me too i'd like that feature, i'm too lazy to write it ^^

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

Posted: 10 May 2008 17:50
by daemon
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. :?

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

Posted: 11 May 2008 15:29
by Ptitzizi
You're a GOD :D

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

Posted: 11 May 2008 20:46
by cdrw700
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 ^^

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

Posted: 31 May 2008 22:48
by nocturne
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.