I apologize for my lack of detail. An older version of this function is posted earlier in this subject, where my attempts to loadup the person to do the level check in the same manner as I did in do_whois are shown. Here is the most recent version of this function:
void do_destroy( CHAR_DATA *ch, char *argument )
{
CHAR_DATA *victim;
char buf[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH];
char arg[MAX_INPUT_LENGTH];
char *name;
set_char_color( AT_RED, ch );
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
send_to_char( "Destroy what player file?\n\r", ch );
return;
}
for ( victim = first_char; victim; victim = victim->next )
if ( !IS_NPC(victim) && !str_cmp(victim->name, arg) )
break;
if ( !victim )
{
DESCRIPTOR_DATA *d;
/* Make sure they aren't halfway logged in. */
for ( d = first_descriptor; d; d = d->next )
if ( (victim = d->character) && !IS_NPC(victim) &&
!str_cmp(victim->name, arg) )
break;
if ( d )
close_socket( d, TRUE );
}
else
{
int x, y;
if ( victim->level >= 1000 ) /* This ifcheck only seems to work if the player is online */
{
sprintf( buf, "<FYI> %s has attempted to **ILLEGALLY** destroy an admin!!", ch->name );
echo_to_all( AT_IMMORT, buf, ECHOTAR_ALL );
send_to_char( "You cannot destroy admins. Such action requires direct server file access.\nThis attept has been logged.\n\n", ch );
return;
}
quitting_char = victim;
save_char_obj( victim );
saving_char = NULL;
extract_char( victim, TRUE );
for ( x = 0; x < MAX_WEAR; x++ )
for ( y = 0; y < MAX_LAYERS; y++ )
save_equipment[x][y] = NULL;
}
name = capitalize( arg );
if (strcmp (name, "Kris") == 0 ||
strcmp (name, "Mccavity") == 0 ||
strcmp (name, "Yoshi") == 0 ||
strcmp (name, "Penwhale") == 0 ||
strcmp (name, "Xcan") == 0 ||
strcmp (name, "Malfalas") == 0 ||
strcmp (name, "Argos") == 0 ||
strcmp (name, "Cosmo") == 0 ||
strcmp (name, "Alquerian") == 0 ||
strcmp (name, "Lordrom") == 0 ||
strcmp (name, "Admin") == 0)
{
sprintf( buf, "<FYI> %s has attempted to **ILLEGALLY** destroy an admin!!", ch->name );
echo_to_all( AT_IMMORT, buf, ECHOTAR_ALL );
ch_printf( ch, "You cannot destroy %s. Such action requires direct server file access.\nThis attept has been logged.\n\n", name );
return;
}
sprintf( buf, "%s%c/%s", PLAYER_DIR, tolower(arg[0]), name );
ch_printf( ch, "Destroying %s%c/%s.... \n", PLAYER_DIR, tolower(arg[0]), name );
sprintf( buf2, "%s%c/%s", BACKUP_DIR, tolower(arg[0]), name );
if ( !rename( buf, buf2 ) )
{
AREA_DATA *pArea;
sprintf( buf, "<FYI> %s has been destroyed by an immortal!", name );
echo_to_all( AT_IMMORT, buf, ECHOTAR_ALL );
set_char_color( AT_RED, ch );
ch_printf(ch, "Player %s destroyed. Pfile saved in backup directory.\n\r",
name );
sprintf( buf, "%s%s", GOD_DIR, name );
if ( !remove( buf ) )
send_to_char( "Player's immortal data destroyed.\n\r", ch );
else if ( errno != ENOENT )
{
ch_printf( ch, "Unknown error #%d - %s (immortal data). Report to Kris.\n\r",
errno, strerror( errno ) );
sprintf( buf2, "%s destroying %s", ch->name, buf );
perror( buf2 );
}
sprintf( buf2, "%s.are", name );
for ( pArea = first_build; pArea; pArea = pArea->next )
if ( !str_cmp( pArea->filename, buf2 ) )
{
sprintf( buf, "%s%s", BUILD_DIR, buf2 );
if ( IS_SET( pArea->status, AREA_LOADED ) )
fold_area( pArea, buf, FALSE );
close_area( pArea );
sprintf( buf2, "%s.bak", buf );
set_char_color( AT_RED, ch ); /* Log message changes colors */
if ( !rename( buf, buf2 ) )
send_to_char( "Player's area data destroyed. Area saved as backup.\n\r", ch );
else if ( errno != ENOENT )
{
ch_printf( ch, "Unknown error #%d - %s (area data). Report to Kris.\n\r",
errno, strerror( errno ) );
sprintf( buf2, "%s destroying %s", ch->name, buf );
perror( buf2 );
}
break;
}
}
else if ( errno == ENOENT )
{
set_char_color( AT_PLAIN, ch );
send_to_char( "Player does not exist.\n\r", ch );
}
else
{
set_char_color( AT_WHITE, ch );
ch_printf( ch, "Unknown error #%d - %s. Report to Kris.\n\r",
errno, strerror( errno ) );
sprintf( buf, "%s destroying %s", ch->name, arg );
perror( buf );
}
return;
}
I can't get the level check to work for someone who is offline. The earlier version of the function shown has my attempts in it.
|