pfreload.txt
snippets · 2.7 KB · 2010-03-30
Pfreload: reload a player file so you can edit it from the shell without kicking the player out.
Download « Back to the snippets list
/* Pfreload: allows you to "reload" a pfile so you can edit it in shell without making a player log out
The idea was taken from another snippet, but I pretty much had to write this one myself
This is writen for FotE, but should work in any SMAUG based mud (i think) -->Keberus
*/
void do_pfreload( CHAR_DATA * ch, char *argument )
{
CHAR_DATA *victim;
char arg[MAX_INPUT_LENGTH];
if( IS_NPC( ch ) )
return;
argument = one_argument( argument, arg );
if( arg[0] == '\0' )
{
send_to_char( "Reload who?\n\r", ch );
return;
}
if( !( victim = get_char_world( ch, arg ) ) )
{
send_to_char( "They are not here.\n\r", ch );
return;
}
if( get_trust( victim ) > get_trust( ch ) )
{
send_to_char( "You can't reload someone who's a higher level!\n\r", ch );
return;
}
if( exists_player( victim->name ) )
{
DESCRIPTOR_DATA *d;
char name[MAX_STRING_LENGTH];
char buf[MAX_STRING_LENGTH];
ROOM_INDEX_DATA *in_room;
bool Load;
d = NULL;
d = victim->desc;
sprintf( name, "%s", victim->name );
in_room = victim->in_room;
/*
* clear descriptor pointer to get rid of bug message in log
*/
victim->desc = NULL;
extract_char( victim, TRUE );
d->character = NULL;
Load = load_char_obj( d, name, FALSE, FALSE );
victim = d->character;
victim->desc = d;
victim->timer = 0;
/*
* Insert in the char_list
*/
LINK( d->character, first_char, last_char, next, prev );
char_to_room( victim, in_room );
if( Load )
{
send_to_char( "Your pfile has been reloaded.\n\r", victim );
send_to_char( "Their pfile has been reloaded.\n\r", ch );
sprintf( buf, "%s has been reloaded.", victim->name );
log_string( buf );
}
else
{
send_to_char( "Hrmm bug, it didnt work.\n\r", ch );
return;
}
}
else
send_to_char( "They have to have a pfile before you can load it.\n\r", ch );
return;
}
/*this function came from Rantic/Samson's name authorization snippet if you don't that installed...you'll need this*/
bool exists_player( char *name )
{
struct stat fst;
char buf[256];
/*
* Stands to reason that if there ain't a name to look at, they damn well don't exist!
*/
if( !name || !str_cmp( name, "" ) )
return FALSE;
snprintf( buf, 256, "%s%c/%s", PLAYER_DIR, tolower( name[0] ), capitalize( name ) );
if( stat( buf, &fst ) != -1 )
return TRUE;
return FALSE;
}