Код: Выделить всё
#sos.pl
#sos -- console command thats write word 'PRISON' to D:/ALARM.ini
#if in file D:/ALARM.ini exsist word 'PRISON' all bots with this plugin receive console message "one of us in turma"
#may be usefull for a lot of bots you want to quit if one of them have moved to prison by GM
#using automacro with condition console /one of us in turma/
#thanks to ME (Rumata)
package sos;
use strict;
use Fcntl qw (:flock);
use Plugins;
use Log;
use Commands;
use Utils;
use Globals;
use Time::HiRes qw(time);
my $Timecount;
Plugins::register('sos', '', \&Unload);
my $chooks = Commands::register(
['sos', "", \&inisos]
);
my $hooks = Plugins::addHooks(
['mainLoop_pre', \&call]
);
sub call {
if ($Timecount eq'') {
$Timecount = time;
}
return if (!timeOut($Timecount, 1));
open (FILE,"D:/ALARM.ini");
flock(FILE, LOCK_SH);
my $aa = <FILE>;
flock(FILE, LOCK_UN);
close (FILE);
if ($aa =~ "PRIS") {
Log::message("one of us in turma\n");
}
$Timecount = '';
}
sub inisos {
open (F,">>D:/ALARM.ini");
print F "PRISON";
close (F);
return 1;
}
sub Unload {
Commands::unregister($chooks);
Plugins::delHooks($hooks);
}
automacro gmDetected {
console /from sec_pri|MAP Name: sec_pri|You have been forced to disconnect by/
priority 0
exclusive 1
timeout 3
call gmAlert
}
macro gmAlert {
do sos
}
по команде sos пишеться в файл D:/ALARM.ini слово "PRISON" (если файла нет, то он создается), теперь все боты у которых есть данный плагин будут раз в секунду выдавать в консоль себе сообщение "one of us in turma".
ну и им соответственно ставим блок:
automacro friendBANNED {
console /one of us in turma/
priority 1
exclusive 1
timeout 3
call Svalivaem
}
macro Svalivaem {
do quit
}
замечу, проверка файла на слово PRISON осуществляется раз в секунду.