I have since gotten the do_whois code to work for both online and offline players, thanks to your help :)
Now, I've been trying for several days to implement the same premise into do_destroy. Alas, no matter how many different approaches I take, my knowledge of C (and this source) is still very limited, and I'm at a loss. I apologize for the following lengthyness, but I feel it's necessary to post the relevant first 2/3 of the function code, so that you may be able to tell me what's wrong. In it also is the specific name-checks I attempted (unsuccessfully) to implement. I have documented key parts of the code with comment tags for your convenience. Here it is:
void do_destroy( CHAR_DATA *ch, char *argument )
{
CHAR_DATA *victim;
char buf[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH];
/* My unsuccessful attempt to put in a specific name-check */
char admin1[MAX_STRING_LENGTH];
char admin2[MAX_STRING_LENGTH];
char admin3[MAX_STRING_LENGTH];
char admin4[MAX_STRING_LENGTH];
char admin5[MAX_STRING_LENGTH];
char admin6[MAX_STRING_LENGTH];
char admin7[MAX_STRING_LENGTH];
char admin8[MAX_STRING_LENGTH];
char admin9[MAX_STRING_LENGTH];
char admin10[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 = get_char_world(ch, argument) ) == NULL )) /* Same thing I used successfully in
do_whois, but I haven't even come close to success using it in this function */
{
do_loadup2( ch, argument );
if( ( ( victim = get_char_world(ch, argument) ) == NULL ))
return;
do_goto2 (victim, "1"); /* To protect the link-dead player from being tampered with --Kris */
}
if ( victim->level >= 1000 ) /* This ifcheck only seems to work if the player is online */
{
send_to_char( "You cannot destroy admins. Such action requires direct server file access.\nThis attept has been logged.\n\n", ch );
if ( !victim->desc ) /* Just in case the player was loaded-up */
do_quit2( victim, "" );
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 );
/* Again, more lousy attempts on my part for a specific name-check (I feel like a lost cause) */
sprintf( admin1, "Kris" );
sprintf( admin2, "Mccavity" );
sprintf( admin3, "Yoshi" );
sprintf( admin4, "Penwhale" );
sprintf( admin5, "Xcan" );
sprintf( admin6, "Malfalas" );
sprintf( admin7, "Argos" );
sprintf( admin8, "Cosmo" );
sprintf( admin9, "Lordrom" );
sprintf( admin10, "Admin" );
if ( name == admin1 )
{
send_to_char( "You cannot destroy admins. Such action requires direct server file access.\nThis attept has been logged.\n\n", ch );
return;
}
if ( name == admin2 )
{
send_to_char( "You cannot destroy admins. Such action requires direct server file access.\nThis attept has been logged.\n\n", ch );
return;
}
if ( name == admin3 )
{
send_to_char( "You cannot destroy admins. Such action requires direct server file access.\nThis attept has been logged.\n\n", ch );
return;
}
if ( name == admin4 )
{
send_to_char( "You cannot destroy admins. Such action requires direct server file access.\nThis attept has been logged.\n\n", ch );
return;
}
if ( name == admin5 )
{
send_to_char( "You cannot destroy admins. Such action requires direct server file access.\nThis attept has been logged.\n\n", ch );
return;
}
if ( name == admin6 )
{
send_to_char( "You cannot destroy admins. Such action requires direct server file access.\nThis attept has been logged.\n\n", ch );
return;
}
if ( name == admin7 )
{
send_to_char( "You cannot destroy admins. Such action requires direct server file access.\nThis attept has been logged.\n\n", ch );
return;
}
if ( name == admin8 )
{
send_to_char( "You cannot destroy admins. Such action requires direct server file access.\nThis attept has been logged.\n\n", ch );
return;
}
if ( name == admin9 )
{
send_to_char( "You cannot destroy admins. Such action requires direct server file access.\nThis attept has been logged.\n\n", ch );
return;
}
if ( name == admin10 )
{
send_to_char( "You cannot destroy admins. Such action requires direct server file access.\nThis attept has been logged.\n\n", ch );
return;
}
/* And the rest is as-is from here.... */
So, you can see how much of a mess this is I'm sure. I know the problem I present is very detailed, yet my question is vague. Still, ummm.... how do I get this to work? :P Thank you for your time and help =)
*sigh* |