I tryed to convert Cer's atag code but it doesnt work. Here is the code I got:
Code:
if($message =~/^atag$/){<br /> # Create the Azulian Tag game if it doesn't exist yet.<br /> my $exists = $bot->{games}->queryGame ('atag');<br /> if ($exists != 1) {<br /> $bot->{games}->create (<br /> id => 'atag',<br /> name => 'Azulian Tag',<br /> );<br /> }<br /><br /> # Set the callback.<br /> $bot->{$username}->{callback} = 'atag';<br /><br /> # If they're in the game...<br /> my $in = $bot->{games}->queryPlayer ('atag',$username);<br /> print "In Game: $in\n";<br /> if ($in == 1) {<br /> # See if they're using a sub-command.<br /> if ($message =~ /^help/i) {<br /> $self->sendMessage(":: Azulian Tag Help ::\n\n"<br /> . "Please type one of the keywords below for help on that subject:\n\n"<br /> . "!commands - See all Azulian Tag commands\n"<br /> . "!about - About Azulian Tag");<br /> }<br /> elsif ($message =~ /^about/i) {<br /> $self->sendMessage(":: About Azulian Tag ::\n\n"<br /> . "Azulian Tag is the inverse of traditional tag. The one who is \"it\" "<br /> . "is being hunted down by the other players. All I can provide you for "<br /> . "this game is the list of players, you must find out which one is \"it\".");<br /> }<br /> elsif ($message =~ /^commands/i) {<br /> $self->sendMessage(":: Commands List ::\n\n"<br /> . "help - Shows the Help Menu\n"<br /> . "tag username - Try and tag a user\n"<br /> . "say message - Broadcast a message to all players\n"<br /> . "exit - Quit the game\n\n"<br /> . ":: Moderator Functions ::\n"<br /> . "kick username - Kick a user\n"<br /> . "kill - Terminate the Game");<br /> }<br /> elsif ($message =~ /^kick (.*?)$/i) {<br /> my $user = $1;<br /> if (&Mod($username) || &Admin($username)) {<br /> # Kick the user.<br /> $bot->{games}->broadcast ('atag', ":: Azulian Tag ::\n\n$user has been kicked from the game.");<br /> $bot->{games}->dropPlayer ('atag', $user);<br /> if ($bot->{data}->{atag}->{it} eq $user) {<br /> my @players = $bot->{games}->listPlayers ('atag');<br /> $bot->{data}->{atag}->{it} = $players [ int(rand(scalar(@players))) ];<br /> }<br /> }<br /> else {<br /> $self->sendMessage("You do not have permission to kick users.");<br /> }<br /> }<br /> elsif ($message =~ /^kill/i) {<br /> if (&Mod($username) || &Admin($username)) {<br /> # Terminate the game.<br /> my @players = $bot->{games}->listPlayers ('atag');<br /> foreach my $item (@players) {<br /> delete $bot->{$item}->{callback};<br /> }<br /><br /> $bot->{games}->destroy (<br /> id => 'atag',<br /> force => 1,<br /> alert => 1,<br /> message => "Azulian Tag has been terminated by a moderator.",<br /> );<br /> }<br /> else {<br /> $self->sendMessage("You do not have permission to terminate this game.");<br /> }<br /> }<br /> elsif ($message =~ /^say (.*?)$/i) {<br /> my $say = $1;<br /><br /> # Send this message.<br /> $bot->{games}->broadcast ('atag', ":: Azulian Tag ::\n\n[$username] $say");<br /> }<br /> elsif ($message =~ /^players$/i) {<br /> # Get the players.<br /> my @players = $chaos->{games}->listPlayers ('atag');<br /> my $reply = ":: Players List ::\n\n"<br /> . join (", ", @players);<br /> $self->sendMessage($reply);<br /> }<br /> elsif ($message =~ /^exit$/i) {<br /> # Exit them.<br /> $bot->{games}->broadcast ('atag', ":: Azulian Tag ::\n\n$username has left the game.");<br /> $bot->{games}->dropPlayer ('atag', $username);<br /> if ($bot->{data}->{atag}->{it} eq $username) {<br /> my @players = $bot->{games}->listPlayers ('atag');<br /> $bot->{data}->{atag}->{it} = $players [ int(rand(scalar(@players))) ];<br /> }<br /> delete $bot->{$username}->{callback};<br /> }<br /> elsif ($message =~ /^tag (.*?)$/i) {<br /> # Tag them?<br /> my $tag = $1;<br /><br /> # If they were it...<br /> if ($bot->{data}->{atag}->{it} eq $tag) {<br /> $bot->{games}->broadcast ('atag', ":: Azulian Tag ::\n\n"<br /> . "The \"it\" has been found (was $tag). Now find out who tagged him!");<br /> $bot->{data}->{atag}->{it} = $username;<br /> }<br /> else {<br /> $self->sendMessage("Nope, not the one - keep searching!");<br /> }<br /> }<br /> else {<br /> $self->sendMessage("Invalid command, type \"!help\" for more information.");<br /> }<br /> }<br /> else {<br /> # If there is no "it"<br /> if (!exists $bot->{data}->{atag}->{it}) {<br /> $bot->{data}->{atag}->{it} = $username;<br /> }<br /><br /> # Add them.<br /> $bot->{games}->broadcast ('atag', ":: Azulian Tag ::\n\n$username has joined the game.");<br /> $bot->{games}->addPlayer ('atag',<br /> name => $username,<br /> );<br /><br /> $self->sendMessage("Welcome to Azulian Tag! Type \"!help\" for some help, or type \"!players\" to see who's playing now!");<br /> }<br />}
Here's what The code gives me:
Quote:
ToxicGuy says: !atag TCSBOT says: Invalid command, type "!help" for more information.
EDIT: Yes I did add
Code:
# Create a new game manager.<br />$bot->{games} = new Games::Manager (debug => 1);<br />$bot->{games}->setHandler (broadcast => \&gamesend);
to my bot file, and I do have the sub, and have set $bot like:
ToxicGuy says: !atag TCSBOT says: Invalid command, type "!help" for more information.
Code:
else {<br /> $self->sendMessage("Invalid command, type \"!help\" for more information.");<br /> }
It looks like you used the command once, it created the game and joined you into it. Try typing "tag " or type "help" and see how it replies to you. _________________ Current Site (2008) http://www.cuvou.com/
Another thing... it checks if their message begins with "atag" to check if it's a command, and then checks if it starts with the sub-commands ("help", "tag", "say", etc.)
You need to have the "atag" part stripped off the message first (Leviathan does that automatically ). _________________ Current Site (2008) http://www.cuvou.com/