Problems with udb_RenameUser
#1

Allright, so I'm experiencing some problems with the /changename command. This is the place where it's supposed to change the user files name to the new name and change to the new name in game. All it does is restarting my server when executing this command.

Код:
udb_RenameUser(pName(playerid),tmp);
SetPlayerName(id, tmp);
Reply
#2

Show the whole command.
Reply
#3

pawn Код:
if(strcmp(cmd, "/changename", true) ==0)
    {
      if(PlayerInfo[playerid][LoggedIn] == 1)
      {
        if(PlayerInfo[playerid][Level] >= 1)
        {
          tmp = strtok(cmdtext, idx);
          if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "Usage: /changename [playerid] [New name]");
          new id = strval(tmp);
          tmp = strtok(cmdtext, idx);
          if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "Usage: /changename [playerid] [New name]");
         
         
          if(IsPlayerConnected(id))
          {
            if(PlayerInfo[id][LoggedIn] == 1)
            {
              if(strlen(tmp) < 3 || strlen(tmp) > 24) return SendClientMessage(playerid, COLOR_RED, "Your name cannot be shorter than 3 chracters or longer than 24 characters.");
              if(udb_Exists(tmp))
              {
              SendClientMessage(playerid, COLOR_GREY, "That name does allready exist.");
              }
              else
              {
              udb_RenameUser(pName(playerid),tmp);
              SetPlayerName(id, tmp);
              }
            }
            else{SendClientMessage(playerid, COLOR_RED, "The selected player is not logged in.");}
          }
          else{SendClientMessage(playerid, COLOR_RED, "The selected player is not connected");}
        }
        else{SendClientMessage(playerid, COLOR_RED, "You are not authorized to use this command.");}
      }
      else{SendClientMessage(playerid, COLOR_RED, "You are not logged in.");}
      return 1;
    }
Reply
#4

Bumping.
Reply
#5

Bumping, anyone who can help me, please?
Reply
#6

my question what is the problem with changing it yourself in the files?
Reply
#7

Try adding a printf before udb_RenameUser so you can make sure all of the strings contain the correct information for that function.

pawn Код:
printf("pName Contains: %s || tmp contains: %s",pName(playerid),tmp);
Add that just before udb_RenameUser, so I can see what those strings contain.
Reply
#8

Here it is.

pawn Код:
pName Contains: Richard_Wright || tmp contains: John_Greenwood
Reply
#9

I had the same issue long time ago and did this;

pawn Код:
new oldFile[ MAX_PLAYER_NAME +9 ], newFile[ MAX_PLAYER_NAME +9 ];
format(oldFile, sizeof(oldFile), "%s.dudb.sav", udb_encode(pName(id)));
format(newFile, sizeof(newFile), "%s.dudb.sav", udb_encode(tmp));
frename(oldFile, newFile);
SetPlayerName(id, tmp);
Reply
#10

Quote:
Originally Posted by exora
Посмотреть сообщение
I had the same issue long time ago and did this;

pawn Код:
new oldFile[ MAX_PLAYER_NAME +9 ], newFile[ MAX_PLAYER_NAME +9 ];
format(oldFile, sizeof(oldFile), "%s.dudb.sav", udb_encode(pName(id)));
format(newFile, sizeof(newFile), "%s.dudb.sav", udb_encode(tmp));
frename(oldFile, newFile);
SetPlayerName(id, tmp);
Well, it works yes but the problem is that the old userfile isn't deleted. I would rather prefer having the RenameUser to work so does anyone have any solutions?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)