SA-MP Forums Archive
/setpass - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /setpass (/showthread.php?tid=587576)



/setpass (I will +1 you) - saffierr - 31.08.2015

I couldn't find any tutorial about it, I would like to learn how to script a simple /setpass [oldpassword] [newpassword]


Re: /setpass - trablon - 01.09.2015

Well.You can use your password variable for your players, YOU DON'T HAVE TO USE TWO VARIABLE.(like old and new password)
If you are using sscanf, it's more easy, of course.
For example;

Код:
if(sscanf(params, "s[32]", newpass)) return SendClientMessage(playerid,-1,"SYTNAX: /setpass [new password]");
format(playervariable[playerid][playerpassword],32,newpass);
Then save it with your saving system for onplayerdisconnect public.This is the basic logic for giving you an idea.You can use this logic.


Re: /setpass - Abagail - 01.09.2015

Here are some steps that may be helpful:
1. Check the parameters using a function such as sscanf.
2. Verify if the current password parameter matches the stored password. Hash both passwords in seperate variables before doing anything - assuming you hash your passwords.
3. Verify if the current password is different from the new.
4. Change the password - make sure you use the hashed version.

Simply adjust it to fit your system / gamemode. If you aren't hashing your passwords this is a MUST!


Re: /setpass - IceBilizard - 01.09.2015

pawn Код:
//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;
}



Re: /setpass - Bomber07 - 01.09.2015

Take this!

Код:
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;
}