Author |
Message |
The Arctica Newbie
Gender: Joined: Dec 04 2004 Posts: 13 Offline
|
Posted: 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  |
|
Back to top |
|
 |
D1st0rt Miss Directed Wannabe

Age:37 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: 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 _________________
 |
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: 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. |
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: 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.  _________________ Performance is often the art of cheating carefully. - James Gosling |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sat Dec 04, 2004 6:44 pm Post subject: |
 |
|
|
|
You could record it by ident. I did it once and it worked fine. _________________ 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 |
|
 |
k0zy (too lazy to login) Guest
Offline
|
Posted: 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.... |
|
Back to top |
|
 |
Underlord Novice
Gender: Joined: Feb 17 2004 Posts: 55 Offline
|
Posted: Sun Dec 05, 2004 9:09 am Post subject: |
 |
|
|
|
assuming a struct of type:
#define MAX_PILOT=300;
struct pilot{
char name[20];
int kills;
int deaths;
};
pilot pilots[MAX_PILOT];
|
to find a pilot slot
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) |
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: 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.  |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: 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. |
|
Back to top |
|
 |
D1st0rt Miss Directed Wannabe

Age:37 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
|
Back to top |
|
 |
|