28.01.2015, 10:16
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
+rep if you Help me
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;
}