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 Sat 12 May 2001 10:28 PM (UTC)
Message
The destroy command doesn't work. Everytime we attempt to use it, it says 'Player does not exist.' and disconnects the player we're trying to delete. However, it doesn't delete the pfile, nor does it save it to the backup directory. I checked the source code, and the mud.h file, and the path is correct. What do I need to change in the source code to get this built-in command to work as it's supposed to?
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 13 May 2001 04:10 AM (UTC)

Amended on Sun 13 May 2001 04:11 AM (UTC) by Nick Gammon

Message
Do you have a backup directory? In my case there isn't one (probably because it was initially empty and WinZip does not create empty directories). Try creating a directory called "backup" at the same level as the "player" directory.

However if you are using Cygwin, I found that the version of the source I had wanted the backup directory inside the player directory.

Also, make sure that you create subdirectories for each letter of the alphabet.

This file shows the location of the backup directory:


mud.h:#define BACKUP_DIR "../player/backup/"



eg.


$ ls player
a backup d f h j l n p r t v x z
b c e g i k m o q s u w y

$ ls player/backup
a b c d e f g h i j k l m n o p
q r s t u v w x y z


Once you have the directory set up, you should be able to do a destroy, like this:


destroy nick
Log: Lordrom: destroy nick
Player Nick destroyed. Pfile saved in backup directory.



- Nick Gammon

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

Posted by Kris   USA  (198 posts)  Bio
Date Reply #2 on Sat 02 Jun 2001 12:32 AM (UTC)
Message
I'm trying to change the 'destroy' command so it can't be used on admins. Such deletions should be kept to the person who has direct server access, namely myself. I managed to put in a level ifcheck to check to see if the victim's level was >= 1000, and it worked. However, it only works if that person is online. How do I make it so it'll check when the person is offline or online? Also, how do I perform name-checking? I tried to just save the trouble and have it check for specific names, but I couldn't get that to work either. Nor could I figure out a way to check the victim's level if not online. How would I accomplish either one of these things?
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #3 on Sun 03 Jun 2001 10:29 PM (UTC)
Message
For checking the level of players that are not connected, see what the "loadup" command does. That loads a character so an admin can work on it even if they are not playing. I would do something like that, and check their level.

- Nick Gammon

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

Posted by Kris   USA  (198 posts)  Bio
Date Reply #4 on Fri 08 Jun 2001 12:30 AM (UTC)
Message
I tried what you suggested, but I think I need more information. As a test, and hopefully as a solution to another problem we've been having, I tried using your loadup idea to make it so that 'whois' will work on a player even if they're not online. I tried everything from copying the do_loadup code into do_whois to simply putting a do_loadup call, both of which within an ifcheck to see if the player is online or not. However, I haven't even come close to successful. The thing is, I'd rather not have the Comm logs spammed up every time someone does a whois on an offline player, so I prefer to copy the loadup code directly into the function, but only what I need. If that would work, what would I have to do in order to accomplish this? Otherwise, how would I successfully implement a do_loadup function call within the do_whois function? If this eventually works, I'll use the same premise with do_destroy.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #5 on Fri 08 Jun 2001 04:29 AM (UTC)
Message
It is very hard to answer this sort of question.

You haven't said:

* What you tried (eg. code snippet)

or

* What went wrong. (Wouldn't compile? Crashed? Didn't crash but didn't work?)

I don't really have time to sit down and write code for everyone. I don't mind giving hints about where to look, but after that you are on your own a bit, sorry.

- Nick Gammon

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

Posted by Kris   USA  (198 posts)  Bio
Date Reply #6 on Sat 09 Jun 2001 08:12 PM (UTC)
Message
Ok, how would I make a one-line function call into do_loadup from do_whois? Would I simply put:
do_loadup
or would I need to pass some argument, like do_loadup (victim) or something like that? That's what I can't seem to figure out, and I can't find anywhere in the source where it makes a specific call to do_loadup, so I don't have an example to work from.
Top

Posted by Kris   USA  (198 posts)  Bio
Date Reply #7 on Mon 11 Jun 2001 08:00 PM (UTC)
Message
Would anybody know?
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #8 on Mon 11 Jun 2001 10:48 PM (UTC)
Message
Well, do_loadup has two arguments, a pointer to your player data, and an argument list. It expects one argument in that list, so something like this should work:


do_loadup(ch, "gandalf");

- Nick Gammon

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

Posted by Kris   USA  (198 posts)  Bio
Date Reply #9 on Tue 12 Jun 2001 12:48 AM (UTC)
Message
In do_whois, victim stands for the person you're inquiring whois info on. Therefore, based on your last post, I attempted the following:

do_loadup2( ch, victim );

(I duplicated do_loadup, but got rid of echos and logs and stuff, so it won't spam up the mud whenever someone uses the whois command on an offline player).

However, in do_loadup2, it fails the ifcheck that determines if there's an argument given or not. Therefore, I'm assuming that I'm passing the victim's name over the wrong way. I tried changing it to:

do_loadup2( ch, victim->name );

But that just crashed the mud. How do I pass it through as whatever the person types in whois?
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #10 on Tue 12 Jun 2001 03:04 AM (UTC)

Amended on Tue 12 Jun 2001 03:05 AM (UTC) by Nick Gammon

Message
I'm having to guess what you are doing because you are not providing any code, which makes debugging almost impossible, but I would guess that you are passing a NULL pointer as "victim", which would indeed crash the MUD.

The relevant code in do_whois is:


void do_whois( CHAR_DATA *ch, char *argument)
{
  CHAR_DATA *victim;
  char buf[MAX_STRING_LENGTH];
  char buf2[MAX_STRING_LENGTH];

  buf[0] = '\0';

  if(IS_NPC(ch))
    return;

  if(argument[0] == '\0')
  {
    send_to_pager("You must input the name of an online character.\n\r", ch);
    return;
  }

  strcat(buf, "0.");
  strcat(buf, argument);
  if( ( ( victim = get_char_world(ch, buf) ) == NULL ))
  {
// <--- is your code here ?? 
    send_to_pager("No such character online.\n\r", ch);
    return;
  }



If your call to do_loadup2 is where I marked, which I assume you are doing, otherwise the victim is online, then you are passing a NULL victim pointer to do_loadup, which then cannot dereference it to get the name.

Why not just pass the "argument" to do_whois, which is, after all, the person you are looking for.

eg.


do_loadup2 (ch, argument);




- Nick Gammon

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

Posted by Kris   USA  (198 posts)  Bio
Date Reply #11 on Thu 14 Jun 2001 08:39 PM (UTC)
Message
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*
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #12 on Fri 15 Jun 2001 01:21 AM (UTC)

Amended on Fri 15 Jun 2001 01:22 AM (UTC) by Nick Gammon

Message
Hmmm - if I may suggest this without giving offence - you really would be helped by reading a good book on C. An "Introduction to C" book would cover this sort of material, and would make it much easier for you to progress.

Your problem here is you are comparing pointers, not what the pointers are pointing to.


eg.


sprintf( admin1, "Kris" );
...
if ( name == admin1 )


"admin1" is an area of memory (say with address 0x0012FCD4) and "name" is another area of memory (say with address 0x00E42FFD). Comparing those two is asking:

Is 0x0012FCD4 the same as 0x00E42FFD?

Well, they're not. They are different memory locations, and thus the pointers will have different numbers in them.

What you want is this:


if (strcmp (name, admin1) == 0)
... error message ...


"strcmp" is a "string compare" routine that compares two strings, and returns 0 if they are the same. You pass two pointers to it.

You also don't need your ten fields "admin1" through to "admin10". That is very long-winded. All you need to do is this ( the symbol "||" means "or" ) :


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, "Lordrom") == 0 ||
strcmp (name, "Admin") == 0)
{
send_to_char( "You cannot destroy admins. Such action requires direct server file access.\nThis attept has been logged.\n\n", ch );
return;
}


- Nick Gammon

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

Posted by Kris   USA  (198 posts)  Bio
Date Reply #13 on Fri 15 Jun 2001 01:35 AM (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 Kris   USA  (198 posts)  Bio
Date Reply #14 on Mon 18 Jun 2001 10:08 PM (UTC)
Message
Does anybody have an answer to this and the WAIT_STATE problem I posted a few days ago in the "problems with source code" section?
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,979 views.

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

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.