Try to do some simple debugging.
pawn Код:
CMD:rename(playerid, params[])
{
if(PVar[playerid][pLevel] >= 4)
{
new Player, newname[32], string[128], File[85];
if(!sscanf(params, "us[32]", Player, newname))
{
format(File, sizeof(File), PFiles, newname);
if(!fexist(File))
{
format(File, sizeof(File), PFiles, pName(playerid));
PVar[playerid][pKills] = djInt (File, "Kills");
PVar[playerid][pDeaths] = djInt (File, "Deaths");
PVar[playerid][pLevel] = djInt (File, "Level");
PVar[playerid][pMuted] = djInt (File, "Muted");
PVar[playerid][pCash] = djInt (File, "Cash");
PVar[playerid][pSkin] = djInt (File, "Skin");
PVar[playerid][pUseSkin] = djInt (File, "UseSkin");
format(PVar[playerid][pMutedReason], 52, "%s", dj(File, "MutedReason"));
format(string, sizeof(string), "%s.json", newname);
djCreateFile(string);
format(File, sizeof(File), PFiles, newname);
printf("File: %s", File);
djSetInt (File, "Kills", PVar[playerid][pKills]);
djSetInt (File, "Deaths", PVar[playerid][pDeaths]);
djSetInt (File, "Level", PVar[playerid][pLevel]);
djSetInt (File, "Cash", PVar[playerid][pCash]);
djSetInt (File, "Muted", PVar[playerid][pMuted]);
djSetInt (File, "Skin", PVar[playerid][pSkin]);
djSetInt (File, "UseSkin", PVar[playerid][pUseSkin]);
djSet (File, "MutedReason", PVar[playerid][pMutedReason]);
format(string, sizeof(string), "%s.json", pName(playerid));
djRemoveFile(string);
SetPlayerName(playerid, newname);
}
else return SendClientMessage(playerid, COLOR_RED, "File already exists!");
}
else return SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /rename < Player ID > < New Name >");
}
else return AdminCMD(playerid, 4);
return 1;
}
Also do you happen to be using dutils? There is a file re-name function in there that would make all of this a lot easier, it would all boil down to one function in fact.