Re: [NEWBIE] If statement checking all sockets

From: Brandon Brown (
Date: 12/28/00

> 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. ;)

    The trick to teaching yourself how to code while working with Circle is
to think about each part of what you want to do, and find a place in the
already-written code that it exists..then modify that code to fit what you
need.  This is called a 'hack' - taking existing code and improving upon
it/altering it for your own use.

    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!'

   | FAQ: |
   | Archives: |

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