Re: Rename char function

From: Christopher Avans (parka@CDC.NET)
Date: 10/21/98

On Wed, 21 Oct 1998, George wrote:

> On Wed, 21 Oct 1998, Ronny Iversen wrote:
> >Anybody ever written a function for renaming characters if they have
> >innapropriate names, without having to purge them. Any hints will help ;)
> free(GET_NAME(ch));
> GET_NAME(ch) = str_dup("new name here");
> Then you _must_ scan the player table and replace their name there too or
> they will only be able to log in with the old name until you reboot.
> Trivial really.  I put it under do_set().

I hate to go against the admin heh, but the above code will lead to
problems. Like double naming, they linkdead? If so how they gonan log
back in, etc among other things

Please credit "Hubis Group"

  int player_i;
  extern int top_of_p_table;
  extern struct player_index_element *player_table;
  struct char_file_u tmp_store;
  struct char_data *victim=NULL;
  char tmp_name[MAX_INPUT_LENGTH], arg1[MAX_INPUT_LENGTH],
  extern struct char_data *is_playing(char *vict_name);
  extern save_char_file_u(struct char_file_u st);
  two_arguments(argument, arg1, arg2);

  if(!ch || IS_NPC(ch))

  if(!arg1 || !*arg1 || !arg2 || !*arg2){
    send_to_char("Usage: rename <player name> <new name>\r\n",ch);

  if((victim=is_playing(arg1))) {
    if(GET_LEVEL(ch) <= GET_LEVEL(victim)) {
      send_to_char("You don't have permission to change that name.",ch);
    if ((_parse_name(arg2, tmp_name)) || strlen(tmp_name) < 2 ||
          strlen(tmp_name) > MAX_NAME_LENGTH ||
          fill_word(strcpy(buf, tmp_name)) || reserved_word(buf)) {
        send_to_char("The new name is invalid.\r\n",ch);
    if (!Valid_Name(tmp_name)) {
        send_to_char("The new name is invalid.\r\n",ch);
    if ((player_i = load_char(tmp_name, &tmp_store)) > -1){
        send_to_char("There is already a player with that name.\r\n",ch);
    sprintf(buf2,"&1&bYou have renamed &7%s&1 to &7%s&0\r\n",GET_NAME(victim),CAP(tmp_name));
    send_to_char(buf2, ch);
    sprintf(buf2, "%s has renamed %s to %s",GET_NAME(ch),GET_NAME(victim), tmp_name);
    strcpy((player_table + GET_PFILEPOS(victim))->name,CAP(tmp_name));
    strcpy(victim->, CAP(tmp_name));
    save_char(victim, victim->in_room);
    sprintf(buf2,"&1&b!!! You have been renamed to &7%s&1.&0\r\n",GET_NAME(victim));
    send_to_char(buf2, victim);
  else {
    send_to_char("That players is not playing at the moment.\r\n",ch);
     /* possible rename if offline? this would be bad because player
       would not know how to log in again.*/

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

This archive was generated by hypermail 2b30 : 12/15/00 PST