16.04.2015, 03:08
Hello i'm using Y_INI ,i've tried multipe times to change the account name but it doesn't replace the new name to the old one, is there a problem with the code?
Код:
CMD:setname(playerid, params[]) { new giveplayerid, newname[24], string[128], sendername[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME]; if(PlayerInfo[playerid][pAdmin] >= 3) { if(!sscanf(params, "us[24]", giveplayerid, newname)) { if(IsPlayerConnected(giveplayerid)) { if(giveplayerid != INVALID_PLAYER_ID) { new string6[50]; format(string6, sizeof(string6), "Accounts/%s.ini", newname); format(string, sizeof(string), "Accounts/%s.ini", newname); if(fexist(string)) { SendClientMessage(playerid, COLOR_GRAD1, "That name is already registered."); return 1; } strmid(sendername, PlayerName(playerid), 0, MAX_PLAYER_NAME); strmid(giveplayer, PlayerName(giveplayerid), 0, MAX_PLAYER_NAME); SetPlayerName(giveplayerid, newname); format(string, sizeof(string), "Accounts/%s.ini", giveplayer); SaveAccounts(); if(INI_Exist(string6)) { fremove(string); } else { SendClientMessage(playerid, COLOR_NICERED, "There was a problem with saving the account! Reverting changes..."); SetPlayerName(giveplayerid, giveplayer); if(INI_Exist(string6)) // For some odd reason it exists? { fremove(string6); SaveAccounts(); } } format(string, sizeof(string), " You have renamed %s to %s !", giveplayer, newname); SendInfoMessage(playerid,2,"0", string); format(string, sizeof(string), "Your name has been changed from %s to %s.", giveplayer, newname); SendInfoMessage(giveplayerid,2,"0", string); } } } else { SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setname [playerid/PartOfName] [name]"); } } else { SendClientMessage(playerid, COLOR_GRAD1, " {FF0000}ERROR{FFFFFF}: you do not have sufficient permissions!"); } return 1; }