Hey all,
Almost a year ago, I posted some AFK code. It worked, but it was kind of
bad. So I have decided to redo it. This can replace the AFK code of mine
on the snippets page.
#define PRF_AFK (1 << ##) /* Player is AFK */
where ## is whatever is next on your PRF listing.
In char_player_data, add:
char *afk_message; /* PC / NPC's AFK MESSAGE */
In char_file_u, add:
char afk_message[POOF_LENGTH + 1];
------------------------ NOTE: THIS WILL CORRUPT YOUR PFILE! ---------------
With the function prototypes at the top of utils.h, add:
void set_afk(struct char_data *ch, char *afk_message, int result);
with the POOFIN(ch) defines, put
#define AFK_DEFAULT "I am afk, not looking at keyboard"
#define GET_AFK(ch) ((ch)->player.afk_message)
If you want it to save in pfile, you will need to modify the character
saving/loading functions in db.c
In limits.c, add:
void set_afk(struct char_data * ch, char *afk_message, int result)
{
if (!*afk_message)
sprintf(buf1, "%s", AFK_DEFAULT);
else
sprintf(buf1, "%s", afk_message);
if (strlen(buf1) > POOF_LENGTH) {
send_to_char("Afk message too long, using default.\r\n", ch);
sprintf(buf1, "%s", AFK_DEFAULT);
}
if (GET_AFK(ch))
free(GET_AFK(ch));
GET_AFK(ch) = NULL;
GET_AFK(ch) = str_dup(buf1);
if (result) {
sprintf(buf, "$n has just gone AFK: %s", GET_AFK(ch));
act(buf, FALSE, ch, 0, 0, TO_ROOM);
sprintf(buf, "You have just gone AFK: %s", GET_AFK(ch));
act(buf, FALSE< ch, 0, 0, TO_CHAR);
} else {
act("$n is back from AFK!", FALSE, ch, 0, 0, TO_ROOM);
act("You are back from AFK!", FALSE, ch, 0, 0, TO_CHAR);
}
}
In act.other.c, put this:
ACMD(do_afk)
{
int result;
if (IS_NPC(ch)) {
send_to_char("Mobs don't have keyboards, go away.\r\n", ch);
return;
}
skip_spaces(&argument);
if (PRF_FLAGGED(ch, PRF_AFK)) {
result = FALSE;
REMOVE_BIT(PRF_FLAGS(ch), PRF_AFK);
} else {
result = TRUE;
SET_BIT(PRF_FLAGS(ch), PRF_AFK);
}
set_afk(ch, argument, result);
}
In act.comm.c, in ACMD(do_tell)
after
else if (PRF_FLAGGED(vict, PRF_NOTELL) || ROOM_FLAGGED(vict->in_room, ROOM_SOUNDPROOF))
act("$E can't hear you.", FALSE, ch, 0, vict, TO_CHAR | TO_SLEEP);
add:
else {
if (PRF_FLAGGED(vict, PRF_AFK)) {
sprintf(buf, "%s is AFK and may not hear your tell.\r\n", GET_NAME(vict));
send_to_char(buf, ch);
sprintf(buf, "MESSAGE: %s\r\n", GET_AFK(vict));
send_to_char(buf, ch);
}
In act.informative.c, in list_one_char, after:
if (PLR_FLAGGED(i, PLR_WRITING))
strcat(buf, " [COMPOSING]"); <---- I think it's (Composing) in stock Circle
add:
if (PRF_FLAGGED(i, PRF_AFK))
strcat(buf, " [AFK]");
In do_who after
if (PRF_FLAGGED(tch, PRF_NOTELL))
strcat(buf, " [NO-TELLS]"); <---- Think it is (No-Tell) in stock Circle
if (PRF_FLAGGED(tch, PRF_AFK))
strcat(buf, " [AFK]");
In comm.c, in make_prompt,
before:
if (PRF_FLAGGED(d->character, PRF_DISPHP))
sprintf(prompt, "%s%s<%dhp ", prompt,
CBBLU(d->character,C_SPR),GET_HIT(d->character));
add:
if (PRF_FLAGGED(d->character, PRF_AFK))
sprintf(prompt, "%s%s[AFK]%s", prompt, CBCYN(d->character, C_SPR),
CCNRM(d->character, C_SPR));
/ \
_ ) (( )) (
(@) /|\ ))_(( /|\ _
|-|`\ / | \ (/\|/\) / | \ (@)
| | ------------/--|-voV---\`|'/--Vov-|--\--------------|-|
|-| '^` (o o) '^` | |
| | James C. Thomas Jr. `\Y/' Founder of Finality |-|
|-| rasdan@finality.com | |
| | finality.com 4000 |-|
|_|_____________________________________________________| |
(@) l /\ / ( ( \ /\ l `\|-|
l / V \ \ V \ l (@)
l/ _) )_ \I
`\ /'
`
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST