BrenBot help. [message #438259] |
Sun, 24 October 2010 10:41 ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
crysis992
Messages: 314 Registered: June 2008
Karma: 0
|
Recruit |
![288304956](/theme/Renegade_Forums/images/icq.png)
|
|
Hello, i need a bit help with BrenBot.
I want a !mpage command, that command should page all authed moderators on the modlist. But how I do this?
|
|
|
|
Re: BrenBot help. [message #438283 is a reply to message #438259] |
Sun, 24 October 2010 20:25 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
![](http://renegadeforums.com/images/avatars/Viseroid.jpg) |
Gen_Blacky
Messages: 3250 Registered: September 2006
Karma: 1
|
General (3 Stars) |
|
|
I thought it was a good idea so I made one
sub pagemods
{
my ( $session, $heap, $args ) = @_[ SESSION, HEAP, ARG0 ];
my $kernel = $_[KERNEL];
my %args = %{$args};
#if ( $args{arg1} )
if ( $args{arg} =~ m/^\!\S+\s(.+)$/i )
{
my $msg = $1;
my $name = "";
my $string = "";
my $players_gdi = serverStatus::getPlayers_GDI();
my $players_nod = serverStatus::getPlayers_Nod();
my $maxplayers = $players_nod + $players_gdi;
my $msglength = length($msg);
if ( $msglength > 248 ) { sendmsg("Your Message is too long.", $args{nicktype}, "A", $args{nick} ); return; }
elsif ($maxplayers < 1) { sendmsg("No players in Game", $args{nicktype}, "A", $args{nick} ); return; }
else
{
my %playerlist = playerData::getPlayerList();
while ( my ( $id, $player ) = each ( %playerlist ) )
{
if ((modules::IsHalfMod($player->{'name'}) || modules::IsFullMod($player->{'name'}) || modules::IsAdmin($player->{'name'}) ))
{
modules::pagePlayer ( $player->{'id'}, "Admin", "$msg" );
$name = "$player->{'name'} ";
$string = $string . $name;
}
}
my $stringl = length($string);
if ($stringl < 1) { sendmsg("No Mods ingame", $args{nicktype}, "A", $args{nick} ); return;}
else { sendmsg("Mods $string have been paged", $args{nicktype}, "A", $args{nick} ); }
}
}
else { sendmsg("Syntax !pagemods <msg>", $args{nicktype}, "A", $args{nick} ); }
}
sub sendmsg
{
my ( $msg, $nicktype, $chantype, $username ) = @_;
if ($nicktype == 1)
{
plugin::ircmsg ($msg, $chantype );
}
else
{
my ( $result, %player ) = playerData::getPlayerData( $username );
if ( $result == 1 )
{
modules::pagePlayer ( $player{'id'}, "Brenbot", "$msg." );
}
}
}
![http://s18.postimage.org/jc6qbn4k9/bricks3.png](http://s18.postimage.org/jc6qbn4k9/bricks3.png)
[Updated on: Sun, 24 October 2010 21:30] Report message to a moderator
|
|
|
|
Re: BrenBot help. [message #438287 is a reply to message #438259] |
Mon, 25 October 2010 04:43 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) |
![](http://renegadeforums.com/images/custom_avatars/2893.jpg) |
danpaul88
Messages: 5795 Registered: June 2004 Location: England
Karma: 0
|
General (5 Stars) |
|
|
Why are you adding up the number of GDI and Nod players instead of just getting the player list (which you do a few lines later) and checking how many items are in it? ![Rocked Over](images/smiley_icons/rockdover.gif)
EDIT: And, for reference, you shouldn't ever be accessing ServerStatus, PlayerData or modules directly, they are NOT part of the plugin interface and any plugins using them may break in future versions of BRenBot. You should use plugin::getPlayerList to get the player list and plugin::pagePlayer to page a player. All of the functionality you have used should be available through the plugin interface, if it is not you should request that it is added so you can create future-proof plugins.
[Updated on: Mon, 25 October 2010 04:45] Report message to a moderator
|
|
|