16.10.2014, 15:32
When I change name, old name can't be deleted.
What's wrong with this code?
What's wrong with this code?
Код:
CMD:rename(playerid,params[]) { if(pInfo[playerid][pLogged] == 1) { if(pInfo[playerid][pAdminLevel] >= 2) { new oldname[128], newname[128], string[90], targetid; if(sscanf(params,"s[128]s[128]", oldname, newname)) return SendClientMessage(playerid,COLOR_YELLOW, "Correct Usage: /rename [OldName][New name]"); new filestring[128]; new filestring2[128]; new filestring3[128]; format(filestring2, sizeof(filestring2), "/ZMA/Users/%s.ini", oldname); if(!fexist(filestring2)) return SendClientMessage(playerid, COLOR_YELLOW, "That account name doesn't exist!"); format(filestring, sizeof(filestring), "/ZMA/Users/%s.ini", newname); if(fexist(filestring)) return SendClientMessage(playerid, COLOR_YELLOW, "The new name you've chosen is already taken"); frename(filestring2, filestring); format(filestring3, sizeof(filestring3), "/ZMA/Users/%s.ini", oldname); new INI:File = INI_Open(filestring); INI_SetTag(File, "data"); INI_WriteString(File,"OldName", oldname); INI_Close(File); if(!fremove(filestring3))fremove(filestring3); new renamedstring[128], cstring[128]; format(string, sizeof(string), "You have successfully renamed %s's account to %s" ,oldname, newname); format(renamedstring, sizeof(renamedstring), "%s has renamed %s's account to %s" ,GetAdminName(playerid) ,oldname, newname); format(cstring, sizeof(cstring), "Your name was changed from %s to %s" ,oldname, newname); SendClientMessage(playerid, COLOR_BLUE, string); SendClientMessage(targetid, COLOR_BLUE, cstring); SendClientMessageToAll(-1,renamedstring); printf("%s %s has renamed %s's account to %s" ,GetAdminName(playerid),PlayerName(playerid) ,oldname, newname); pInfo[targetid][pRenamed] = 1; } } else if(pInfo[playerid][pLogged] == 0) { SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" Nice try u fucking fag gay!"); printf("%s has been kicked for trying to use a command without being logged in!", PlayerName(playerid)); Kick(playerid); } return 1; }