06.02.2010, 14:01
Well i'm trying to make a " rename " command for my GM but as far i know there is no "rename " function so i need to delete a file and create another one.
When i tried to code it pawno give me no errors but when i tried to make it as wiki says in this page:
https://sampwiki.blast.hk/wiki/Fremove
it gave me error for " mismatch " ...
then i tried my own and pawno did not gave any problems... but when i tried to use it IG it don't delete the file.... but i can remove it manually....
here is the code where the file soppose to be deleted:
This is the complete Command.
When i tried to code it pawno give me no errors but when i tried to make it as wiki says in this page:
https://sampwiki.blast.hk/wiki/Fremove
it gave me error for " mismatch " ...
then i tried my own and pawno did not gave any problems... but when i tried to use it IG it don't delete the file.... but i can remove it manually....
here is the code where the file soppose to be deleted:
Код:
new fnameold[33]; format(fnameold,sizeof(fnameold),P_FILE,udb_encode(PlayerInfo[giveplayerid][name])); fremove(fnameold);
Код:
if(strcmp(cmd, "/setname", true) == 0) { new fname[256]; if(PlayerInfo[playerid][admin] == 0) { SendClientMessage(playerid,COLOR_BRIGHTRED,"SAC: You are not an admin to use this command!"); return 1; } tmp = strtok(cmdtext, idx); if(!IsPlayerConnected(strval(tmp))) { SendClientMessage(playerid,COLOR_BRIGHTRED,"This Player Is not Connected!"); return 1; } if(!strlen(tmp)) { SendClientMessage(playerid,COLOR_LIGHTBLUE,"USAGE: /setname [playerid] [New PlayerName]"); return 1; } giveplayerid = strval(tmp); tmp = strtok(cmdtext, idx, strlen(cmdtext)); if(!strlen(tmp)) { SendClientMessage(playerid,COLOR_LIGHTBLUE,"USAGE: /setname [playerid] [New PlayerName]"); return 1; } format(fname,sizeof(fname),P_FILE,udb_encode(tmp)); if(fexist(fname)) { SendClientMessage(playerid,COLOR_BRIGHTRED,"This Account already Exist!"); return 1; } new File: file,filestring[256]; SetPlayerName(giveplayerid,tmp); GetPlayerName(giveplayerid, playername, sizeof(playername)); format(fname,sizeof(fname),P_FILE,udb_encode(playername)); file = fopen(fname, io_write); if(file) { format(filestring,sizeof(filestring),"%s,0,%d,0,0,500,0,0,0,0,0,0,0,0,0,0",playername,PlayerInfo[playerid][pass]); fwrite(file,filestring); fclose(file); } new fnameold[33]; format(fnameold,sizeof(fnameold),P_FILE,udb_encode(PlayerInfo[giveplayerid][name])); fremove(fnameold); format(string,sizeof(string),"SAC: You had changed the name of Player %s to %s",PlayerInfo[giveplayerid][name],tmp); SendClientMessage(playerid,COLOR_BRIGHTRED,string); format(string,sizeof(string),"SAC: Your name had been changed by admin: %s to %s",PlayerInfo[playerid][name],tmp); SendClientMessage(giveplayerid,COLOR_BRIGHTRED,string); GetPlayerName(giveplayerid, playername, sizeof(playername)); PlayerInfo[giveplayerid][name] = playername; SavePlayer(giveplayerid); }