If you wanted to hardcode it, you could have do_jail look through each cell
to see if it is occupied or not.
This could be done with an array and a for loop, a for loop and no array, or
IF statements.  (other ways, too).  I imagine it'd be easier to just define
some cells in merc.h rather than have your code scan every room in the game
looking for ROOM_JAIL :-)

Look at the code for goto for some ideas.  If you're still humdingered, I'd
love to try my best to provide some code for you.

Relatedly, here's how I jail and unjail people.  I don't persay care about
multiple jailed people being in the same room as each other.  (You need
<time.h>, as I use ctime to record when people were jailed.  I place it in
their long descrip, as short and long descrips are not used by the game for
players anywho.  Also, I have two custom commands in jail--do_godsmack and
do_info.)


/* JH 'Jail' command, for punishing bad people */
void do_jail (CHAR_DATA * ch, char *argument)
{
    char arg[MAX_INPUT_LENGTH], buf[MAX_STRING_LENGTH];
    CHAR_DATA *victim;
    char strtime[MAX_STRING_LENGTH];

    one_argument (argument, arg);

    if (arg[0] == '\0')
    {
        send_to_char ("Jail whom?", ch);
        return;
    }

    if ((victim = get_char_world (ch, arg)) == NULL)
    {
        send_to_char ("They aren't here.\n\r", ch);
        return;
    }

    if (IS_NPC (victim))
    {
        send_to_char ("Not on NPCs.\n\r", ch);
        return;
    }

    if (get_trust (victim) >= get_trust (ch))
    {
        send_to_char ("That is {RNOT{x going to happen.\n\r", ch);
        return;
    }

    if (IS_SET (victim->act, PLR_JAILED))
    {
        send_to_char ("They are already in jail.\n\r", ch);
        return;
    }

    if (!IS_NPC (victim) && victim->desc == NULL)
    {
       act ("$N is currently {DLINKDEAD{x.", ch, NULL, victim, TO_CHAR);
       return;
    }

    /*punishment begins*/
    if (!IS_SET (victim->act, PLR_JAILED))
        SET_BIT (victim->act, PLR_JAILED);
        send_to_char ("Jailing character.\n\r---------------------\n\r",
ch);

    if (!IS_SET (victim->comm, COMM_NOCHANNELS))
    {
        SET_BIT (victim->comm, COMM_NOCHANNELS);
        send_to_char ("The gods have revoked your channel privileges.\n\r",
                      victim);
        send_to_char ("NOCHANNELS set.\n\r", ch);
        sprintf (buf, "$N revokes %s's channels.", victim->name);
        wiznet (buf, ch, NULL, WIZ_PENALTIES, WIZ_SECURE, 0);
    }

    do_godsmack (ch, arg);
    char_from_room (victim);
    char_to_room (victim, get_room_index (ROOM_VNUM_JAIL));
    send_to_char ("Player transferred to jail.\n\r", ch);
    sprintf(buf, "{W%s has been placed in {RJAIL{W for being an utter
{RMORON{x.\n\r", victim->name);
    do_info(ch, buf);

    /*below places the time they were jailed into their long description*/
    sprintf(strtime, "{WComment: Jailed by %s on %s{x\r", ch->name, ctime
(&current_time));

    free_string (victim->long_descr);
    victim->long_descr = str_dup (strtime);
    return;
}

void do_unjail (CHAR_DATA * ch, char *argument)
{
    char arg[MAX_INPUT_LENGTH], buf[MAX_STRING_LENGTH],
buf2[MAX_STRING_LENGTH];
    CHAR_DATA *victim;

    one_argument (argument, arg);

    if (arg[0] == '\0')
    {
        send_to_char ("Unjail whom?", ch);
        return;
    }

    if ((victim = get_char_world (ch, arg)) == NULL)
    {
        send_to_char ("They aren't here.\n\r", ch);
        return;
    }

    if (!IS_SET (victim->act, PLR_JAILED))
    {
     send_to_char ("They aren't jailed.\n\r", ch);
     return;
    }

    if (!IS_NPC (victim) && victim->desc == NULL)
    {
       act ("$N is currently {DLINKDEAD{x.", ch, NULL, victim, TO_CHAR);
       return;
    }

    /*punishment ends*/
    if (IS_SET (victim->act, PLR_JAILED))
        REMOVE_BIT (victim->act, PLR_JAILED);
        send_to_char ("Unjailing character.\n\r---------------------\n\r",
ch);

    if (IS_SET (victim->comm, COMM_NOCHANNELS))
    {
        REMOVE_BIT (victim->comm, COMM_NOCHANNELS);
        send_to_char ("The gods have restored your channel priviliges.\n\r",
                      victim);
        send_to_char ("NOCHANNELS removed.\n\r", ch);
        sprintf (buf, "$N restores channels to %s", victim->name);
        wiznet (buf, ch, NULL, WIZ_PENALTIES, WIZ_SECURE, 0);
    }

    char_from_room (victim);
    char_to_room (victim, get_room_index (ROOM_VNUM_ALTAR));
    send_to_char ("Player transferred to the Midgaard Altar.\n\r", ch);
    send_to_char ("You have been released from jail.\n\r", victim);
    buf2[0] = '\0';
    free_string (victim->long_descr);
    victim->long_descr = str_dup (buf2);
    return;
}


Reply via email to