if.txt
snippets · 1.3 KB · 2010-03-30
A helpful ifcheck for SMAUG (posted by Christopher Wigginton).
Download « Back to the snippets list
From: "Wigginton, Christopher" <Wigginton#m#_Christopher@msgate.apple.com>
Cc: smaug@realms.game.org
Subject: A helpful ifcheck....
Hi Y'all,
Just thought I'd share a helpful ifcheck I use on my mud. With tunnels and private rooms, I needed the ability to check the number of pcs/mobs in a room before I mptransferred, mpmload, etc...
The is mobinroom and so forth ifcheck didn't quite cut it enough since you had to specify the mob vnum
just place it somewhere in your ifchecks...
Regards,
Golias
-----------------------------------------------------------------------------
if ( !str_cmp(chck, "roomcount") )
{
int room_vnum = atoi(cvar);
int lhsvl;
CHAR_DATA *oMob;
ROOM_INDEX_DATA *location;
if ( !room_vnum )
location = mob->in_room;
else
location = get_room_index( room_vnum );
if (location == NULL)
{
progbug( "mud_prog.c: Bad Location in roomcount", mob );
return BERR;
}
lhsvl = 0;
for ( oMob = location->first_person; oMob;
oMob = oMob->next_in_room )
if ( oMob != supermob )
lhsvl++;
rhsvl = atoi(rval);
if ( rhsvl < 1 ) rhsvl = 1;
if ( !*opr )
strcpy( opr, "==" );
return mprog_veval(lhsvl, opr, rhsvl, mob);
}