Re: [NEWBIE] If statement checking all sockets

From: Luke Waite (lwaite2000@home.com)
Date: 12/28/00


Ok sorry forget the other message.
I have this much.

ACMD(do_level)
{
 struct descriptor_data *i;

     for (i = descriptor_list; i; i = i->next)
       if (STATE(i) == CON_PLAYING)
         if (GET_LEVEL(i->character) == GET_LEVEL(ch)){
           sprintf(buf, "%s chats, '%s'.", GET_NAME(ch), argument);
           SEND_TO_Q(buf, i);
           }
}
Ok here's my problem. It shows the
Joe chats, 'Hi everyone'.
to the person that chats it, but, not to the others.

Thanks

Brandon Brown wrote:
>
> > How do I make an IF statement check all the playing sockets. So like say a
> > level chat. Yes I know this is a bad example but... I know this much
> > so maybe
> >      if (GET_LEVEL == GET_LEVEL(ch))
> >               ^             ^
> > Check of all the players    Level of the player executing the command
> > Oh yeah and I would prefer it not in do_gen_comm.
>
>     I'm not going to tell you because that'd be too easy. ;)
>
>     Where does something like this occur?  A few places.. the one that comes
> to mind, for example's use is send_to_all in comm.c:
>
> void send_to_all(char *messg)
> {
>   struct descriptor_data *i;
>
>   if (messg)
>     for (i = descriptor_list; i; i = i->next)    (*1)
>       if (STATE(i) == CON_PLAYING)   (*2)
>         SEND_TO_Q(messg, i);
> }
>
> *1 - This is what's cycling through all of the sockets connected.
> *2 - This where you would check the level - except you'd want to use if
> (GET_LEVEL(i->character) == whatever)
>
>     Hope that helps you get started. :)
>
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>   B. Brown                                                     TimeTraveller
>   Senior Programmer                                      'Lost in Time,
>   U&A Software InterActive                            'and Loving it!'
>   http://www.uasoft.com/staff/bbrown/         http://www.uasoft.com/
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>
> --
>    +---------------------------------------------------------------+
>    | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
>    | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
>    +---------------------------------------------------------------+

--
**************************************************
*                                                *
*               Endon, Head God of               *
*       M E D I E V A L    C O N Q U E S T       *
*                                                *
**************************************************

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/11/01 PDT