Exemplo n.º 1
0
void icec_showchannel(ice_channel *c, const char *from, const char *txt, int emote)
{
  DESCRIPTOR_DATA *d, *dnext;
  CHAR_DATA *ch;
  char buf[MAX_STRING_LENGTH];

  if (!c->local)
    return;
  
  sprintf(buf, emote ? c->local->format2 : c->local->format1, from, color_itom(txt));
  strcat(buf, "\n\r");
  
  for (d=descriptor_list; d; d=dnext)
  {
    dnext=d->next;

    ch=d->original ? d->original : d->character;

    if (!ch ||
	IS_NPC(ch) ||
	get_trust(ch) < c->local->level ||
	!ice_audible(c, imc_makename(ch->name, imc_name)) ||
	!imc_hasname(ch->pcdata->ice_listen, c->local->name))
      continue;

    send_to_char(buf, ch);
  }
}
Exemplo n.º 2
0
/* check for icec channels, return TRUE to stop command processing, FALSE otherwise */
bool icec_command_hook(CHAR_DATA *ch, const char *command, const char *argument)
{
  ice_channel *c;
  char arg[MAX_STRING_LENGTH];
  const char *word2;
  int emote=0;
  
  if (IS_NPC(ch))
    return FALSE;
  
#ifdef CIRCLE
  skip_spaces(&argument);
#endif
  
  c=icec_findlchannel(command);
  if (!c || !c->local)
    return FALSE;

  if (c->local->level > get_trust(ch))
    return FALSE;

  if (!imc_hasname(ch->pcdata->ice_listen, c->local->name))
    return FALSE;
  
  if (!ice_audible(c, imc_makename(ch->name, imc_name)))
  {
    send_to_char("You cannot use that channel.\n\r", ch);
    return TRUE;
  }

  word2=imc_getarg(argument, arg, MAX_STRING_LENGTH);

  if (!arg[0])
  {
    send_to_char("Use ichan to toggle the channel - or provide some text.\n\r", ch);
    return TRUE;
  }

  if (!str_cmp(arg, ",") ||
      !str_cmp(arg, "emote"))
  {
    emote=1;
    argument=word2;
  }
  
  icec_sendmessage(c, ch->name, color_mtoi(argument), emote);
  return TRUE;
}
Exemplo n.º 3
0
void icec_sendmessage(ice_channel *c, const char *name, const char *text, int emote) {
    imc_packet out;
    strcpy(out.from, name);
    imc_initdata(&out.data);
    imc_addkey(&out.data, "channel", c->name);
    imc_addkey(&out.data, "text", text);
    imc_addkeyi(&out.data, "emote", emote);
    /* send a message out on a channel */
    if(c->policy == ICE_PRIVATE) {
        /* send to the daemon to distribute */
        /* send locally */
        icec_showchannel(c, imc_makename(name, imc_name), text, emote);
        sprintf(out.to, "ICE@%s", ice_mudof(c->name));
        strcpy(out.type, "ice-msg-p");
    } else {
        /* broadcast */
        strcpy(out.type, "ice-msg-b");
        strcpy(out.to, "*@*");
    }
    imc_send(&out);
    imc_freedata(&out.data);
}