Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Tiberian Technologies / Blackhand Studios » Other Products » Brenbot Plugin
Brenbot Plugin [message #400153] Thu, 27 August 2009 19:00 Go to next message
Gen_Blacky is currently offline  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;






http://s18.postimage.org/jc6qbn4k9/bricks3.png

[Updated on: Thu, 27 August 2009 19:02]

Report message to a moderator

Re: Brenbot Plugin [message #400227 is a reply to message #400153] Thu, 27 August 2009 23:37 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
As stated in the error message there is a syntax error on line 69 of your code. Line 69 is a while loop with no code inside of it... looks like you missed the { and } for the actual while loop.

http://steamsignature.com/card/1/76561197975867233.png
Re: Brenbot Plugin [message #400812 is a reply to message #400153] Sun, 30 August 2009 09:33 Go to previous messageGo to next message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma: 1
General (3 Stars)
okay ty got it working.

http://s18.postimage.org/jc6qbn4k9/bricks3.png
Re: Brenbot Plugin [message #400908 is a reply to message #400153] Sun, 30 August 2009 21:01 Go to previous messageGo to next message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma: 1
General (3 Stars)
another question. How do i get player ip when they join the game.

I did this when player joined , but wont get player that joined since hes not on the list yet.

		my %playerlist = playerData::getPlayerList();
		while ( my ( $id, $player ) = each ( %playerlist ) )
		{
			#$player{'name'} = $1;
			#brIRC::ircmsg( "[BR] $player->{'ip'} ." );
			modules::RenRemCMD( "player_info" );
			brIRC::ircmsg( "9 [DEBUG] GOT Player Name 7 $player->{'name'} 4 $player->{'ip'}  7 Ping 4 $player->{'ping'} ", "A" );
		}



http://s18.postimage.org/jc6qbn4k9/bricks3.png
Re: Brenbot Plugin [message #400924 is a reply to message #400153] Sun, 30 August 2009 23:58 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
Use a 2 second timer and pass the ID of the player as the parameter to the timer

http://steamsignature.com/card/1/76561197975867233.png
Re: Brenbot Plugin [message #400931 is a reply to message #400153] Mon, 31 August 2009 00:35 Go to previous messageGo to next message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma: 1
General (3 Stars)
would i use a POE alarm_timer

http://s18.postimage.org/jc6qbn4k9/bricks3.png
Re: Brenbot Plugin [message #400945 is a reply to message #400153] Mon, 31 August 2009 06:47 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
# Give BRenBot time to get their IP
$kernel->alarm( myEventName => (int(time()) +3) => $args{'nick'} );


NB: I said to use ID before but nick would be better since its possible they might have joined and immediatly left again and someone else joined with the same ID before it triggers.


http://steamsignature.com/card/1/76561197975867233.png
Re: Brenbot Plugin [message #401180 is a reply to message #400153] Tue, 01 September 2009 12:14 Go to previous messageGo to next message
Gen_Blacky is currently offline  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 ?


http://s18.postimage.org/jc6qbn4k9/bricks3.png

[Updated on: Tue, 01 September 2009 19:29]

Report message to a moderator

Re: Brenbot Plugin [message #401262 is a reply to message #400153] Tue, 01 September 2009 23:54 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
Because the IP is NOT available on the 'x has joined the game' line, it's only available when the next player_info response is received. Hence why you need to use a timer. Also, why are you trying to manually parse the renlog? BRenBot already provides the player_joined event for that line of the renlog file.

http://steamsignature.com/card/1/76561197975867233.png
Re: Brenbot Plugin [message #401336 is a reply to message #400153] Wed, 02 September 2009 19:27 Go to previous messageGo to next message
Gen_Blacky is currently offline  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" );
						}
					}
				);
			}
		}


http://s18.postimage.org/jc6qbn4k9/bricks3.png

[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 Go to previous messageGo to next message
danpaul88 is currently offline  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.


http://steamsignature.com/card/1/76561197975867233.png

[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 Go to previous messageGo to next message
Gen_Blacky is currently offline  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"




http://s18.postimage.org/jc6qbn4k9/bricks3.png

[Updated on: Sat, 05 September 2009 00:25]

Report message to a moderator

Re: Brenbot Plugin [message #401711 is a reply to message #400153] Sat, 05 September 2009 11:29 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
Your supposed to pass the player name as ARG0, NOT the renlog line... use player_joined instead of hooking renlog output.

http://steamsignature.com/card/1/76561197975867233.png
Re: Brenbot Plugin [message #402385 is a reply to message #400153] Fri, 11 September 2009 02:16 Go to previous message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma: 1
General (3 Stars)
lol thank you

http://s18.postimage.org/jc6qbn4k9/bricks3.png
Previous Topic: Server crash when loaded C&C_Under.mix edit
Next Topic: Leveledit
Goto Forum:
  


Current Time: Tue Dec 17 20:39:06 MST 2024

Total time taken to generate the page: 0.00871 seconds