Change Name CMD help. -
iSkate - 28.06.2014
pawn Код:
dcmd_changename(playerid, params[])
{
new oldname[125], newname[125], string[128], string2[128];
GetPlayerName(playerid, oldname, sizeof(oldname));
format(string2,sizeof(string2),"TDM-Forest/Users/%s.ini",oldname);
if(sscanf(params, "s[125]", newname)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /changename [new_name]");
format(string,sizeof(string),"TDM-Forest/Users/%s.ini",newname);
if(fexist(string)) return SendClientMessage(playerid, COLOR_RED, "Account name already exists! Please choose another name!");
else
{
new INI:File = INI_Open(string); new lolname[128];
if (File != INI_NO_FILE)
{
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",PlayerInfo[playerid][pPass]);
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Score",PlayerInfo[playerid][pScore]);
INI_Close(File);
}
SetPlayerName(playerid,newname);
format(lolname,sizeof(lolname)," ~ %s has changed his account name to %s", oldname, newname);
SendClientMessageToAll(COLOR_ORANGE,lolname);
fremove(string2);
}
return 1;
}
I took some help from the internet in making this command. Edited and made it better but the password still doesn't save. Every thing is transferred to the new account except the password. I am using the udb_hash thingy. I hope I can get help in this. Thanks in advance.
EDIT : PROBLEM FIXED.
Re: Change Name CMD help. -
iSkate - 28.06.2014
Umm...anyone?
Re: Change Name CMD help. -
Don_Cage - 28.06.2014
The password is not an integer(numbers) its a string which can be all kinds of characters. So try changing INI_WriteInt into INI_WriteString on the password line
Re: Change Name CMD help. -
iSkate - 28.06.2014
Nope. Didn't work. The password in the ini file is П instead of something like asp12093123koas..like this.
Re: Change Name CMD help. -
Flake. - 28.06.2014
What's the point of making a whole new account for a name change? Why not just changed the name of the old account.
As for the password I'd use whirlpool to hash your passwords (If you do choose to use whirlpool make sure your password string is 129 cells to allow for the whole password to save)
Re: Change Name CMD help. -
iSkate - 28.06.2014
Is there any way I can just fix this? I mean by not using any other include(s) like whirlpool. It can surely be fixed.
Re: Change Name CMD help. -
rickisme - 28.06.2014
https://sampforum.blast.hk/showthread.php?tid=496953
maybe this plugin will help you
Re: Change Name CMD help. -
iSkate - 28.06.2014
hmm, im not really sure how to use that in this situation.
Re: Change Name CMD help. -
iSkate - 28.06.2014
Bump
Re: Change Name CMD help. -
icra - 28.06.2014
Код:
INI_WriteInt(File,"Password",PlayerInfo[playerid][pPass]);
You are giving Password as an Integer.
Are you sure "pPass" is an Integer? Anyway isn't needed saving password each time you do a /changename.
By the way i suggest you to learn SQL and leave INI, it's very slow.