Server Help

Bot Questions - Help me (again LoL)

The Arctica - Sat Dec 04, 2004 1:14 pm
Post subject: Help me (again LoL)
Hey,

I have a struct, in the struct there are data of the player (name, kills, deaths). When a player dies i want to add ++death but, how do i know the slot of the player ?

Thanks alot anyways.

-The Arctica icon_cool.gif
D1st0rt - Sat Dec 04, 2004 1:24 pm
Post subject:
Are you using merv? If you are, I would probably use tags as they are easier.

Whatever you end up using, Underlord's Tutorial tells you how to go about it
Bak - Sat Dec 04, 2004 2:11 pm
Post subject:
structInstance->deaths++;

you get the right struct instance based on how you stored it... like in a linked list you would have to iterate through the list looking for when the right name.
CypherJF - Sat Dec 04, 2004 2:16 pm
Post subject:
Noting that if two players have the first same 19 characters; looping through comparing player names won't work correctly. icon_wink.gif
Cyan~Fire - Sat Dec 04, 2004 6:44 pm
Post subject:
You could record it by ident. I did it once and it worked fine.
Anonymous - Sun Dec 05, 2004 3:39 am
Post subject:
I'd just tag the player...
Take a look at the tutorial D1st0rt posted.
I think it's explained there.

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole....
Underlord - Sun Dec 05, 2004 9:09 am
Post subject:
assuming a struct of type:

Code: Show/Hide

#define MAX_PILOT=300;

struct pilot{
   char name[20];
   int kills;
    int deaths;
};

pilot pilots[MAX_PILOT];



to find a pilot slot

Code: Show/Hide


int botInfo::GetPilot(Player *p)
{
      // assumes: any player searched for already exists in the struct, otherwise sends back MAX_PILOT as slot
      int pilot = 0;

      for (pilot=0; pilot < MAX_PILOT;  pilot++)  // cycle struct slots
           if (strcmp(p->name,pilots[pilot].name)==0)  // compare pilot name to struct slot name
               break;  // found pilot
     
       return pilot;
}

// to use in spawn.cpp

case EVENT_PlayerDeath:  {

   Player *p = (Player*)event.p[0];

   int slot = GetPilot(p);

    if (slot < MAX_PILOT)
         pilots[slot].deaths++;
}


hopefully u know how to insert and delete slots as they enter/leave arena, and initialize struct data before using

tutorial location: http://www.dzleagues.com/bots/MERVbot_tutorial.html

20 character name bug ('player entering' packet only sends 19 i think) only solved by tracking userids from *einfo. easier to just disallow 19+ character names (not count them, speclock, ban, etc)
CypherJF - Sun Dec 05, 2004 12:09 pm
Post subject:
Thats what I ended up doing; writing out code that would kick them out w/ a warning message. icon_wink.gif
Cyan~Fire - Sun Dec 05, 2004 12:20 pm
Post subject:
Like ew, no, that's so inefficient. As long as you don't actually need to save the info after the player leaves, use the frickin' ident.
D1st0rt - Sun Dec 05, 2004 1:39 pm
Post subject:
Wouldn't just a tag be more efficient? and easy?

you can like
Code: Show/Hide
#define DEATHS 0
get_tag(p,DEATHS);

All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group