do_as.txt

snippets · 1.1 KB · 2010-03-30

do_as: attaches the immortal's descriptor to a character and runs a command (a mix of snoop and force).

Download   « Back to the snippets list

/*
   do_as
   Attaches the immortal's descriptor to the character, then executes
   a command, so the immortal sees the output.  Like a cross between
   snoop and force.
*/
void do_as(CHAR_DATA *ch, char *argument)
{
    char arg[MAX_STRING_LENGTH];
    CHAR_DATA *target;
    DESCRIPTOR_DATA *temp; 

    argument = one_argument(argument, arg);

    target = get_char_world(ch, arg);

    if (target == NULL)
    {
        send_to_char("As who what?\n\r", ch);
        return;
    }

    if (!IS_NPC(target) && get_trust(ch) <= get_trust(target))
    {
        send_to_char("I don't think so.\n\r", ch);
        return;
    }

    /* any commands that might screw with the descriptors should
       probably be blocked */
    if (!str_prefix(argument, "quit")
    || !str_prefix(argument, "delete")
    || !str_prefix(argument, "switch"))
    {
        send_to_char("You will need to use the 'force' command!\n\r", ch);
        return;
    }

    temp = target->desc;
    target->desc = ch->desc;
    interpret(target, argument);
    target->desc = temp;
}

Site Stats

Snippets: 1791
Codebases: 571