Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ Running the server ➜ Problems With Destroy Command

Problems With Destroy Command

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2 

Posted by Kris   USA  (198 posts)  Bio
Date Reply #15 on Mon 25 Jun 2001 10:44 PM (UTC)
Message
I've implemented the name check, and it works =)
However, I'm still having trouble with the basic ifcheck to see if a person is above level 1000 (the name check is just to ensure that, regardless of level, certain
people can't be dested). It works just fine if the player is online, but when I tried to use the same premise that worked with do_whois (i.e. do_loadup2, etc), I've
been having the runtime errors. Do you have any insight as to how I may resolve that problem as well? Thank you for all you help :)
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #16 on Tue 26 Jun 2001 03:02 AM (UTC)
Message
It really is impossible to debug your source code changes when I can't see what the source code is.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Kris   USA  (198 posts)  Bio
Date Reply #17 on Tue 26 Jun 2001 11:11 PM (UTC)

Amended on Wed 27 Jun 2001 08:42 AM (UTC) by Nick Gammon

Message
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.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #18 on Wed 27 Jun 2001 08:55 AM (UTC)
Message
Hard to say. I'm not going to spend hours debugging your code here. I suggest some debugging displays, eg printf so you can see if "victim" is NULL or not.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


51,980 views.

This is page 2, subject is 2 pages long:  [Previous page]  1  2 

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.