19.05.2015, 17:06
Hello!
I have a /changename command to change player name and rename player file!
But file doesn't change [%s.ini(name)]
I have a /changename command to change player name and rename player file!
But file doesn't change [%s.ini(name)]
Код:
if(dialogid == CHANGE_NAME) { if (response) { if(strlen(inputtext) < 4) return ShowPlayerDialog(playerid, CHANGE_NAME, DIALOG_STYLE_INPUT, "{AA3333}New Name", "Input your new name below\nName must be at least 4 lethers long!:", "Change", "Cancel"); if (dini_Exists(inputtext)) return SendClientMessage(playerid,COLOR_RED,"This User Name Is Taken!"); new name1[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME]; format(name1, sizeof(name1), PLAYERS, PlayerName(playerid)); format(name2, sizeof(name2), PLAYERS, inputtext); SetPlayerName(playerid,inputtext); frename(name1, name2); } }
Код:
stock frename(const oldname[], const newname[]) { if (!fexist(oldname)) return 0; new File: oldfile = fopen(oldname, io_read), File: newfile = fopen(newname, io_write), line[128]; if (!oldfile || !newfile) return 0; while (fread(oldfile, line)) fwrite(newfile, line); fclose(oldfile); fclose(newfile); fremove(oldname); return 1; }