Server Help

Bot Questions - TWBot Coding Help.

BDwinsAlt - Mon Jul 11, 2005 6:05 pm
Post subject: TWBot Coding Help.
Well i just have a few questions, first of all...
If i have this:

public void handleCommand( String name, String message, String playerName ){
if( message.startsWith( "!ban ")){
m_botAction.sendUnfilteredPrivateMessage( playerName, "*kill 283892" );
}
}

How can i get this to work? It does not do anything when i type !ban in game. No errors are reported when i compile the coding either.

Also, how can i get the bot to send someone text from a txt or cfg?

Like !staff and you read from a file and send the text from there.

would it be something like:

...} else if( message.startsWith( "!staff" )){
m_botAction.send[w/e goes in here]
}
}
Contempt+ - Mon Jul 11, 2005 9:12 pm
Post subject:
Just incode the !staff in a merv bot. Instead of writing it in java.
BDwinsAlt - Mon Jul 11, 2005 9:19 pm
Post subject:
LOL! Nah serciously you guys know how?
D1st0rt - Sat Jul 16, 2005 4:00 pm
Post subject:
Check out the stuff here for basics on how I structure commands in my bots when not using the command interpreter.

Code: Show/Hide
public void handleCommand( String name, String message, String playerName )
{
    if( message.startsWith( "!ban "))   
        m_botAction.sendUnfilteredPrivateMessage( playerName, "*kill 283892" );
}


When I see this, I wonder if your handleCommand method ever gets called because I have never seen one that takes three parameters. How did you obtain the value to pass as playerName? It's also possible that the name is invalid so it gets sent to nobody. What I would do (haven't tested this) is more along these lines:
Code: Show/Hide
public void handleCommand( String name, String message)
{
    if( message.startsWith( "!ban "))   
       if(message.length() > 5)
       {
           Player p = m_botAction.getPlayer(message.substring(5));
           if(p != null)
              m_botAction.sendUnfilteredPrivateMessage(p.getPlayerID(), "*kill 283892");
           else
               m_botAction.sendPrivateMessage(name, "Invalid Player");
       }       
}


Hope this helps.
BDwinsAlt - Mon Jul 18, 2005 4:36 pm
Post subject:
Hey man you rock. You gave me a straight up awnser instead of something like "Make a new Bot". There are nice people on here! icon_smile.gif
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group