Changing a players name
#1

I have a command that is used to set a players name based on YINI saving system :-

PHP код:
CMD:setname (playeridparams[])
            {
                new 
idname[25],str[120];
                if(
PInfo[playerid][Admin] < 7) return SendClientMessage(playeridRED,"[ERROR]: {FFFFFF}You do not have the privilleges to perform this command.");
                if(
sscanf(params"us[25]"idname)) return SendClientMessage(playeridTOMATO"[USAGE]: {FFFFFF}/setname [playerid/PartOfName] [name]");
                if(
strlen(name) < 3)return SendClientMessage(playeridCOLOR_RED"[ERROR]: {FFFFFF}The length of the name shouldn't be lower than 3!");
                if(
strlen(name) > MAX_PLAYER_NAME)return SendClientMessage(playeridCOLOR_RED"[ERROR]: {FFFFFF}The length of name exceeds the limit!");
                new 
file[64];
                
format(filesizeof(file), "/Users/%s.ini"name);
                if (
fexist(file)) return SendClientMessage(playeridCOLOR_RED"[ERROR]: {FFFFFF}That name is already registered in the database!");
                
fremove(UserPath(id));
                
SetPlayerName(id,name);
                
SaveStats(id);
                return 
1;
          } 
It works fine at first, i have tested relogging with it multiple times but when i turn off the server and then re start it, it shows a wrong password error according to my registration and login system. I would love any kind of help i can get about how it should be fixed.
Reply
#2

You are deleting and saving the file again. Try ini_rename
Reply
#3

Because you're doing it wrong. You will need to recreate the player file after you delete it (just like you do in the registration) and then save their stats! That's why we recommend SQL as the saving system, you don't need to struggle with any kind of bullshit, straight forward and easy.
Reply
#4

Quote:
Originally Posted by Logic_
Посмотреть сообщение
Because you're doing it wrong. You will need to recreate the player file after you delete it (just like you do in the registration) and then save their stats! That's why we recommend SQL as the saving system, you don't need to struggle with any kind of bullshit, straight forward and easy.
if you would have taken a better look on his code, you would've noticed that he is doing that:
SaveStats(id);

Also be sure that SaveSats saves the stats for ID and not playerid
Reply
#5

Quote:
Originally Posted by jasperschellekens
Посмотреть сообщение
if you would have taken a better look on his code, you would've noticed that he is doing that:
SaveStats(id);

Also be sure that SaveSats saves the stats for ID and not playerid
Yes, SaveStats is saving the id's stats. I have this stock though:

PHP код:
stock frename(oldname[],newname[]) {
                if (!
fexist(oldname)) return false;
                
fremove(newname);
                if (!
fcopy(oldname,newname)) return false;
                
fremove(oldname);
                return 
true;
            } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)