Rename a file is not working - 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)
+--- Thread: Rename a file is not working (
/showthread.php?tid=614721)
Rename a file is not working - antoinefr - 11.08.2016
Hello, im trying to rename userfiles but it is not renaming anything. I use the "frename" function from YSF plugin. I certainly do not use it directly:
PHP код:
frename(UserPath(playerid),GetOfflineUserPath(newname));
At final, UserPath become: /users/name.ini and Getofflineuserpath : /users/newname.ini
Thanks to help me!
Re: Rename a file is not working -
Kaliber - 11.08.2016
Here try this:
PHP код:
stock frename2(const path[], const newPath[])
{
if(!fexist(path)||fexist(newPath)) return 0;
new File:f = fopen(path,io_read),buffer[512];
fread(f,buffer,sizeof(buffer));
fclose(f);
fremove(path);
f = fopen(newPath,io_write);
fwrite(f,buffer);
fclose(f);
return 1;
}