Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Complex command help.

 
Post new topic   Reply to topic Printable version
 View previous topic  Question about workspaces in VC 6 Post :: Post Check lag with mervbot?  View next topic  
Author Message
Pests
Novice


Joined: Feb 24 2003
Posts: 84
Offline

PostPosted: Tue Dec 09, 2003 9:58 pm    Post subject: Complex command help. Reply to topic Reply with quote

I need a way to do this, I can do what I want to do, but not one part....

I want to make the bot so one player can give points to another, but it has to confirm with both players first. So one player will !give User 999 and it needs to first ask that user if thats really what they want to do, they will respond with a command (something like !yes or !no). If, yes, it needs to ask the same question to User, and again they need to respond in the same way the first person did. If this goes all good, then it will transfew the points. I need it so it will support 2 people asking one person, ect.

The only problem I have is storing who asked who, and when the second user responds with !y or !n, who the first user was.

I do have experence with the merv core, I just don't know how to do the above. Any ideas would help icon_smile.gif
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Tue Dec 09, 2003 10:33 pm    Post subject: Reply to topic Reply with quote

I'd say probably player pointers. Make a Nx2 array of player pointers, each entry having a pair (giver and receiver). That's the best thing I can come up with.
_________________
This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:41
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3615
Location: Las Vegas
Offline

PostPosted: Wed Dec 10, 2003 1:07 am    Post subject: Reply to topic Reply with quote

Learn what LinkedLists are, and how they work. Will do exactly what you need without problems.

Simple description of how to use it: Created the linked list, but without any data in it. As you add !give'd players, you create new links in the chain, and tack it onto the end of the list. The new link will contain the giver's name, the receiver's name, and how many points. Then, as someone accepts (or rejects) an offer, you go through the list to find the offer, and then remove it from the list. Maybe add a timer value also, so after 5 mins, the offer becomes invalid. Then you can have a function that is ran every minute or so, and cleans up the list.
Back to top
View users profile Send private message Add User to Ignore List Send email
Underlord
Guest


Offline

PostPosted: Wed Dec 10, 2003 8:32 am    Post subject: Reply to topic Reply with quote

Use the built-in player tags from mervbot.

Code: Show/Hide

spawn.h

enum ptags{
has_confirmed,
asker_ident,
prize_amount
};

spawn.cpp

int strcasecmp (const char *a, const char *b)
{
   // compare strings not case sensitive
   register int n;

   while (*a == *b || (n = tolower (*a) - tolower (*b)) == 0)
     {
       if (*a == '\0')
         return 0;
       a++, b++;
     }
   return n;
}

Player* botInfo::GetPilot(char *name)
{
    _listnode <Player> *parse = playerlist->head;

     while (parse)
     {
   Player *p = parse->item;

   if (strcasecmp(p->name,name)==0)
             return p;

   parse = parse->next;
      }
   return 0;
}

Player* botInfo::GetPilot(int id)
{
    _listnode <Player> *parse = playerlist->head;

     while (parse)
     {
   Player *p = parse->item;

   if (p->ident == id)
             return p;

   parse = parse->next;
      }
   return 0;
}


command.cpp

if (c->check("give"))
{
   // !give <name>,<amount>
   String str = c->final;

   int check = strstr(s,",")-s;
   String name = s.split(',");
   int amount = getInteger(s,10);

   Player t = GetPilot(name);

   if (t)
   {
      set_tag(p,asker_ident,t->ident);
      set_tag(p,has_confirmed,0);

      set_tag(t,has_verified,0);

      set_tag(t,prize_amount,amount);
     
     sendPrivate(p,"Verify sending '" + (String) t->name + "' " + (String) amount + " points by replaying !confirm");
   }
}

if (c->check("confirm"))
{
   if (get_tag(p,has_confirmed)==0)
   {
     set_tag(p,has_confirmed,1);

     Player t = GetPilot(get_tag(p,asker_ident));

     if (t)
     {
        sendPrivate(t,"'" + (String) p->name + "' wants to give you " + (String) amount + " points, grant by replying !yes");
      }
   }
}

if (c->check("yes"))
{
   int amount = get_tag(p,amount);

   if (amount > 0)
   {
      sendPrivate(p,"*points " + (String) amount);

      set_tag(p,prize_amount,0);
   }
   
}

That's the general idea, might be missing some code, only spent 5 mins on it.
Back to top
Pests
Novice


Joined: Feb 24 2003
Posts: 84
Offline

PostPosted: Wed Dec 10, 2003 10:53 am    Post subject: Reply to topic Reply with quote

That seems to be what im looking for, cept a few errors. Also might need to check if the first user confirmed before the second can type !yes, but that wouldnt be hard. Thanks.
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Wed Dec 10, 2003 4:42 pm    Post subject: Reply to topic Reply with quote

Player tags wouldn't be a good solution for this problem because you'd have to search them all the time.
The reason I suggested an array instead of a linkedlist is because it could be 2 dimensions.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:41
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3615
Location: Las Vegas
Offline

PostPosted: Wed Dec 10, 2003 10:10 pm    Post subject: Reply to topic Reply with quote

Cyan~Fire wrote:
The reason I suggested an array instead of a linkedlist is because it could be 2 dimensions.


The reason I suggested a linked list is so you wouldn't be eating massive amounts of memory for very low usage. Its better to learn a more advanced way every so often, even if for only a trival project, so you can use it in the future.
Back to top
View users profile Send private message Add User to Ignore List Send email
Dr Brain
Flip-flopping like a wind surfer


Age:39
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Wed Dec 10, 2003 11:01 pm    Post subject: Reply to topic Reply with quote

Learn the correct algorthm for the job. Linked lists are second to none for inserts and deletes. They are slower on reads than arrays, but for this job, they are the storage method of choice.

Arrays are great for reading/updating, but majorly suck for inserts and deletes (read: nearly impossible).

Vectors are like arrays, but allow you to grow the contents.

Linked lists can also be used for a million different things, like trees, circular lists, queues, stacks, maps and some other things that I have forgotten about.

Oh, and BTW, linked lists can be two dementional too tongue.gif.
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Bot Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 33 page(s) served in previous 5 minutes.

phpBB Created this page in 0.483734 seconds : 33 queries executed (94.1%): GZIP compression disabled