User Control Panel
Advertisements

HELP US, HELP YOU!

atag elsif. Broken.

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Code Review
View unanswered posts
Author Message
Addict
Not Yet a God
Not Yet a God


Joined: 21 Jan 2004
Posts: 473

Reputation: 34.4Reputation: 34.4Reputation: 34.4

PostPosted: Tue Jan 18, 2005 11:03 pm    Post subject: Reply with quote

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:
Code:
$bot = {};
.

Smile
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Tue Jan 18, 2005 11:06 pm    Post subject: Reply with quote

Quote:
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. Smile

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
Addict
Not Yet a God
Not Yet a God


Joined: 21 Jan 2004
Posts: 473

Reputation: 34.4Reputation: 34.4Reputation: 34.4

PostPosted: Tue Jan 18, 2005 11:31 pm    Post subject: Reply with quote

umm it doesn't.. it doesn't reply at all. Sad
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Wed Jan 19, 2005 12:40 am    Post subject: Reply with quote

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 Razz ).

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Code Review All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group