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
setfreq

 
Post new topic   Reply to topic Printable version
 View previous topic  elim bot Post :: Post Huge Bot project, C++ Coders Read  View next topic  
Author Message
JaqMs14
Guest


Offline

PostPosted: Mon Jul 05, 2004 1:10 pm    Post subject: setfreq Reply to topic Reply with quote

How do I code a !setfreq command? Here is my curret code but it is doesn't work at all.

Code: Show/Hide
else if(c->check("setfreq"))
         {
            if (isNumeric(c->final))
            {
               String setship="*setfreq ";
               setfreq+=getInteger(c->final,10);
               for(_listnode <Player> *pl=playerlist->head;pl;pl=pl->next)
               {
                  if(pl->item->freq!=8)
                  {sendPrivate(pl->item,setfreq);}
               }
               sendPrivate(p,"Freq changes Complete");
            }
            else
            {sendPrivate(p,"You must specify a freq number.");}

         }


Then the error is:

c:\documents and settings\....\desktop\src\bot\command.cpp(125) : error C2065: 'setfreq' : undeclared identifier
Back to top
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Mon Jul 05, 2004 1:44 pm    Post subject: Reply to topic Reply with quote

You never defined setfreq icon_smile.gif

unsigned int setfreq = 0; // change.
setfreq+=getInteger(c->final,10);
_________________
Performance is often the art of cheating carefully. - James Gosling
Back to top
View users profile Send private message Add User to Ignore List
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: Mon Jul 05, 2004 2:14 pm    Post subject: Reply to topic Reply with quote

Ew. new_Eyecrazy.gif
The coding style in that piece of code is even more ugly than Dustpup's style. icon_razz.gif

And Cypher, what you gave him as solution wouldn't work either, he could've used "String setfreq = "*setfreq ";" instead of what he used on that line. icon_biggrin.gif

Me thinks you should use the following.

Code: Show/Hide
else if (c->check("setfreq"))
{
   if (isNumeric(c->final))
   {       
      String setfreq = "*setfreq ";
      setfreq += getInteger(c->final,10);

      _listnode <Player> *parse = playerlist->head;

      while (parse)
      {
         Player *p = parse->item;

         if (p->freq != 8) // Why are you doing this?!? Btw, when I worked with MERV p->team was used for the frequency number, did it get changed!?
            sendPrivate(p, setfreq);

         parse = parse->next;
      }
      sendPrivate(p,"Frequency changes complete.");
   }
   else
      sendPrivate(p, "You must specify a valid frequency number.");
}
Back to top
View users profile Send private message Add User to Ignore List
JaqMs14
Guest


Offline

PostPosted: Mon Jul 05, 2004 2:23 pm    Post subject: Reply to topic Reply with quote

Yes I know, it's messy. I copied it from a !setship command and I thought it would do the same thing.
Back to top
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: Mon Jul 05, 2004 2:32 pm    Post subject: Reply to topic Reply with quote

Of course checking if the parameter of the command is a valid freq number (0 <= number && number <= 9999) or something, and making sure the number is not the spectator frequency number could both be useful too.

But that's up to you, heh.
Back to top
View users profile Send private message Add User to Ignore List
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Mon Jul 05, 2004 4:11 pm    Post subject: Reply to topic Reply with quote

Oh true lol.. i didnt really pay much attention.. oops :/
Back to top
View users profile Send private message Add User to Ignore List
JaqMs14
Guest


Offline

PostPosted: Mon Jul 05, 2004 4:14 pm    Post subject: Reply to topic Reply with quote

One more question, how do I make it so that the users cannot switch frequencies/ships? I know you can do it by putting code in under case EVENT_PlayerTeam but I want to know if I can just lock it or something.
Back to top
JaqMs14
Guest


Offline

PostPosted: Mon Jul 05, 2004 4:23 pm    Post subject: Reply to topic Reply with quote

Sorry, never mind about that top post. Apperently, I didn't know all the things that *lock did.
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: Mon Jul 05, 2004 9:25 pm    Post subject: Reply to topic Reply with quote

Uint16 Freq= getInteger(c->final,10);//you could use this or do it by hand
if(Freq >= 0 && Freq <=9999)
{
char SetMsg[14];
sprintf(SetMsg,"*setfreq %d",Freq);

//then whatever else you want
}


Thing with Strings is that they allocate/deallocate memory everytime they perform a task and they run a bunch of crap code. I used them so i can get bots done quickly, but something small such as the *setfreq command should be put together with the sprintf function
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Tue Jul 06, 2004 10:21 am    Post subject: Reply to topic Reply with quote

Actually, for even more speedy-quickness, you don't have to do a negative check (unsigned).
_________________
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
View users profile Send private message Add User to Ignore List Visit posters website
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:41
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3615
Location: Las Vegas
Offline

PostPosted: Tue Jul 06, 2004 11:40 am    Post subject: Reply to topic Reply with quote

Cyan~Fire wrote:
Actually, for even more speedy-quickness, you don't have to do a negative check (unsigned).

A problem with this is that others that may read your code may not notice that, and may assume that there is a sign problem. So leaving it in may make it a bit slower, but better readable. Hopefully, a compiler may notice that its checked if an always positive value is positive, and may reduce that instruction for you, but it may not. Those things have been getting very smart these days.
Back to top
View users profile Send private message Add User to Ignore List Send email
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: 126 page(s) served in previous 5 minutes.

phpBB Created this page in 0.463405 seconds : 35 queries executed (93.5%): GZIP compression disabled