CMD:setname (playerid, params[])
{
new id, name[25],str[120];
if(PInfo[playerid][Admin] < 7) return SendClientMessage(playerid, RED,"[ERROR]: {FFFFFF}You do not have the privilleges to perform this command.");
if(sscanf(params, "us[25]", id, name)) return SendClientMessage(playerid, TOMATO, "[USAGE]: {FFFFFF}/setname [playerid/PartOfName] [name]");
if(strlen(name) < 3)return SendClientMessage(playerid, COLOR_RED, "[ERROR]: {FFFFFF}The length of the name shouldn't be lower than 3!");
if(strlen(name) > MAX_PLAYER_NAME)return SendClientMessage(playerid, COLOR_RED, "[ERROR]: {FFFFFF}The length of name exceeds the limit!");
new file[64];
format(file, sizeof(file), "/Users/%s.ini", name);
if (fexist(file)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: {FFFFFF}That name is already registered in the database!");
fremove(UserPath(id));
SetPlayerName(id,name);
SaveStats(id);
return 1;
}
Because you're doing it wrong. You will need to recreate the player file after you delete it (just like you do in the registration) and then save their stats! That's why we recommend SQL as the saving system, you don't need to struggle with any kind of bullshit, straight forward and easy.
|
if you would have taken a better look on his code, you would've noticed that he is doing that:
SaveStats(id); Also be sure that SaveSats saves the stats for ID and not playerid |
stock frename(oldname[],newname[]) {
if (!fexist(oldname)) return false;
fremove(newname);
if (!fcopy(oldname,newname)) return false;
fremove(oldname);
return true;
}