Server Help

Bot Questions - !challenge & !accept

Witchie NL - Mon Aug 14, 2006 8:44 am
Post subject: !challenge & !accept
Does anyone have any idea how to implent an !challenge <name> and !accept <name> part in an mervbot plugin. As told in another topic im working on an duel bot (edit from catid's duel.dll) but i have no idea how to build this part.

When done i will post the plugin here.
Witchie NL - Mon Aug 14, 2006 8:46 am
Post subject:
It keeps track of scores to.
k0zy - Mon Aug 14, 2006 8:52 am
Post subject:
I was just about to start a duel plugin, too.

What part are you having problems at?
Finding the player or saving the challange?

foomy hulk
Witchie NL - Mon Aug 14, 2006 3:17 pm
Post subject:
saving the challenges. If someone uses it it just scrolls playerlist to the specified player and then pm's him with !accept. but how does the bot remember which player challenged who and how to keep track of that when its realy bussy.

Code: Show/Hide

if (c->check("challenge"))
{
     if (!*c->final) {sendPrivate(p, "Syntax: !challenge <playername>");}
     else
     {
          String challenger, challenged;
          challenger = p->name;
          challenged = c->final;
         
          _listnode <Player> *parse = playerlist->head;      
          while (parse)
          {
                Player *p = parse->item;   
                {
                       if (p->name == challenged)
                       {
                               sendPrivate(p, (String)challenger + " Has challenged you for a duel, !accept to accept the duel!");
                       }
                }
          }
     }
}
else if (c->check("accept"))
{
       if (p->name == challenged)
       {
               sendPrivate(p, "You have accepted the duel");
               sendPrivate(p, "*warpto # #");
               sendPrivate(challenger, "*warpto # #");   
       }
}   


This is what i came up with but this will only work propperly when there are 2 players in the arena.
Witchie NL - Mon Aug 14, 2006 3:21 pm
Post subject:
i just wrote that with bare hands and it might be fucked coz this forum doest suport the Tab key. There might be some bug's to but this will explain it a bit.

Ive tryed it with playertag's to but when 2 players challenge the same player its fucked. only allows the 2nd player to duel.
Mine GO BOOM - Mon Aug 14, 2006 4:36 pm
Post subject:
Witchie NL wrote:
i just wrote that with bare hands and it might be fucked coz this forum doest suport the Tab key. There might be some bug's to but this will explain it a bit.

Found some code that will allow TABs to be inputted into textareas under IE fine, but with Firefox, it inputs the tab and then it highlights the preview button like before. But at least it puts a copy of a tab in the text box (which you can then copy/paste as needed).
D1st0rt - Mon Aug 14, 2006 10:52 pm
Post subject:
You could do something like

Code: Show/Hide
struct Challenge{
    Player *challenger;
    Player *challenged;
};

and then either store them in a list or hashmap
Cyan~Fire - Mon Aug 14, 2006 11:31 pm
Post subject:
Or use player tags.
Bak - Tue Aug 15, 2006 2:44 am
Post subject:
I'd store names instead of Player*'s
k0zy - Tue Aug 15, 2006 5:44 am
Post subject:
You could make up a random number.
Tag the challenger with that number, the competitor with that number+1.
That way you can identify both players before the duel.

If a player accepts a duel, simply search for the player with his tag -1.

That might work.
The number can also be some autoincrementing id, which would probably be better.
Cyan~Fire - Tue Aug 15, 2006 11:53 am
Post subject:
Uhh yeah, auto increment would be a lot better than a random number.

But you could allocate a structure for each duel and make the player tag a pointer to the structure. That would be very easy and simple.
Witchie NL - Wed Aug 16, 2006 7:55 am
Post subject:
ok ima try a few things. ima use struct's and the idea about give people tag's with each an unique duelID. ima post the updates here.

currently i have some bs with windows so ima need to reinstal it and tweak everything thing whole again, reinstal all programs etc etc. then ill start working on it.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group