Home » Tiberian Technologies / Blackhand Studios » Other Products » Custom Brenbot Plugin Error
Re: Custom Brenbot Plugin Error [message #361596 is a reply to message #361585] |
Fri, 05 December 2008 19:46 |
|
Gen_Blacky
Messages: 3250 Registered: September 2006
Karma:
|
General (3 Stars) |
|
|
I created a table in brenbot.dat called mp3s and the bot gave me a error say the table already exists here is the plugin code.
package zbot;
use POE;
use plugin;
#use Win32::Process::List;
our %additional_events = (
"snda" => "snda",
"sndp" => "sndp",
"sndt" => "sndt",
);
sub start
{
my ( $session, $heap, $args ) = @_[ SESSION, HEAP, ARG0 ];
my $kernel = $_[KERNEL];
my $name = shift;
my @result = brdatabase::execute_query ( "SELECT * FROM mp3s" );
my $size = @result;
if ($size<1)
{
my @result = brdatabase::execute_query ( "CREATE TABLE mp3s ( length TEXT,name TEXT,time TEXT)");
$data_file="plugins/mp3s.pl";
open(DAT, $data_file) || die("Could not open $data_file to read!");
@raw_data=<DAT>;
close(DAT);
foreach(@raw_data)
{
my $st = $_;
my $st =~ s/\"/""/g;
my @ar = split(",",$st);
my $length= $ar[0];
my $name= $ar[1];
my $time = $ar[2];
my $q = "INSERT INTO mp3s(length,name,time) VALUES (\"".$length."\",\"".$name."\",\"".$time."\")";
my @res = brdatabase::execute_query($q);
}
}
}
sub sndp
{
my %args = %{@_[ ARG0 ]};
eval
{
if (!$args{arg1} || !$args{arg2})
{
my $syntaxvalue = $args{settings}->{syntax}->{value};
if ($args{nicktype} == 1)
{
brIRC::ircmsg ( "[RT] Usage: $syntaxvalue", $args{'ircChannelCode'} );
}
else
{
modules::RenRemCMD("msg [RT] Usage: $syntaxvalue");
}
return;
}
my $pager = $args{nick};
my ( $result, %player ) = playerData::getPlayerData( $args{'arg1'} );
if ( $result == 1 )
{
$snd = $args{arg2};
$query = "SELECT * FROM mp3s WHERE name LIKE \"%".$snd."%\"";
my @array = brdatabase::execute_query($query);
my $size = @array;
if($size == 1){
$f = $array[0];
my $sndname = $f->{'name'};
my $sndtime = $f->{'time'};
modules::RenRemCMD("sndp $player{id} $sndname");
brIRC::ircmsg ( "9PrivateSound sent to $player{name} --> \($pager): $sndname", $args{'ircChannelCode'} );
return;
}
if($size < 10)
{
brIRC::ircmsg ("There are $size sounds with $snd in name, listing them now",$args{'ircChannelCode'} );
foreach(@array)
{
my $sndname = $_->{'name'};
my $sndtime = $_->{'time'};
brIRC::ircmsg ("$sndname : time: ".$sndtime,$args{'ircChannelCode'} );
}
return;
}
if($size > 9)
{
brIRC::ircmsg ("There are $size sounds with $snd in name, listing only 10 of them now",$args{'ircChannelCode'} );
my $cn = 0;
while($cn < 10)
{
my $f = $array[$cn];
my $sndname = $f->{'name'};
my $sndtime = $f->{'time'};
brIRC::ircmsg ("$sndname : time: ".$sndtime,$args{'ircChannelCode'} );
$cn++;
}
return;
}
}
else
{
brIRC::ircmsg ( "Error: $args{arg1} was not found ingame, or is not unique.", $args{'ircChannelCode'} );
}
}
or modules::display_error($@);
}
sub snda
{
my ( $session, $heap, $args ) = @_[ SESSION, HEAP, ARG0 ];
my $kernel = $_[KERNEL];
my %args = %{$args};
print("=zbot= In snda with arg $args{arg1}\r\n");
eval
{
if (!$args{arg1})
{
if ($args{nicktype} == 1)
{
my $syntaxvalue = $args{settings}->{syntax}->{value};
brIRC::ircmsg ( "Usage: $syntaxvalue", $args{'ircChannelCode'} );
}
else
{
modules::RenRemCMD("msg [RT] Usage: $args{settings}->{syntax}->{value}");
}
return;
}
my $pager = $args{nick};
my $snd = $args{arg1};
$query = "SELECT * FROM mp3s WHERE name LIKE \"%".$snd."%\"";
my @array = brdatabase::execute_query($query);
my $size = @array;
if ($args{nicktype} == 1)
{
if($size == 1){
$f = $array[0];
my $sndname = $f->{'name'};
my $sndtime = $f->{'time'};
modules::RenRemCMD("snda $sndname");
brIRC::ircmsg ( "9Global Sound --> \($pager): $sndname", $args{'ircChannelCode'} );
return;
}
if($size < 10)
{
brIRC::ircmsg ("There are $size sounds with $snd in name, listing them now",$args{'ircChannelCode'} );
foreach(@array)
{
my $sndname = $_->{'name'};
my $sndtime = $_->{'time'};
brIRC::ircmsg ("$sndname : time: ".$sndtime,$args{'ircChannelCode'} );
}
return;
}
if($size > 9)
{
brIRC::ircmsg ("There are $size sounds with $snd in name, listing only 10 of them now",$args{'ircChannelCode'} );
my $cn = 0;
while($cn < 10)
{
my $f = $array[$cn];
my $sndname = $f->{'name'};
my $sndtime = $f->{'time'};
brIRC::ircmsg ("$sndname : time: ".$sndtime,$args{'ircChannelCode'} );
$cn++;
}
return;
}
}else{
#ingame page
my ( $result, %player ) = plugin::getPlayerData( $pager );
my $id = $player{'id'};
if($size == 1){
$f = $array[0];
my $sndname = $f->{'name'};
my $sndtime = $f->{'time'};
modules::RenRemCMD("snda $sndname");
plugin::RenRemCMD ( "ppage $player{'id'} 9Global Sound --> \($pager): $sndname" );
return;
}
if($size < 10)
{
plugin::RenRemCMD ( "ppage $player{'id'} There are $size sounds with $snd in name, listing them now" );
foreach(@array)
{
my $sndname = $_->{'name'};
my $sndtime = $_->{'time'};
plugin::RenRemCMD ( "ppage $player{'id'} $sndname : time: ".$sndtime );
}
return;
}
if($size > 9)
{
plugin::RenRemCMD ("ppage ".$player{'id'}." There are $size sounds with $snd in name, listing only 10 of them now");
my $cn = 0;
while($cn < 10)
{
my $f = $array[$cn];
my $sndname = $f->{'name'};
my $sndtime = $f->{'time'};
plugin::RenRemCMD ( "ppage $player{'id'} $sndname : time: ".$sndtime );
$cn++;
}
return;
}
}
modules::RenRemCMD("snda $args{arg1}");
}
or modules::display_error($@);
}
sub sndt
{
my ( $session, $heap, $args ) = @_[ SESSION, HEAP, ARG0 ];
my $kernel = $_[KERNEL];
my %args = %{$args};
eval
{
if (!$args{arg1} || !$args{arg2})
{
if ($args{nicktype} == 1)
{
my $syntaxvalue = $args{settings}->{syntax}->{value};
brIRC::ircmsg ( "Usage: $syntaxvalue", $args{'ircChannelCode'} );
}
else
{
modules::RenRemCMD("msg [RT] Usage: $args{settings}->{syntax}->{value}");
}
return;
}
my $pager = $args{nick};
my $team = $args{arg1};
my $snd = $args{arg2};
$query = "SELECT * FROM mp3s WHERE name LIKE \"%".$snd."%\"";
my @array = brdatabase::execute_query($query);
if ($team =~ /nod/i) {$team = "0"} #support user specifying NOD instead of 0
if ($team =~ /gdi/i) {$team = "1"} #support user specifying GDI instead of 1
my $size = @array;
if($size == 1){
$f = $array[0];
my $sndname = $f->{'name'};
my $sndtime = $f->{'time'};
modules::RenRemCMD("sndt $team $sndtime");
brIRC::ircmsg ( "9TeamSound Sent to Team $team --> \($pager): $sndname", $args{'ircChannelCode'} );
return;
}
if($size < 10)
{
brIRC::ircmsg ("There are $size sounds with $snd in name, listing them now",$args{'ircChannelCode'} );
foreach(@array)
{
my $sndname = $_->{'name'};
my $sndtime = $_->{'time'};
brIRC::ircmsg ("$sndname : time: ".$sndtime,$args{'ircChannelCode'} );
}
return;
}
if($size > 9)
{
brIRC::ircmsg ("There are $size sounds with $snd in name, listing only 10 of them now",$args{'ircChannelCode'} );
my $cn = 0;
while($cn < 10)
{
my $f = $array[$cn];
my $sndname = $f->{'name'};
my $sndtime = $f->{'time'};
brIRC::ircmsg ("$sndname : time: ".$sndtime,$args{'ircChannelCode'} );
$cn++;
}
return;
}
}
or modules::display_error($@);
}
Edit: it was originally part of a module
[Updated on: Fri, 05 December 2008 19:50] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Mon Jan 20 10:00:47 MST 2025
Total time taken to generate the page: 0.00880 seconds
|