com/atell.c and help/atell - examples for course 08

[previous example] [course08] [Table of contents] [next example]
/* Filename      : atell.c
 * Description   : area-tell command 
 *
 * written       : 05-10-1996 - Gunner
 * last modified : 27-05-1998 - Gunner
 * HTML-Version  : 04-02-2000 - Ghorwin
 */

#include <mudlib.h>
#include "/doc/crashcourse/defs.h"
inherit I_COMMAND;

#define HELPDIR "/doc/crashcourse/course08/help/"

string
query_action()
{
    return "atell";
}

string
short_help()
{
    return "This will send a message to all players within a "
        "certain area.\n";
}

string
help()
{
    return HELPDIR + "atell";
}

static int
main(string arg)
{
    object player, room;
    int t, num = 0;
    string path, message, file;

    if (!arg || sscanf(arg,"%s %s",path,message) != 2)
        NOT_FAIL("atell <path> <message>\n");

    foreach(player in users())
    {
        room = ENV(player);
        if (!room) continue;
        file = source_file_name(room);
        if (strlen(path) > strlen(file)) continue;
        if (file[0..strlen(path)-1] == path)
        {
            tell_object(player,message+"\n");
            tell_object(TP,"The message was sent to: " + 
                CAP(Q_RNAME(player)) + ".\n");
            num++;
        }
    }
    if (!num)
        tell_object(TP,"Sorry, no users found in that path.\n");

    return 1;
}

help/ctell


NAME
        atell - send a message to all users in a special area

SYNTAX
        atell <path> <message>

DESCRIPTION
        This command will send a message to all users in a special area.
        The area is specified with its dir or parts of it.

EXAMPLE
        atell /d/Mloria Howdy folks...
        Would send the message to all players in the Mloria domain.

        atell /players/gunner Hia!
            Would send the message to all players inside a room created
            by Gunner. :-0

SEE ALSO