SA-MP Forums Archive
Problems with udb_RenameUser - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problems with udb_RenameUser (/showthread.php?tid=166632)



Problems with udb_RenameUser - Mystique - 09.08.2010

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);



Re: Problems with udb_RenameUser - MadeMan - 09.08.2010

Show the whole command.


Re: Problems with udb_RenameUser - Mystique - 09.08.2010

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;
    }



Re: Problems with udb_RenameUser - Mystique - 10.08.2010

Bumping.


Re: Problems with udb_RenameUser - Mystique - 11.08.2010

Bumping, anyone who can help me, please?


Re: Problems with udb_RenameUser - selten98 - 11.08.2010

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


Re: Problems with udb_RenameUser - JaTochNietDan - 11.08.2010

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.


Re: Problems with udb_RenameUser - Mystique - 12.08.2010

Here it is.

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



Re: Problems with udb_RenameUser - woot - 12.08.2010

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);



Re: Problems with udb_RenameUser - Mystique - 13.08.2010

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?