Danpual would this be a bad way to constantly update players credits or could this lag the fds. Call the pinfo timer when bot starts. Then everyone's credits are consistently updated every 30 seconds. Would it be better to get it from ssgm log instead of the console.
modules::pinfotimer();
#id,playername,score,team,ping,ip;port,kbps,0,0,0,credits,0
if ( $line =~ /(\d+),(.+),\d+,(\d+),\d+,.+;\d+,\d+,\d+,\d+,\d+,(\d+),.+/ )
{
my $id = $1;
my $name = $2;
my $team = $3;
my $credits = $4;
my ( $result, %player ) = plugin::getPlayerData( $id );
if ( $result == 1 )
{
# update credits
playerData::setKeyValue ( $id, "credits", $credits );
}
}
sub pinfotimer
{
POE::Session->create
(
inline_states =>
{
_start => sub
{
RenRemCMD( "pinfo" );
$_[HEAP]->{next_alarm_time} = int( time() ) + 30;
$_[KERNEL]->alarm( tick => $_[HEAP]->{next_alarm_time} );
},
tick => sub
{
RenRemCMD( "pinfo" );
$_[HEAP]->{next_alarm_time} = int( time() ) + 30;
$_[KERNEL]->alarm( restart => $_[HEAP]->{next_alarm_time} );
},
restart => sub
{
RenRemCMD( "pinfo" );
$_[HEAP]->{next_alarm_time} = int( time() ) + 30;
$_[KERNEL]->alarm( tick => $_[HEAP]->{next_alarm_time} );
},
}
);
}
[Updated on: Thu, 02 December 2010 13:02]
Report message to a moderator