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
player name help

 
Post new topic   Reply to topic Printable version
 View previous topic  Bots Post :: Post gotCommand does not react  View next topic  
Author Message
JaqMs14
Guest


Offline

PostPosted: Tue Jul 20, 2004 11:02 pm    Post subject: player name help Reply to topic Reply with quote

Ok, I am making a command: !makeguesser [name]. I put the things for input in commands.cpp but now I need to know how to make it so that the name specified will be changed to a certain frequency and ship. Help?
Back to top
Underlord
Novice


Gender:Gender:Male
Joined: Feb 17 2004
Posts: 55
Offline

PostPosted: Tue Jul 20, 2004 11:43 pm    Post subject: Reply to topic Reply with quote

Code: Show/Hide

if (c->check("makeguesser"))
{
     if(*c->final != NULL)
     {
         _listnode <Player> *parse = playerlist->head;

         Player *p = parse->item;

         while (parse)
         {
            if (strcmp(p->name,c->final)==0)
            {
                sendPrivate(p,"*setfreq 100");  // replace 100 with freq
                sendPrivate(p,"*setship 1");  // replace 1 with ship
                break;
            }

            parse = parse->next;
         }
     }
}


Last edited by Underlord on Wed Jul 21, 2004 12:14 pm, edited 3 times in total
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
JaqMs14
Guest


Offline

PostPosted: Wed Jul 21, 2004 1:32 am    Post subject: Reply to topic Reply with quote

It says "strcmp" is has an undeclared identifier. How do I declare it?
Back to top
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Wed Jul 21, 2004 2:35 am    Post subject: Reply to topic Reply with quote

#include "string.h"
_________________
4,691 irradiated haggis!
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: Wed Jul 21, 2004 5:21 am    Post subject: Reply to topic Reply with quote

Isn't it dangerous to declare a second Player *p. The function botInfo::gotCommand allready has a parameter Player *p.
_________________
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
50% Packetloss
Server Help Squatter


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

PostPosted: Wed Jul 21, 2004 7:39 am    Post subject: Reply to topic Reply with quote

depends on your compiler, it will spit out an error if it has a problem. Else it is fine. You could also do parse->item->name, no need for a pointer
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: Wed Jul 21, 2004 7:43 am    Post subject: Reply to topic Reply with quote

It looks better to do "p = parse->item", though; How do you code, 50%?
Without code?
Back to top
View users profile Send private message Add User to Ignore List
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Wed Jul 21, 2004 10:37 am    Post subject: Reply to topic Reply with quote

While I think it's bad style, declaring a variable of the same name inside any braces creates a new "version" that is locally scoped. As soon as you leave the braces, the higher level one "exists" again. This is a C standard.
Back to top
View users profile Send private message Add User to Ignore List
Underlord
Novice


Gender:Gender:Male
Joined: Feb 17 2004
Posts: 55
Offline

PostPosted: Wed Jul 21, 2004 12:15 pm    Post subject: Reply to topic Reply with quote

Code: Show/Hide

#include <string.h>

if (c->check("makeguesser"))
{
     if(*c->final != NULL)
     {
         _listnode <Player> *parse = playerlist->head;

         while (parse)
         {
            if (strcasecmp(parse->item->name,c->final)==0)
            {
                sendPrivate(parse->item,"*setfreq 100");  // replace 100 with freq
                sendPrivate(parse->item,"*setship 1");  // replace 1 with ship
                break;
            }

            parse = parse->next;
         }
     }
}


Jag, if you just google "c++ strcmp", you can instantly find what library you need
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
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: 35 page(s) served in previous 5 minutes.

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