26.09.2012, 22:04
Use the function SetPlayerName to change a user's name when they are currently in game.
As for detecting if the username is already taken, format the path of the new name and use fexist to determine if it's taken or not.
(If your using MySQL, fexist will not work obviously). If the user's file currently exists and they are registered, you can use this custom stock function:
To modify and re-name their userfile to the new username.
As for detecting if the username is already taken, format the path of the new name and use fexist to determine if it's taken or not.
(If your using MySQL, fexist will not work obviously). If the user's file currently exists and they are registered, you can use this custom stock function:
pawn Code:
stock frename(oldname[], newname[])
{
if(!fexist(oldname)) return false;
new string[128], File:old, File:neww;
old = fopen(oldname, io_read);
neww = fopen(newname, io_write);
while(fread(old, string))
{
StripNewLine(string);
format(string, sizeof(string), "%s\r\n", string);
fwrite(neww, string);
}
fclose(old);
fclose(neww);
fremove(oldname);
return true;
}