Author |
Message |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: 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 _________________ 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 |
|
 |
Plody Guest
Offline
|
Posted: 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. |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: 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. |
|
Back to top |
|
 |
Rifle Guest
Offline
|
Posted: 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 |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: 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. |
|
Back to top |
|
 |
Dustpuppy Server Help Squatter

Age:40 Gender: Joined: Jan 23 2003 Posts: 215 Location: England Offline
|
Posted: 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;
}
Rather than this:
botInfo::cheack_leave(Player *p)
{
if (p->name == array[p->team])
blah;
} |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Fri Sep 26, 2003 7:47 pm Post subject: |
 |
|
|
|
Oooooh ok, cool, thanks.
Any comments on alias? |
|
Back to top |
|
 |
ExplodyThingy Server Help Squatter
Age:38 Gender: Joined: Dec 15 2002 Posts: 528 Location: Washington DC Offline
|
Posted: 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. _________________ There are no stupid question, but there are many inquisitive idiots.
Loot
Dr Brain> I hate clean air and clean water. I'm a member of Evil Conservitive Industries |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

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