Bot Questions - Alias and Player class functions Cyan~Fire - Mon Sep 22, 2003 6:45 pm Post subject: Alias and Player class functions
2 Questions:
1) Has anybody had problems with alias.dll just plain not recording names? It's kinda weird.
2) I keep getting a weird error in my plugin.
When I do this:
botInfo::cheack_leave(Player *p)
{
if (p->name == array[p->team])
blah;
}
The function doesn't work.
And yet this works:
botInfo::check_leave(String name, int team)
{
if (name == array[team])
blah;
}
Of course I am calling the function differently with:
check_leave(p);
check_leave(p->name, p->team);
So I'm doing it the second way but I could do a lot more and it would be simpler to do it the first. Any help/explanation would be appreciated!
Thanks,
Cyan~Fire
Anonymous - Wed Sep 24, 2003 7:53 am Post subject:
Because p->name (i think) is a char, and, looking at the array, that is type String. Do "String bleh = p->name", then use "if(bleh == array[p->team])".
That oughta work.
Cyan~Fire - Wed Sep 24, 2003 4:17 pm Post subject:
Hmmm, good thinking, I'll try it out later. I still don't fully understand how the String class works, basically I just have 'pidgin MERVBot', I don't really understand how a lot of it works.
Anonymous - Wed Sep 24, 2003 10:12 pm Post subject:
When I work with Mervbot-defined strings and my own variables ( such as char playername[20] ), I use strcmp instead of if (string1 == string2).
f.ex
if (strcmp(mystring,mervstring)==0)
{
tell(makeEcho("my string is equal to mervs string"));
}
else
{
tell(makeEcho("my string is not equal to mervs string"));
}
Note : Remember that strcmp is case-sensetive, so converting both strings to lowercase is recommended if f.ex you`re comparing a players input to f.ex a string from a text file.
You might have to #include "string.h" to use the strcmp function.
-Rifle
Cyan~Fire - Thu Sep 25, 2003 6:14 pm Post subject:
Thanks, but I think that's fixing what isn't broken. I'm using 'string1==string2' right now and it works. And case doesn't matter too because the value stored in 'array' is straight from p->name, so the case should be the same no matter what.
And anyway, my main problem is with alias.dll. I can't ban anybody the nice way because it records no player names and just says 'I have never seen them before.'
Thanks though.
Dustpuppy - Fri Sep 26, 2003 11:42 am Post subject:
The String object has it's own function for comparing to a char, so as long as you put it as the first item it will work. Like this:
botInfo::cheack_leave(Player *p)
{
if (array[p->team] == p->name)
blah;
}
Any comments on alias?
ExplodyThingy - Fri Sep 26, 2003 9:22 pm Post subject:
Clean the names out of the database, use the new(er) one on cats site, with the large-zone bug fix.
Cyan~Fire - Sat Sep 27, 2003 11:31 am Post subject:
Lol, whoops, sorry about that, the problem was just that my bot wasn't sysop. Oh well, thanks anyway.