how to use ActivePerl lib with openkore

Forum closed. All further discussion to be discussed at https://github.com/OpenKore/

Moderator: Moderators

Message
Author
ahijup
Noob
Noob
Posts: 1
Joined: 24 Feb 2012, 00:09
Noob?: Yes

how to use ActivePerl lib with openkore

#1 Post by ahijup »

HI:

i want to load "thread" model for openkore...

i have installed ActivePerl-5.12.3.1204-MSWin32-x86-294330.msi..(path : C:\Perl)

i am trying to write a code for thread in Perl.

Code: Select all

package test2;

use threads;
use strict;


my $t1 = threads->new(
								{ 'context'    => 'list',
                                'stack_size' => 32*4096,
                                'exit'       => 'thread_only' },
								
								\&doSomething) ;

sleep(5) ;

$t1->exit() ;

sub doSomething {
	while(1){
		print("test String..\n") ;
		sleep(1) ;
	}
}


1;
it can work...

however, i write the following code to plugins

Code: Select all

package test;

use lib "C:/Perl/lib" ;
use Utils;
use strict;
use Plugins;
use Globals;
use Settings;
use Log qw(message debug);
use Socket; 
use threads;
Plugins::register('test', 'Record console messages after bot died', \&unload);

my $cHook = Plugins::addHooks( [ "disconnected" , \&onDisconnected , undef] 
							,  [ "in_game" , \&onInGame , undef ]
							,  [ "start3" , \&onLoad , undef ]
							,  [ "base_level" , \&onBaseLevel , undef ]
							,  [ "self_died"  , \&onDeath , undef ]
							,  [ "map_loaded" , \&onMapLoaded , undef ]
							);
my $t1 ;
my $sock ;
my $address = 0; 
my $port = 0;


sub unload {
	close($sock) ;
	$t1->join() ;
    Plugins::delHooks( $cHook ) ;
}

sub onDisconnected {
	message ("error:disConnected....\n" , "error") ;
}
sub onInGame {
}
sub onLoad {
	my $flag = $config{StatusReportMode} ;
	
	if ( $flag == 0 ) {
		message ("Report Mode off\n" , "info") ;
		unload() ;
	} else {
		message ("Start Connect to Report Server\n" , "info") ;
		$address = inet_aton( $config{"StatusReportIp"} ) ;
		$port = $config{"StatusReportPort"} ;
		
		$t1 = threads->new(
								{ 'context'    => 'list',
                                'stack_size' => 32*4096,
                                'exit'       => 'thread_only' },
								
								\&RecThreadFunc) ;
		
		
		while ( 1 ) {
			message ("Connect to -> ".$config{"StatusReportIp"}.":".$port."..." , "info") ;
			last unless(ConnectToServer() == 0 ) ;
			message ("Connect Fail!\n" , "info") ;
			sleep ( $config{"StatusRetryDelay"} ) ;
		}
		message ("Connect Success!\n" , "info") ;
	}
}

sub RecThreadFunc {
	message ("in thread ...\n" , "info") ;
}

sub ConnectToServer {
	socket( $sock ,AF_INET,SOCK_STREAM,6);
	
	my $result=sockaddr_in($port,$address);
	
	my $flag = connect( $sock , $result ) ;
	
	return $flag ;
}

sub onBaseLevel {
}
sub onDeath {
}
sub onMapLoaded {
}
1;
and i get the following error
Image


thanks..

User avatar
kLabMouse
Administrator
Administrator
Posts: 1301
Joined: 24 Apr 2008, 12:02

Re: how to use ActivePerl lib with openkore

#2 Post by kLabMouse »

For use of Perl itself. you need to Compile XSTools and NetRedirect yourself for your version of Perl.

Locked