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
gotCommand does not react

 
Post new topic   Reply to topic Printable version
 View previous topic  player name help Post :: Post java Bot  View next topic  
Author Message
Doggeti
Server Help Squatter


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

PostPosted: Thu Jul 22, 2004 8:23 am    Post subject: gotCommand does not react Reply to topic Reply with quote

The bot should be able to receive commands via chat channels. I have this code in spawn.cpp:

Code: Show/Hide
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
View users profile Send private message Add User to Ignore List Send email AIM Address
Solo Ace
Yeah, I'm in touch with reality...we correspond from time to time.


Age:37
Gender:Gender:Male
Joined: Feb 06 2004
Posts: 2583
Location: The Netherlands
Offline

PostPosted: Thu Jul 22, 2004 9:50 am    Post subject: Reply to topic Reply with quote

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. icon_razz.gif
Back to top
View users profile Send private message Add User to Ignore List
Doggeti
Server Help Squatter


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

PostPosted: Thu Jul 22, 2004 9:57 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Send email AIM Address
Solo Ace
Yeah, I'm in touch with reality...we correspond from time to time.


Age:37
Gender:Gender:Male
Joined: Feb 06 2004
Posts: 2583
Location: The Netherlands
Offline

PostPosted: Thu Jul 22, 2004 10:04 am    Post subject: Reply to topic Reply with quote

Hmm, run it through a debugger?
Back to top
View users profile Send private message Add User to Ignore List
Doggeti
Server Help Squatter


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

PostPosted: Thu Jul 22, 2004 10:24 am    Post subject: Reply to topic Reply with quote

Look what I've found in dllcore.h

Code: Show/Hide
EVENT_Chat,
      /*   Chat message has been received.

         [0] Type
         [1] Sound
         [2] Player class/UNUSED
         [3] Message
      */


UNUSED :/
==> p in gotCommand(p, c); is NULL
==> gotCommand ignores it
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
50% Packetloss
Server Help Squatter


Age:40
Gender:Gender:Male
Joined: Sep 09 2003
Posts: 561
Location: Santa Clarita, California
Offline

PostPosted: Thu Jul 22, 2004 10:39 am    Post subject: Reply to topic Reply with quote

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 icon_sad.gif. 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
View users profile Send private message Add User to Ignore List Send email AIM Address
-Smong-
Guest


Offline

PostPosted: Thu Jul 22, 2004 3:38 pm    Post subject: Reply to topic Reply with quote

Briefly looking at the code I can see two improvements that can be made:
Code: Show/Hide
colon = strstr(msg, ":");
pointybracket = strstr(msg, ">");

/* becomes */
colon = strchr(msg, ':');
pointybracket = strstr(msg, "> ");

You might want to check for NULL being returned as I've seen at least one biller send messages like 'channel created by ...'.
Back to top
50% Packetloss
Server Help Squatter


Age:40
Gender:Gender:Male
Joined: Sep 09 2003
Posts: 561
Location: Santa Clarita, California
Offline

PostPosted: Thu Jul 22, 2004 4:38 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Send email AIM Address
-Smong-
Guest


Offline

PostPosted: Thu Jul 22, 2004 5:50 pm    Post subject: Reply to topic Reply with quote

That's one good reason to login before posting, so you can edit your posts :/
Back to top
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: 56 page(s) served in previous 5 minutes.

phpBB Created this page in 0.462127 seconds : 33 queries executed (87.9%): GZIP compression disabled