[Plugin] Is not activated

For everything NOT server specific support. Do NOT ask for connectivity help here!.

Moderator: Moderators

Unknown6996
Human
Human
Posts: 24
Joined: 07 Oct 2011, 11:21
Noob?: No

[Plugin] Is not activated

#1 Post by Unknown6996 »

I have created some plugins and,of 6,And don't was can create the last.
The plugin has then function of when receive a pm with a especific message,answer him.
And my ask is : How i do this?
This is a plugin of Sr. Mushroom,This plugin has in Openkore.com.br

Code: Select all

#
# Openkore - antiBot
# Copyright (c) - 2011 Mushroom
#

package antiBot;

use strict;
use Plugins;

use Log qw(message);

Plugins::register('antiBot', 'Responde ao NPC Anti-Bot', \&Unload);

my $hooks = (
	Plugins::addHooks(
		['npc_talk', \&onTalk, undef],
		['npc_talk_responses', \&onResp, undef],
	)
);

sub Unload {
	Plugins::delHooks($hooks);
};

my %antibot;
my $state;

sub onTalk {
	my (undef, $args) = @_;
	if ($args->{msg} =~ /Please,identify the following numbers: (\d+) - (\d+) - (\d+)\./i) {
		message "[ANTIBOT] Numbers found: $1 $2 $3\n";
		$antibot{numero1} = $1;
		$antibot{numero2} = $2;
		$antibot{numero3} = $3;
		$state = "start";
	}	
}

sub onResp {
	my (undef, $args) = @_;
	return unless ($state =~ /^(?:start|found)$/);

	foreach my $order (sort keys %antibot) {
		next if (!$antibot{$order});
		
		for (my $i = 0; $i < @{$args->{responses}}; $i++) {
			if (checkResp($antibot{$order}, $args->{responses}[$i])) {
				message "[ANTIBOT] A alternative has found to the number $antibot{$order}.\n";
				talkResp($i);
				$state = "found";
				last;
			}
		}
		
		if ($state eq "found") {
			undef $antibot{$order};
			undef $state if (!$antibot{numero1} && !$antibot{numero2} && !$antibot{numero3});
			last;
		} else {
			message "[ANTIBOT] any response has found to the number $antibot{$order}.\n";
			undef %antibot;
			undef $state;
		}
	}
	
}

sub checkResp {
	my ($numero, $resp) = @_;
	if ($numero == 1 && $resp =~ /[µuúùûü|l_1]+.*?m/i
		|| $numero == 2 && $resp =~ /[dÐ|)]+.*?[oóòöõô0@Øø#]+.*?[iíìïî|l1]+.*?[sz$2%]+/i
		|| $numero == 3 && $resp =~ /[t+-†÷?±]+.*?[r®Þþ#]+.*?[eéèëê£3³Æ&]+.*?[sz$2%]+/i
		|| $numero == 4 && $resp =~ /[qc©k]+.*?[µuúùûü|l_1]+.*?[aáàäãâ@4å\/-\\|]+.*?[t+-†÷?±]+.*?[r®Þþ#]+.*?[#oóòöõô0@Øø]+/i
		|| $numero == 5 && $resp =~ /[sc\©]+.*?[iíìïî|l1]+.*?[nñ|\\\/]+.*?[sc©]+.*?[#oóòöõô0@Øø]+/i
		|| $numero == 6 && $resp =~ /[sz$2%]+.*?[eéèëê£3³Æ&]+.*[iíìïî|l1]+.*?[sz$2%]+/i
		|| $numero == 7 && $resp =~ /[sz$2%]+.*?[eéèëê£3³Æ&]+.*[t+-†÷?±]+.*?[eéèëê£3³Æ&]+/i
		|| $numero == 8 && $resp =~ /[#oóòöõô0@Øø]+.*?[iíìïî|l1]+.*?[t+-†÷?±]+.*?[oóòöõô0@Øø]+/i
		|| $numero == 9 && $resp =~ /[nñ|\\\/m]+.*?[#oóòöõô0@Øø]+.*?[v\\\/]+.*?[eéèëê£3³Æ&]+/i
		|| $numero == 10 && $resp =~ /[dÐ|)]+.*?[eéèëê£3³Æ&]+.*?[sz$2%]+/i
	) {
		return 1
	}
	return 0;
}

sub talkResp {
	AI::ai_clientSuspend(0, 2);
	message "[ANTIBOT] Responding to NPC Anti-BOT the resp $_[0].\n";
	Commands::run("talk resp $_[0]");
}

1;
This plugins is a verificator of message.
When ANTI-BOT say random numbers,i want resp the right question.
But,doesn't resp.
Why ?
Some error ?
I Don't see :B