Renaming a file? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Renaming a file? (
/showthread.php?tid=89588)
Renaming a file? -
-eXo - 02.08.2009
Is it possible to rename a file in scriptfiles? Like typing /name whatever_whatever and the file name changes.
Re: Renaming a file? -
Jefff - 02.08.2009
But U want all what is inside file or brand new
Re: Renaming a file? -
-eXo - 02.08.2009
Quote:
Originally Posted by Jefff
But U want all what is inside file or brand new
|
All of what was already inside in the file
Re: Renaming a file? -
Jefff - 02.08.2009
Код:
stock frename(oldname[],newname[]) { // by Jefff
if(!fexist(oldname)) return false;
new string[255], File:old, File:neww;
old = fopen(oldname, io_read);
neww = fopen(newname, io_write);
while(fread(old, string)){
StripNewLine(string);
format(string,sizeof(string),"%s\r\n",string);
fwrite(neww, string);
}
fclose(old);
fclose(neww);
fremove(oldname);
return true;
}
:>
Re: Renaming a file? -
(.Aztec); - 03.08.2009
Along with that stock use this:
pawn Код:
if(strcmp(cmd,"/changename",true)==0)
{
tmp = strtok(cmdtext, idx);
if(strlen(tmp)==0) return SendClientMessage(playerid, COLOR_LB, "Syntax: /ChangeName <Player ID/Part of Name> <New Name>");
player = ReturnUser(tmp);
if(player != INVALID_PLAYER_ID)
{
if(PlayerInfo[playerid][pAdmin] >= 1337)
{
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[80];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
GetPlayerName(player, sendername, sizeof(sendername));
format(string, sizeof(string), "%s.ini", sendername);
frename(sendername,(result));
SetPlayerName(player,(result));
OnPlayerUpdate(player);
fremove(string);
format(string, sizeof(string), "Your name has been changed from %s to %s.", sendername, (result));
SendClientMessage(player, COLOR_YELLOW, string);
}
else return SendClientMessage(playerid, COLOR_RED, "(Error): You are not an administrator. (Error Code: 45)");
}
else return SendClientMessage(playerid, COLOR_RED, "(Error): Player does not exist.");
return 1;
}
Re: Renaming a file? -
Criss_Angel - 05.09.2009
I used both of those and put them to together and got these erros
C:\DOCUME~1\k\Desktop\Server\GAMEMO~1\ERP.pwn(2542 0) : error 017: undefined symbol "COLOR_LB"
C:\DOCUME~1\k\Desktop\Server\GAMEMO~1\ERP.pwn(2542 1) : error 017: undefined symbol "player"
C:\DOCUME~1\k\Desktop\Server\GAMEMO~1\ERP.pwn(2542 2) : error 017: undefined symbol "player"
C:\DOCUME~1\k\Desktop\Server\GAMEMO~1\ERP.pwn(2543 9) : error 017: undefined symbol "player"
C:\DOCUME~1\k\Desktop\Server\GAMEMO~1\ERP.pwn(2544 2) : error 017: undefined symbol "player"
C:\DOCUME~1\k\Desktop\Server\GAMEMO~1\ERP.pwn(2544 3) : error 017: undefined symbol "OnPlayerUpdate"
C:\DOCUME~1\k\Desktop\Server\GAMEMO~1\ERP.pwn(2544 6) : error 017: undefined symbol "player"
C:\DOCUME~1\k\Desktop\Server\GAMEMO~1\ERP.pwn(3690 7) : error 017: undefined symbol "StripNewLine"
Re: Renaming a file? -
Criss_Angel - 05.09.2009
Please Help