Brenbot Plugin [message #400153] |
Thu, 27 August 2009 19:00 |
|
Gen_Blacky
Messages: 3250 Registered: September 2006
Karma: 1
|
General (3 Stars) |
|
|
Can some one tell me why the plugin wont load. Im just trying to get it to load before i go any further.
error found in forcecp.pm: syntax error at plugins/forcecp.pm line 48, near ")
{"
syntax error at plugins/forcecp.pm line 69, near ")
if"
Compilation failed in require at (eval 198) line 1.
package forcecp;
use POE;
use plugin;
# define additional events in the POE session
our %additional_events =
(
# !command functions
"forcecp" => "forcecp"
);
# BRenBot automatically sets the plugin name
our $plugin_name;
# BRenBot automatically imports the plugin's config (from the xml file) into %config
our %config;
our $currentVersion = 1.00;
sub forcecp
{
my ( $session, $heap, $args ) = @_[ SESSION, HEAP, ARG0 ];
my $kernel = $_[KERNEL];
my %args = %{$args};
eval
{
if (!$args{arg1})
{
if ($args{nicktype} == 1)
{
my $syntaxvalue = $args{settings}->{syntax}->{value};
brIRC::ircmsg ( "Usage: $syntaxvalue", $args{'ircChannelCode'} );
}
else
{
modules::RenRemCMD("msg [BR] Usage: $args{settings}->{syntax}->{value}");
}
return;
}
my $user = $args{arg1}
if ( modules::get_module("bhs") )
{
my $mod = $args{nick};
my ( $result, %player ) = playerData::getPlayerData( $user );
if ( $result == 1 )
{
if (!modules::get_module("gamelog") )
{
modules::RenRemCMD("msg [BR] Gamelog must be enabled to be able to use forcecp");
return;
}
my $loaded = gamelog::get_player( $player{'name'} );
print "Enforcing Scripts now!\n";
my ( $result, %player ) = playerData::getPlayerData( $user );
while ( my ( $id, $player ) = each ( %playerData ) )
if ( length ( $player->{'bhsVersion'} ) == 0 && ( ( time() - $player->{'joinTime'} ) > 10 ) )
{
brIRC::ircmsg ( "$admin Forced $player to get scripts.", $args{'ircChannelCode'} );
modules::RenRemCMD( "pamsg $player->{id} You need Scripts to play on this server" );
RenRem::RenRemCMDtimed( "kick $player->{id}", 5 );
}
}
}
}
}
# else
# {
# if ( $player->{'bhsVersion'} >= 3.4 ){
# brIRC::ircmsg ( "$player Has Scripts 3.4 No Reason to Force.", $args{'ircChannelCode'} );
sub start
{
plugin::set_global ( "version_plugin_forcecp", $currentVersion );
}
sub stop
{
}
sub command
{
my $kernel = $_[KERNEL];
my %args = %{@_[ ARG0 ]};
$kernel->yield( $args{'command'} => \%args);
}
# Return true or the bot will not work properly...
1;
[Updated on: Thu, 27 August 2009 19:02] Report message to a moderator
|
|
|
|
|
|
|
|
|
Re: Brenbot Plugin [message #401180 is a reply to message #400153] |
Tue, 01 September 2009 12:14 |
|
Gen_Blacky
Messages: 3250 Registered: September 2006
Karma: 1
|
General (3 Stars) |
|
|
Now im just trying to get get the single player but i cant get ip , what do i need to get ip.
if ( $line =~ m/Player (.*?) joined the game/ )
{
my ( $result, %player ) = playerData::getPlayerData ( $1 );
if ( $result != 1 )
{
$player{'name'} = $1;
}
brIRC::ircmsg( " Player $player{'name'} $player{'ip'} ", "A" );
}
Edit: Some times it would get player ip but 90% time it done why is that ?
[Updated on: Tue, 01 September 2009 19:29] Report message to a moderator
|
|
|
|
Re: Brenbot Plugin [message #401336 is a reply to message #400153] |
Wed, 02 September 2009 19:27 |
|
Gen_Blacky
Messages: 3250 Registered: September 2006
Karma: 1
|
General (3 Stars) |
|
|
Yea i was just testing some stuff out. So I tired making a timer but it didn't work not sure what to do with code you gave me.
my %playerlist = playerData::getPlayerList();
while ( my ( $id, $player ) = each ( %playerlist ) )
{
if ( modules::get_module( "bhs" ) )
{
POE::Session->create
( inline_states =>
{
_start => sub
{
$_[HEAP]->{next_alarm_time} = int( time() ) + 5;
#$_[KERNEL]->alarm( end => (int(time() ) +3) => $player->{'name'}
$_[KERNEL]->alarm( end => $_[HEAP]->{next_alarm_time} );
},
end => sub
{
modules::RenRemCMD ( "player_info" );
brIRC::ircmsg( "7 Player 4 $player->{'name'} 4 $player->{'ip'} 7 Ping 4 $player->{'ping'} 7Serial 4 $player{'serial'} ", "A" );
}
}
);
}
}
[Updated on: Wed, 02 September 2009 19:34] Report message to a moderator
|
|
|
Re: Brenbot Plugin [message #401358 is a reply to message #400153] |
Thu, 03 September 2009 01:16 |
|
danpaul88
Messages: 5795 Registered: June 2004 Location: England
Karma: 0
|
General (5 Stars) |
|
|
You don't need to manually send RenRemCmd("player_info"), BRenBot already did that on the player_joined line, the reason for the timer is because you have to wait for the response to come back.
You also need to pass the name to the timer so you know which player it triggered for, ie;
$_[KERNEL]->alarm( end=> (int(time()) +3) => $player->{'name'} );
In the end sub you need to use something like
end => sub
{
my ( $result, %player ) = plugin::getPlayerData ( $_[ARG0] );
if ( $result != 1 )
{
brIRC::ircmsg( "7 Player 4 $player->{'name'} 4 $player->{'ip'} 7 Ping 4 $player->{'ping'} 7Serial 4 $player{'serial'} ", "A" );
}
}
Also, you should never use playerdata::getPlayerData in your plugin, use plugin::getPlayerData instead, it calls the same function but because its in the plugin interface it will always be supported in future regardless of internal changes.
[Updated on: Thu, 03 September 2009 01:18] Report message to a moderator
|
|
|
Re: Brenbot Plugin [message #401593 is a reply to message #400153] |
Fri, 04 September 2009 23:50 |
|
Gen_Blacky
Messages: 3250 Registered: September 2006
Karma: 1
|
General (3 Stars) |
|
|
ah thank you for your help works now.
Edit: when i try getting single player with
my ( $result, %player ) = plugin::getPlayerData ( $_[ARG0] );
if ( $result != 1 )
Br loads fine but as soon a player joins i get this
Can't use string ("[01:21:08] Player y0 joined the ") as a HASH ref while "stric
t refs"
[Updated on: Sat, 05 September 2009 00:25] Report message to a moderator
|
|
|
|
|