24.06.2012, 14:49
Hello,
Well i got a cmd /changenick but its not working as i want. When i use /changenick it creates new file instead renaming the existing file
Code:
Anyone got Idea how to fix this?
Well i got a cmd /changenick but its not working as i want. When i use /changenick it creates new file instead renaming the existing file
Code:
pawn Код:
if(strcmp(cmd,"/changenick",true)==0)
{
if(PlayerInfo[playerid][power] >= 10)
{
new tmp[256],nickid;
new oldname[ MAX_PLAYER_NAME +9 ], newname[ MAX_PLAYER_NAME +9 ];
new stringa[MAX_STRING];
tmp = strtok(cmdtext,idx);
if(!strlen(tmp))
{
SendClientUsage(playerid, cmd, "[exaclty name] [new name] (case sensitive)");
return 1;
}
nickid=INVALID_PLAYER_ID;
if(IsPlayerConnected(PlayerID(tmp))) nickid=PlayerID(tmp);
format(oldname, sizeof(oldname), "%s.dudb.sav", udb_encode(tmp));
format(newname, sizeof(newname), "%s.dudb.sav", udb_encode(tmp));
frenametextfile(oldname, newname);
tmp=strtok(cmdtext,idx);
if(!strlen(tmp))
{
SendClientUsage(playerid, cmd, "[exaclty name] [new name] (case sensitive)");
return 1;
}
format(oldname, sizeof(oldname), "%s.dudb.sav", udb_encode(PlayerName(playerid)));
format(newname, sizeof(newname), "%s.dudb.sav", udb_encode(tmp));
frenametextfile(oldname, newname);
SetPlayerName(playerid, tmp);
if(dini_Exists(oldname))
{
if(!dini_Exists(newname))
{
frenametextfile(oldname,newname);
format(stringa,sizeof(stringa),"%s renamed in %s succesfully",oldname,newname);
SendClientInfo(playerid, stringa);
if(IsPlayerConnected(nickid))
{
SendClientMessage(playerid, COLOR_WHITE, "NickName Succesfully Changed :. ");
SetPlayerName(nickid,tmp);
}
format(stringa,sizeof(stringa),"Admin(%s) renamed %s in %s",PlayerName(playerid),oldname,newname);
AppendTo(adminlog,stringa);
return 1;
}
else
{
format(stringa,sizeof(stringa),"%s - ACCOUNT ALREADY EXIST",newname);
SendClientError(playerid, stringa);
return 1;
}
}
else
{
format(stringa,sizeof(stringa),"%s, Account not found",oldname);
SendClientError(playerid, stringa);
return 1;
}
}
return 1;
}