10.06.2011, 10:14
Hi guys,someone can give me some help to code the /changepassword command?Thanks.
dcmd_CMD_CHANGEPASS(playerid,params[])
{
if(AccInfo[playerid][LoggedIn] == 1)
{
if(!strlen(params)) return
SendClientMessage(playerid, LIGHTBLUE2, "Usage: /"#ChangePassCommand" [NewPassword]")
&& SendClientMessage(playerid, orange, "Function: Will modify your account password");
if(strlen(params) < 4) return SendClientMessage(playerid,red,"ERROR: Incorrect password length!");
new string[128];
new file[128], Pass[256];
format(file,sizeof(file),"/YOURADMINSCRIPT/Accounts/%s.sav",udb_encode(PlayerName2(playerid)) );
new buf[145];
WP_Hash(buf, sizeof(buf), params);
Pass = dini_Get(file, "Password");
dini_Set(file, "Password", buf);
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
format(string, sizeof(string),"|- You have successfully changed your account Password to \"%s\" -|",params);
return SendClientMessage(playerid,yellow,string);
} else return SendClientMessage(playerid,red, "ERROR: You must have an account to use this command");
}
I am a newbie but I like to try to help people! Correct me if I am wrong about this
pawn Код:
|
dini_IntSet(udb_encode(playername), "password", udb_hash(inputtext));
if(strcmp(cmd, "/changepass", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, " You need to login first.");
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " This feature is comming up on next release");
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /changepass[password]");
return 1;
}
strmid(PlayerInfo[playerid][pKey], tmp, 0, strlen(cmdtext), 255);
OnPlayerUpdate(playerid);
SendClientMessage(playerid, COLOR_YELLOW, " Password has been changed successfuly");
}
return 1;
}