CMD:changepassword(playerid,params[])
{
if( pInfo[playerid][Spawned] != 1)
{
ShowMessage(playerid, error, 9);
return 1;
}
new pass[25],file[256];
if(sscanf(params, "s[25]", pass)) return SendClientMessage(playerid, error, "Usage: /Changepassword <New Password>");
if(strlen(pass) < 5 || strlen(pass) > 20) return SendClientMessage(playerid,error,"Error: Password lenght must be between 5 - 20 chracters!");
format(file, 256, PATH, GetName(playerid));
new INI:ACCOUNT = INI_Open(file);
INI_SetTag(ACCOUNT,"data");
INI_WriteString(ACCOUNT, "Password",udb_hash(pass));
INI_Close(ACCOUNT);
format(astring, sizeof(astring),"Your password has been successfully changed.{FFFFFF} [NEW PASSWORD: %s]",pass);
return SendClientMessage(playerid,red,astring);
}
stock udb_hash(buf[])
{
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}
INI_WriteString(ACCOUNT, "Password",udb_hash(pass)); //error line
INI_WriteInt
I think the udb_hash converts the password in an integer, so you must use
Код:
INI_WriteInt Also, remember to change your INI_String for INI_Int when loading the player's data. |