problem with plugin.badwords.mcm.php

This is the place where you can find everything related to the dedicated server, control scripts and community tools.

Moderators: Pit Crew, TM-Patrol

Post Reply
User avatar
lgrfbs-sweden
smooth traffic navigator
smooth traffic navigator
Posts: 200
Joined: 15 Apr 2007 15:48
Owned TM-games: TMN
Location: Sweden
Contact:

problem with plugin.badwords.mcm.php

Post by lgrfbs-sweden » 08 Mar 2008 08:05

I want use this plug-in: plugin.badwords.mcm.php but I get this error:

aseco.log______________________________
PHP Fatal error: Cannot redeclare ajouter_joueur_liste() (previously declared in /home/subfil/Aseco/plugins/plugin.badwords.mcm.php:148) in /home/subfil/Aseco/plugins/jfreu.plugin.php on line 741
______________________________________

How too fix the error?

Server is running: Aseco v0.91 Xymph
Admin On:Image
My server:lgrfbs server / XASECO plugins
Image

User avatar
mcm
road tourist
road tourist
Posts: 75
Joined: 30 Jan 2007 21:19
Owned TM-games: UNO
Location: in da house ;)
Contact:

Re: problem with plugin.badwords.mcm.php

Post by mcm » 10 Mar 2008 06:58

u cannot use the badwords plugin if you have parts of jfreu enabled, this badwords plugin is based on jfreus and using same variables, plugin is writen for aseco 0.61b :D

m&o
happy cruiser
happy cruiser
Posts: 188
Joined: 19 Apr 2007 17:53
Owned TM-games: TMN, TMU, TMF

Re: problem with plugin.badwords.mcm.php

Post by m&o » 10 Mar 2008 15:45

mcm wrote:u cannot use the badwords plugin if you have parts of jfreu enabled, this badwords plugin is based on jfreus and using same variables, plugin is writen for aseco 0.61b :D
of what you say and if I read the error message, if you change every single variable his name it wil work(maby just add everywhere a 1...)
Image

User avatar
mcm
road tourist
road tourist
Posts: 75
Joined: 30 Jan 2007 21:19
Owned TM-games: UNO
Location: in da house ;)
Contact:

Re: problem with plugin.badwords.mcm.php

Post by mcm » 11 Mar 2008 12:32

sure m&o that would get it working, but the current state is that its not working with jfreus plugin and i'm not going to change this.

User avatar
lgrfbs-sweden
smooth traffic navigator
smooth traffic navigator
Posts: 200
Joined: 15 Apr 2007 15:48
Owned TM-games: TMN
Location: Sweden
Contact:

Re: problem with plugin.badwords.mcm.php

Post by lgrfbs-sweden » 11 Mar 2008 15:16

If I do as m&o write, will I have 2 badword runing if I do like this?

file: jfreu.config.php - Aseco 0.91

Code: Select all

        //-> Badwords checking (0 = OFF, 1 = ON)
        $badwords = 1;
        //-> Badwords banning (0 = OFF, 1 = ON)
        $badwordsban = 1;
        //-> Number of badwords allowed
        $badwordsnum = 3;
or is it a bad idea?
Admin On:Image
My server:lgrfbs server / XASECO plugins
Image

User avatar
mcm
road tourist
road tourist
Posts: 75
Joined: 30 Jan 2007 21:19
Owned TM-games: UNO
Location: in da house ;)
Contact:

Re: problem with plugin.badwords.mcm.php

Post by mcm » 12 Mar 2008 06:56

that would be yes, but if you dont use the same words in both plugin you can separete between badwords and realy badwords :P
anywhay if you like to try it take my plugin and serach for the item which causes the error

PHP Fatal error: Cannot redeclare ajouter_joueur_liste() (previously declared in /home/subfil/Aseco/plugins/plugin.badwords.mcm.php:148) in /home/subfil/Aseco/plugins/jfreu.plugin.php on line 741
______________________________________

not only i line 148 but in the whole plugin, and change it to 1ajouter_joueur_liste
there will be a few other functions to change in same way to get it working..good luck.

like i said, it was not made to work with jfreus cause i dont like those vip things and ranklimitations that jfreus offers..

User avatar
El Fuego
solid chaser
solid chaser
Posts: 1097
Joined: 27 Oct 2006 11:00
Owned TM-games: TMUF, TM2 C/S
Location: Nae too far frae Glesgie
Contact:

Re: problem with plugin.badwords.mcm.php

Post by El Fuego » 12 Mar 2008 09:06

Can variable names in PHP start with a number? ;)
PHP manual wrote:Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.
Cheers!
.FUEY.
Diary Of A Mad Man

User avatar
mcm
road tourist
road tourist
Posts: 75
Joined: 30 Jan 2007 21:19
Owned TM-games: UNO
Location: in da house ;)
Contact:

Re: problem with plugin.badwords.mcm.php

Post by mcm » 12 Mar 2008 19:32

Douh! now look at that, your right thx i never noticed that...lol...maybe i should realy rtfm :lol:

well then give me anoter try.... :wink:

you must rename the function (which seems also to follow the same rules as other labels in PHP) ajouter_joueur_liste to something else
maybe add_player_list or something like that, you must do that to all ajouter_joueur_liste in the code.

User avatar
lgrfbs-sweden
smooth traffic navigator
smooth traffic navigator
Posts: 200
Joined: 15 Apr 2007 15:48
Owned TM-games: TMN
Location: Sweden
Contact:

Re: problem with plugin.badwords.mcm.php

Post by lgrfbs-sweden » 12 Mar 2008 19:55

Like so?
I add a "z" to variable names there errors showed it needed.

Code: Select all

<?php

// badword baner stolen from jfreu plugin moded by mcm

Aseco::registerEvent("onChat", "BadWordsz");
Aseco::registerEvent("onStartup","init_badwordsz");
Aseco::registerEvent("onPlayerConnect", "player_connectz");

class service
{
	
	
	//** Jfreu's Player list **//
	var $playerlist; // liste des joueurs (taille 100) [liste]
	

	
	//** BadWords **//
	var $badwords;
	var $badwordsban;
	var $badwordsnb;
	//** colors **// <-- use aseco colors ?
	var $green;
	var $white;
	var $yellow;
	var $blue;
	var $red;
}

class joueurz // element joueur
{
	var $hasvoted;
	var $speconly; // speconly status
	var $isvip;
	var $badwords;
	var $kicked;
	var $unspec;
	var $banned; // 1=banned || >1=timestamp unban
	var $cooled; // timelimit 4 reset badwords
}


function init_badwordsz(&$aseco,$command)
{
	
	
	//include("jfreu.config.php");
	//$version="0.13d(test)";
	$aseco->server->client = new service();
	$aseco->server->service->kicked=0;
	
	//** colors **//
	$gre=$aseco->server->service->green=$aseco->formatColors('$z$s{#record}');
	$whi=$aseco->server->service->white=$aseco->formatColors('$z$s{#highlite}');
	$yel=$aseco->server->service->yellow=$aseco->formatColors('$z$s{#server}');
	$blu=$aseco->server->service->blue=$aseco->formatColors('$z$s{#message}');
	$red=$aseco->server->service->red=$aseco->formatColors('$z$s{#error}');
	
	//** badwords **//
	$aseco->server->service->badwords=1; //$badwords;
	$aseco->server->service->badwordsban=1; //$badwordsban;
	$aseco->server->service->badwordsnb=3; //$badwordsnb;
	
	//** playerlist **//
	if(isset($aseco->server->players->player_list))
	{
		foreach($aseco->server->players->player_list as $pl)
		{
			ajouter_joueur_listez($aseco,$pl,0,0);
		}
	}
	
}

function player_connectz(&$aseco,$command)
{
	$red=$aseco->server->service->red;
	$yel=$aseco->server->service->yellow;
	$whi=$aseco->server->service->white;
	$blu=$aseco->server->service->blue;
	$gre=$aseco->server->service->green;
	
	if($ban=isbannedz($aseco,$command->login))
	{
		$message=$yel.'>> '.$whi.clean_nick($command->nickname).$red.'Banned for '.round($ban,0).' min';
		$aseco->addCall("ChatSendServerMessage", array($message));
		$message2=$yel.'>> '.$red.'Your ban will be over in '.$whi.round($ban,0).$red.' min.';
		$aseco->addCall("ChatSendServerMessageToLogin", array($message2, $command->login));
		$aseco->server->service->playerlist[$command->login]->kicked=1;
		$aseco->addCall("Kick", array($command->login));
		return 0;
	}
	
}


function clean_nickz($nick)
{
	$red=$aseco->server->service->red;
	$yel=$aseco->server->service->yellow;
	$whi=$aseco->server->service->white;
	$blu=$aseco->server->service->blue;
	$gre=$aseco->server->service->green;
	$propre=stripColors($nick);
	if($propre=="")
	{
		return $red.'ERROR';
	}
	return $propre;
}

function banforz(&$aseco,$login,$time) // time : min
{
	$red=$aseco->server->service->red;
	$yel=$aseco->server->service->yellow;
	$whi=$aseco->server->service->white;
	$blu=$aseco->server->service->blue;
	$gre=$aseco->server->service->green;
	if($time>0)
	{
		$message =$yel.'>> '.$red.'You have been banned for '.$time.' minute(s).';
		$aseco->addCall("ChatSendServerMessageToLogin", array($message, $login));
		$aseco->addCall("Kick", array($login));
	}
	$time*=60;
	$absolute_time=time()+$time;
	$aseco->server->service->playerlist[$login]->banned=$absolute_time;
}

function isbannedz(&$aseco,$login) // return min = banned , return 0 = not banned
{
	if($aseco->server->service->playerlist[$login]->banned==0)
	{
		return 0;
	}
	$time=time();
	if($aseco->server->service->playerlist[$login]->banned>$time)
	{
		return round((($aseco->server->service->playerlist[$login]->banned)-$time)/60);
	}
	else
	{
		$aseco->server->service->playerlist[$login]->banned=0;
		return 0;
	}
}

function ajouter_joueur_listez(&$aseco,$joueurz,$isvip,$speconly)
{
	if(!isset($aseco->server->service->playerlist[$joueurz->login]))
	{
		$aseco->server->service->playerlist[$joueurz->login]=new joueur();
		$aseco->server->service->playerlist[$joueurz->login]->badwords=0;
		$aseco->server->service->playerlist[$joueurz->login]->hasvoted=0;
		$aseco->server->service->playerlist[$joueurz->login]->kicked=0;
		$aseco->server->service->playerlist[$joueurz->login]->banned=0;
		$aseco->server->service->playerlist[$joueurz->login]->cooled=0;
	}
	$aseco->server->service->playerlist[$joueurz->login]->speconly=$speconly;
	$aseco->server->service->playerlist[$joueurz->login]->isvip=$isvip;
}

function BadWordsz($aseco, $command)
{
	$badwordsban = 1;
	$coolingtime = 15;
	
	
	
	$player = $aseco->server->players->getPlayer($command[1]);
	$nick=$player->nickname;
	if($nick=='')
	{
		return -1;
	}

	$texte=clean_nickz($command[2]);
	$temp='';
	$temp2=' ';
	$i=0;
	while(isset($texte[$i]) && $i<1000)
	{
		if($texte[$i]!=" " && $texte[$i]!=$temp2)
		{
			$temp2=$texte[$i];
			$temp.=$texte[$i];
		}
		$i++;
	}
	$texte=$temp;
	$texte=str_replace("|_|","u",$texte);
	$texte=str_replace(".","",$texte);
	$texte=str_replace("*","",$texte);
	$texte=str_replace("[","",$texte);
	$texte=str_replace("]","",$texte);
	$texte=str_replace("_","",$texte);
	$texte=str_replace("-","",$texte);
	$max=$aseco->server->service->badwordsnb;
	$red=$aseco->server->service->red;
	$yel=$aseco->server->service->yellow;
	$whi=$aseco->server->service->white;
	$blu=$aseco->server->service->blue;
	$gre=$aseco->server->service->green;

	include 'array.badwords.php';
	
	foreach($bad_Words As $mot)
	{
		if (stristr($texte, $mot))
		{	
		 	// coolingtime start
		 	
		 	$time=time();
			
			if($aseco->server->service->playerlist[$command[1]]->cooled<$time && $aseco->server->service->playerlist[$command[1]]->cooled != 0 )
			{
			    //reset coolingtime	
			$aseco->server->service->playerlist[$command[1]]->cooled=0;
			$aseco->server->service->playerlist[$command[1]]->badwords=0;
			
			}
						
			$coolingtime*=60;
			$absolute_coolingtime=time()+$coolingtime;
			$aseco->server->service->playerlist[$command[1]]->cooled=$absolute_coolingtime;	
					 	
		 	// coolingtime end
		 
		 
			$aseco->server->service->playerlist[$command[1]]->badwords++;
			$message = $yel.'>> '.$red.'Language plz !';
			if($aseco->server->service->badwordsban==1 && $aseco->server->service->playerlist[$command[1]]->badwords>$max)
			{
				$max2=$max*2;
				$message .= $blu.' ['.$whi.clean_nickz($nick).$blu.' : ';
				$message .= $whi.$aseco->server->service->playerlist[$command[1]]->badwords.$blu.'/'.$whi.$max2.$blu;
				$message.=$red.' to ban '.$blu.'] ';
			}
			else
			{
				$babar=$aseco->server->service->playerlist[$command[1]]->badwords%$max;
				$message .= $blu.' ['.$whi.clean_nickz($nick).$blu.' : ';
				$message .= $whi.$aseco->server->service->playerlist[$command[1]]->badwords.$blu.'/'.$whi.$max.$blu;
				$message.=$red.' to kick '.$blu.'] ';
			}
			if(($aseco->server->service->playerlist[$command[1]]->badwords%$max)==0)
			{
				if($badwordsban==1)
				{
					if($aseco->server->service->playerlist[$command[1]]->badwords>$max)
					{
						//$aseco->addCall("Ban", array($command[1]));
						banforz($aseco,$command[1],30);
						$message .=' ('.$red.'banned for 30 min'.$blu.')';
						$aseco->server->service->playerlist[$command[1]]->badwords=0;
					}
					else
					{
						$aseco->addCall("Kick", array($command[1]));
						$message .=' ('.$red.'kicked'.$blu.') ';
					}
				}
				else
				{
					$aseco->addCall("Kick", array($command[1]));
					$message .=' ('.$red.'kicked'.$blu.') ';
					$aseco->server->service->playerlist[$command[1]]->badwords=0;
				}
			}
			$message2=$yel.'>> '.$red.'[ '.$whi.'"'.$mot.'"'.$red.' is a forbidden word ].';
			$aseco->addCall("ChatSendServerMessage", array($message));
			$aseco->addCall("ChatSendServerMessageToLogin", array($message2,$command[1]));
			return 0;
		}
	}
}

?>
Admin On:Image
My server:lgrfbs server / XASECO plugins
Image

m&o
happy cruiser
happy cruiser
Posts: 188
Joined: 19 Apr 2007 17:53
Owned TM-games: TMN, TMU, TMF

Re: problem with plugin.badwords.mcm.php

Post by m&o » 13 Mar 2008 17:09

lgrfbs-sweden wrote:Like so?
I add a "z" to variable names there errors showed it needed.
only way to check if it is right start aseco whit the code and if it does not crash like that
Image

User avatar
lgrfbs-sweden
smooth traffic navigator
smooth traffic navigator
Posts: 200
Joined: 15 Apr 2007 15:48
Owned TM-games: TMN
Location: Sweden
Contact:

Re: problem with plugin.badwords.mcm.php

Post by lgrfbs-sweden » 03 Apr 2008 22:29

Now I have tested and both plugin.badwords.mcm.php and jfreu.config.php/jfreu.plugin.php have same error if a word have dubble letters this word
do not get trapped by the script.

My system:
Aseco v0.91 Xymph
Jfreu's plugin 0.13

Funny to see both script to react on same word :D
Admin On:Image
My server:lgrfbs server / XASECO plugins
Image

Post Reply