Changename bugged
#1

Guys i have Problem in Changename Cmd Because When i Start the Command I changename But When i go to scriptfiles to check the old Don't Name Don't Leave and a new file Create With the new name
pawn Код:
stock frename(oldname[], newname[])
{
    if (!fexist(oldname)) return 0;
    new File:oldfile = fopen(oldname, io_read);
    new File:newfile = fopen(newname, io_write);
    new line[256];
    while (fread(oldfile, line))
    {
        fwrite(newfile, line);
    }
    fclose(oldfile);
    fclose(newfile);
    fremove(oldname);
    return 1;
}
pawn Код:
if (dialogid == DIALOG_CHANGENAME)
    {
        if (!response) return 1;
        if (response)
        {
            new path[40], str[150];
            if (isnull(inputtext)) return SendClientMessage(playerid, -1, "ERROR: You have not specified any new name.");
            if (strlen(inputtext) < 3 || strlen(inputtext) > 24) return SendClientMessage(playerid, -1, "ERROR: new nick cannot be smaller than 3 or longer than 24 characters!");
            format(path, sizeof(path), "ZeroAdmin/Accounts/%s.ini", inputtext);
            if (fexist(path)) return SendClientMessage(playerid, -1, "ERROR:The name you have entered is already registered. Please enter a different name to proceed.");
            else
            frename(UserPath(playerid), path);
            SetPlayerName(playerid, inputtext);
            format(str, sizeof(str), "{F5CD1B}You have successfully changed your name to %s. Make sure you change your name on your SA-MP client.", inputtext);
            SendClientMessage(playerid, -1, str);
            return 1;
        }
    }
    return 0;
}
pawn Код:
stock UserPath(playerid)
{
    new str[128], name[MAX_PLAYER_NAME], Path[126];
    GetPlayerName(playerid, name, sizeof(name));
    format(str, sizeof(str), Path, name);
    return str;
}
+rep if you Help me
Reply
#2

it be like this to remove a file with YSI

pawn Код:
new pName[MAX_PLAYER_NAME], str[50];
GetPlayerName(playerid, pName, sizeof pName);
format(str, sizeof str, "%s.ini", pName);
fremove(str);

// this is just an example. If you saved the info into "House" folder, you'd have to format the str in otherway:
format(str, sizeof str, "/Houses/%s.ini", pName);
fremove(str)
Reply
#3

i Don't Understand you
Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
I have said for years that tying user files to names is a terrible idea (in fact, it used to be the case (and potentially still is) that doing so could crash a server, yet people still insist on doing it). If they weren't so directly tied, you wouldn't need to rename the file at all, just change an index somewhere.
Yeah But it's Tiring
Reply
#5

i Don't Know Bro I Need Just Fix that 'cmd:changename'
Reply
#6

bump
Reply
#7

Use YSF

https://sampforum.blast.hk/showthread.php?tid=513499

"native frename(const oldname[], const newname[]);"
Reply
#8

No Bro The Command Work But The olf File Don't Remove and The new file it's Not same Info
this old file
Quote:

Password = D49EB6B9A7D987E2387B414126340048BE446AAB586598513C D0890AAED5E1CF204C04FACBB83175D881A7477B4F7AE7D9D7 763AB96092AA37183F60F7B5C7D6
RegisteredDate = 22/1/2015
Ip = 127.0.0.1
Registered = 1
Banned = 0
Kills = 0
Level = 5
VipLevel = 3
Warnings = 0
LastOn = 29.1.2015
Hours = 2
Minutes = 6
Seconds = 12
Deaths = 7
Score = 200
Cash = 148999
TempVip = 1
FavSkin = 104
UseSkin = 1

And this is The New
Quote:

Banned = 0
Kills = 0
Deaths = 7
Score = 200
Cash = 148999
Hours = 2
Minutes = 6
Seconds = 52
LastOn = 31.1.2015

Reply
#9

Try increasing the buffer string size, how-ever there are simple functions such as frename as seen in YSF. Additionally note, as ****** stated this is an outdated user data saving method.
Reply
#10

I try this But Don't Work For me
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)