Server Help

Bot Questions - TkBot v2 Help (Merv)

TheOne - Thu Apr 13, 2006 8:11 pm
Post subject: TkBot v2 Help (Merv)
I'm trying to change a couple of things in the Tk Bot v2 bot by 50% Packetloss.

Now before I changed anything I wanted to see if everything was working, so I compiled. I got these errors:

\command.cpp(493): error C2666: 'String::operator`!='' : 3 overloads have similar conversions

\datatypes.h(198): could be 'bool String::operator !=(const String &)'

\spawn.cpp(57): error C2666: 'String::operator`=='' : 3 overloads have similar conversions




Quote:
spawn.cpp
\TkBot2\spawn.cpp(57) : error C2666: 'String::operator`=='' : 3 overloads have similar conversions
\datatypes.h(194): could be 'bool String::operator ==(const String &)'
\datatypes.h(192): or 'bool String::operator ==(const char *)'
or 'built-in C++ operator==(char *, char *)'
while trying to match the argument list '(String, char [20])'
note: qualification adjustment (const/volatile) may be causing the ambiguity
command.cpp
\TkBot2\command.cpp(493) : error C2666: 'String::operator`!='' : 3 overloads have similar conversions
\datatypes.h(198): could be 'bool String::operator !=(const String &)'
\datatypes.h(196): or 'bool String::operator !=(const char *)'
or 'built-in C++ operator!=(char *, char *)'
while trying to match the argument list '(String, char [20])'
note: qualification adjustment (const/volatile) may be causing the ambiguity
\TkBot2\command.cpp(493) : error C2666: 'String::operator`!='' : 3 overloads have similar conversions
\datatypes.h(198): could be 'bool String::operator !=(const String &)'
\datatypes.h(196): or 'bool String::operator !=(const char *)'
or 'built-in C++ operator!=(char *, char *)'
while trying to match the argument list '(String, char [20])'
note: qualification adjustment (const/volatile) may be causing the ambiguity


The code is:


Code: Show/Hide

                  if(!PlayerName.IsEmpty())
                  {
                     if((PlayerName != p->name) && (PlayerName != me->name))
                     {
                        TkStats* Tker= FindTker(PlayerName);
                        if(Tker == NULL)

and
Code: Show/Hide

{
   _listnode <Player> *pl= playerlist->head;
   bool Found=false;
   while(pl)
   {
      if(Name == pl->item->name)
      {
         Found=true;
         break;
      }
      pl=pl->next;
   }
   return Found;
}


I'd appreciate any help I could get, thanks. icon_smile.gif
Solo Ace - Fri Apr 14, 2006 2:33 am
Post subject:
Compiles fine here, but you seem to be having problems comparing a char[] to a String with the String overloads.

A way to solve these problems is by using the following.
Note: I commented the original code.
Code: Show/Hide
                  if(!PlayerName.IsEmpty())
                  {
                     if (!CMPSTR(PlayerName, p->name) && !CMPSTR(PlayerName, me->name))
                     //if((PlayerName != p->name) && (PlayerName != me->name))
                     {


Code: Show/Hide
   while(pl)
   {
      if (CMPSTR(Name.msg, pl->item->name))
   //   if(Name == pl->item->name)
      {

Cyan~Fire - Fri Apr 14, 2006 12:21 pm
Post subject:
Why not just use stricmp()?
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group