31.08.2015, 23:14
I couldn't find any tutorial about it, I would like to learn how to script a simple /setpass [oldpassword] [newpassword]
if(sscanf(params, "s[32]", newpass)) return SendClientMessage(playerid,-1,"SYTNAX: /setpass [new password]"); format(playervariable[playerid][playerpassword],32,newpass);
//Here is your tutorial
CMD:setpass(playerid, params[])
{
new op[20], np[20], np1[20], playername[25];
if (sscanf(params, "sss", op, np, np1)) return SendClientMessage2(playerid, COLOR_ORANGE, "Usage: /setpass [old pass] [new pass] [confirm new pass]");// You can use s[128] if you are using sscanf2
GetPlayerName(playerid, playername, MAX_PLAYER_NAME); //Getting playername
if (num_hash(op) != "Define your user's password from users file") return SendClientMessage2(playerid, COLOR_RED, "Error: You must type your current password correctly!");
if (strlen(np) < 6 || strlen(np) > 18) return SendClientMessage2(playerid, COLOR_RED, "Error: Your new password must be between 6-18 characters!");
if (strcmp(np, np1, false) != 0) return SendClientMessage2(playerid, COLOR_RED, "Error: You must confirm your new password correctly!");
//Here you must update your password in userfile
/*example */ dini_IntSet(playerfile(playerid), "Password", num_hash(op1));
SendClientMessage2(playerid, COLOR_YELLOW, "You have successfully changed your password.");
return 1;
}
CMD:changepass(playerid,params[]) { if(PlayerInfo[playerid][LoggedIn] == 1) { if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /changepass [new password]"); if(strlen(params) < 4) return SendClientMessage(playerid,red,"ACCOUNT: Incorrect password length"); new string[128]; dUserSetINT(PlayerName2(playerid)).("password_hash",udb_hash(params) ); PlayerPlaySound(playerid,1057,0.0,0.0,0.0); format(string, sizeof(string),"ACCOUNT: You have successfully changed your password to \"%s\"",params); return SendClientMessage(playerid,yellow,string); } else return SendClientMessage(playerid,red, "ERROR: You must have an account to use this command"); return1; }