em_ote.c
skylib_mudos_v1/mudlib/cmds/living/em_ote.c · 1.7 KB
From the archive skylib_mudos_v1.tar.gz
Download the archive « Back to the archive contents
#include <library.h>
#include <player.h>
inherit COMMAND_BASE;
mixed cmd( string words ) {
string pad = " ";
if(!environment(this_player())) {
return notify_fail("You are in limbo, you cannot emote.\n");
}
if ( userp( this_player() ) && !creatorp(TP) ) {
// so we can remove the permission to do emotes.
if(this_player()->query_property("no emote")) {
return notify_fail(NOT_ALLOWED);
}
if ( (int)this_player()->adjust_sp( -EMOTE_COST ) < 0 ) {
return notify_fail( NO_POWER );
}
}
if ( !words || ( words == "" ) ) {
return notify_fail( "Syntax: emote <text>\n" );
}
words = strip_colours(words);
// have a go at replacing multiple spaces with a single one. This should
// stop anyone trying to format the emote to look as though it's an emote
// followed by a tell or somesuch.
words = replace(words, ({" ", " ",
" ", " ",
" ", " ",
" ", " ",
" ", " ",
" ", " ",
" ", " "}));
this_player()->adjust_time_left( -5 );
if (words[0..0] == "'") pad = "";
environment( this_player() )->event_emote( this_player(),
"$C$" + this_player()->one_short() + pad +
words +"\n" );
all_inventory( environment( this_player() ) )->
event_emote( this_player(), "$C$" + this_player()->one_short() +
pad + words + "%^RESET%^\n" );
write( "You emote: $C$"+
(string)this_player()->pretty_short( this_player() ) + pad + words +
"%^RESET%^\n" );
return 1;
} /* cmd() */