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
Playercount of the teams

 
Post new topic   Reply to topic Printable version
 View previous topic  MERVbot Post :: Post I need a complier...  View next topic  
Author Message
Doggeti
Server Help Squatter


Age:39
Gender:Gender:Male
Joined: Jan 12 2003
Posts: 297
Location: Germany
Offline

PostPosted: Wed Feb 05, 2003 7:04 am    Post subject: Playercount of the teams Reply to topic Reply with quote

How can I figure out how many players are in the teams in MervBot icon_question.gif Is there an array like 'playersInTeam[x]' or is there a possibility to use this playerlist icon_question.gif
_________________
Expect the worst but hope for the best.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
SOS (Skool)
Guest


Offline

PostPosted: Wed Feb 05, 2003 8:32 am    Post subject: Reply to topic Reply with quote

Uint16 teamplayers [MAX_TEAMS]; // Assuming MAX_TEAMS is the max number of teams you wanna check
_listnode<Player> *p = playerlist->head;
while (p)
{
if (p->team < MAX_TEAMS)
teamplayers[p->team]++;
p = p->next;
}
Back to top
Doggeti
Server Help Squatter


Age:39
Gender:Gender:Male
Joined: Jan 12 2003
Posts: 297
Location: Germany
Offline

PostPosted: Wed Feb 05, 2003 2:23 pm    Post subject: Reply to topic Reply with quote

In EVENT_PlayerSpec and EVENT_PlayerTeam I have added this line
Code: Show/Hide
checkTeams();
checkTeams looks like this:
Code: Show/Hide
void botInfo::checkTeams()
{
   Uint16 teamplayers[2];
   String s;
   _listnode<Player> *p = playerlist->head;
   while (p)
   {
      if (p->item->team < 2 && p->item->ship != SHIP_Spectator)
      teamplayers[p->item->team]++;
      p = p->next;
   }
   if (teamplayers[0] == teamplayers[1])
   {
      s = "Teams are even. Evens:";
      s += teamplayers[0];
      s += " Odds:";
      s += teamplayers[1];
   }else{
      s = "Teams are uneven. Evens:";
      s += teamplayers[0];
      s += " Odds:";
      s += teamplayers[1];
   }
   sendPublic(s);
}

It doesn't work. Do you see the error icon_question.gif
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
VampZ
Guest


Offline

PostPosted: Wed Feb 05, 2003 10:19 pm    Post subject: Reply to topic Reply with quote

try initializing:

teamplayers[0] = 0;
teamplayers[1] = 0;

before you use them.
Back to top
Doggeti
Server Help Squatter


Age:39
Gender:Gender:Male
Joined: Jan 12 2003
Posts: 297
Location: Germany
Offline

PostPosted: Fri Feb 07, 2003 9:35 am    Post subject: Reply to topic Reply with quote

Thank you. That was the solution. I first learned VB (I know, I know: It's not good starting with VB and then changing to C sa_tongue.gif )and there it's not necessary to initialize the variables to get the programs work properly.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
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: 677 page(s) served in previous 5 minutes.

phpBB Created this page in 0.443811 seconds : 30 queries executed (94.5%): GZIP compression disabled