char arg[MAX_INPUT_LENGTH];
one_argument(argument,arg);
void ch_printf( CHAR_DATA * ch, const char *fmt, … )
{
char buf[MAX_STRING_LENGTH * 2];
va_list args;
va_start( args, fmt );
vsprintf( buf, fmt, args );
va_end( args );
stc( buf, ch );
}
void do_beep(CHAR_DATA *ch, char *argument)
{
CHAR_DATA *victim;
char buf[MAX_STRING_LENGTH];
if(!argument || !(victim = get_char_world(ch,argument)))
{
stc("{cBeep who?{x\r\n",ch);
return;
}
if (IS_NPC(victim))
{
stc("{cYou can only beep players.{x\r\n",ch);
return;
}
if (IS_SET(victim->act,ACT_NOBEEP))
{
sprintf(buf,"{C%s {cis not accepting beeps at this time.{x\r\n",victim->name);
stc(buf,ch);
return;
}
/* If you change the message here, be sure to leave the \a in since it
* is what causes the audible beep.
*/
sprintf(buf,"{C%s {cis beeping you!{x\a\r\n",PERS(ch,victim));
stc(buf,victim);
sprintf(buf,"{cYou beep {C%s.{x\r\n",PERS(victim,ch));
stc(buf,ch);
return;
}
void do_beep(CHAR_DATA *ch, char *argument)
{
CHAR_DATA *victim;
if(!argument || !(victim = get_char_world(ch,argument)))
{
stc("{cBeep who?{x\r\n",ch);
return;
}
if (IS_NPC(victim))
{
stc("{cYou can only beep players.{x\r\n",ch);
return;
}
if (IS_SET(victim->act,ACT_NOBEEP))
{
ch_printf( ch, "{C%s {cis not accepting beeps at this time.{x\r\n",victim->name);
return;
}
/* If you change the message here, be sure to leave the \a in since it
* is what causes the audible beep.
*/
ch_printf( ch,"{C%s {cis beeping you!{x\a\r\n",PERS(ch,victim));
ch_printf( ch,"{cYou beep {C%s.{x\r\n",PERS(victim,ch));
return;
}
extern int ch_printf (CHAR_DATA *ch, const char *my_format, …) __attribute__ ((format (printf, 2, 3)));
#ifdef __GNUC__
# define GNUC_FORMAT(fmt,args) __attribute__ ((format (printf, fmt, args)))
#else
# define GNUC_FORMAT(fmt,args)
#endif
extern int ch_printf (CHAR_DATA *ch, const char *my_format, …) GNUC_FORMAT(2, 3);
These are very simple functions and not exactly very original, but I figured I'd release these since low4 is lacking in snippets. I'd like some constructive criticism on both of these snippets and any ideas for improving/fixing them.
Click Me for the do_score replacement snippet.
Click Me for the beep/nobeep snippet.