Author |
Message |
Doggeti Server Help Squatter

Age:40 Gender: Joined: Jan 12 2003 Posts: 297 Location: Germany Offline
|
Posted: Thu Jul 22, 2004 8:23 am Post subject: gotCommand does not react |
 |
|
|
|
The bot should be able to receive commands via chat channels. I have this code in spawn.cpp:
case MSG_Channel:
{
char *colon;
char *pointybracket;
char name[32];
char text[256];
char *command = &text[1];
colon = strstr(msg, ":");
pointybracket = strstr(msg, ">");
strncpy(name, colon + 1, pointybracket - colon - 1);
strcpy(text, pointybracket + 2);
for (int i = 0; i < strlen(text); i++)
{
text[i] = tolower(text[i]);
}
if (strchr(text, '.'))
{
if (strchr(text, '.') - text == 0)
{
Command c (command);
Command *cp = &c;
if (strcmp(c.cmd, "help") == 0)
{
gotHelp(p, cp); // I call it but nothing happens
}
else
gotCommand(p, cp); // I call it but nothing happens
}
}
}
break;
}; |
_________________ Expect the worst but hope for the best. |
|
Back to top |
|
 |
Solo Ace Yeah, I'm in touch with reality...we correspond from time to time.

Age:37 Gender: Joined: Feb 06 2004 Posts: 2583 Location: The Netherlands Offline
|
Posted: Thu Jul 22, 2004 9:50 am Post subject: |
 |
|
|
|
I'm not sure if you know but...
MERV calls gotRemoteHelp() and gotRemote() (well, depending on what the user does, of course) when a command was used on a chat channel.
It did when I worked with MERV, I doubt it has changed, maybe it's easier to use that instead of using your code.  |
|
Back to top |
|
 |
Doggeti Server Help Squatter

Age:40 Gender: Joined: Jan 12 2003 Posts: 297 Location: Germany Offline
|
Posted: Thu Jul 22, 2004 9:57 am Post subject: |
 |
|
|
|
Ok, I will try it with gotRemoteHelp and gotRemote but why do these commands not react? I mean, all I do is calling the functions gotHelp and gotCommand like any other function. It seems as if spawn.cpp doesn't know these functions. |
|
Back to top |
|
 |
Solo Ace Yeah, I'm in touch with reality...we correspond from time to time.

Age:37 Gender: Joined: Feb 06 2004 Posts: 2583 Location: The Netherlands Offline
|
Posted: Thu Jul 22, 2004 10:04 am Post subject: |
 |
|
|
|
Hmm, run it through a debugger? |
|
Back to top |
|
 |
Doggeti Server Help Squatter

Age:40 Gender: Joined: Jan 12 2003 Posts: 297 Location: Germany Offline
|
|
Back to top |
|
 |
50% Packetloss Server Help Squatter

Age:40 Gender: Joined: Sep 09 2003 Posts: 561 Location: Santa Clarita, California Offline
|
Posted: Thu Jul 22, 2004 10:39 am Post subject: |
 |
|
|
|
Eh? Chat commands that start with a ! @ or . will be considered remote commands because the player may or may not be in the arena or even the zone. So the code does a event_remotecommand or a event_remote help then if you look at those events there is code to call the function. So you wont need to figure out the player's name, it is provided for you. But if you want to make it so your command only works over chat, then the only way to do it is the way you have setup above. The bot doesnt distiguish between remote message types in that event_remotecommand.
make char name[20]; it wont need to be longer
strstr looks for substrings, strchr looks for characters
remember that strchr will return NULL if it doesnt find the desired character, although this should never happen, you should still write code to look out for it
void botInfo::gotHelp(Player *p, Command *c)
1st this takes a Player, so the only way you are going to get a player is if they are in the same arena as the bot. If this is the case, there isnt much of a reason to use chat commands because the player could just PM the bot. Second you can pass C to the function like this, gotCommand(p, &c);
So if you cant get the Player struct for that player, you can still get the Operator_Level. You will need to open the mervbot.ini and get the location of the operators.txt or whatever the file was named. Then open that file to pull out the operators and thier lvls. Mervbot core has all of the source code for doing this. It would be more convient if the core had a function to get the op-lvl of a player, but it doesnt . Then if you wish to send a message back to the player, it will need to be sent remotly, there is a function for it in spawn.h |
|
Back to top |
|
 |
-Smong- Guest
Offline
|
|
Back to top |
|
 |
50% Packetloss Server Help Squatter

Age:40 Gender: Joined: Sep 09 2003 Posts: 561 Location: Santa Clarita, California Offline
|
Posted: Thu Jul 22, 2004 4:38 pm Post subject: |
 |
|
|
|
50% Packetloss wrote: |
strstr looks for substrings, strchr looks for characters
remember that strchr will return NULL if it doesnt find the desired character, although this should never happen, you should still write code to look out for it |
<3 |
|
Back to top |
|
 |
-Smong- Guest
Offline
|
Posted: Thu Jul 22, 2004 5:50 pm Post subject: |
 |
|
|
|
That's one good reason to login before posting, so you can edit your posts :/ |
|
Back to top |
|
 |
|