/Changepass Not working
#1

If i typed /changepass oldpass12 newpass12 its showed me Server:Unkown Command.

Code:
CMD:changepass( playerid, params[])
{
	if ( !BUD::IsNameRegistered( PlayerName2( playerid ) ) )
	    return SendError( playerid, "You must be registered to change your pass.~n~Use ~b~~h~/register~w~.");

	if ( P_DATA[ playerid ][ P_Logged ] == 0 )
	    return SendError( playerid,  "Please ~b~~h~/login ~w~to change your password.");

  BUD::JSCHash( NewPass, pPassHash );

    BUD::MultiSet( iUID, "sss", "passhash", 	pPassHash,
								"Password", 	NewPass,
								"Old_Password", OldPass );

	format( String, sizeof String, "Password has been changed!~n~~n~~r~~h~Old:~w~%s~n~~b~~h~New: ~w~%s", OldPass,NewPass );
	Info( playerid, String,9000 );



	new NewPass[ 21 ], OldPass[ 129 ];
	if ( sscanf( params, "s[21]s[129]", OldPass, NewPass ))
	    return SendUsage( playerid, "/changepass [OLD] [NEW]");

	new Password[ 20 ],
		String[ 129 ],
		pPassHash[  (64) + 1  ]
	;
	new iUID = BUD::GetNameUID( PlayerName2( playerid ) );
	BUD::GetStringEntry( iUID, "Password", Password, 20 );

	if ( strcmp( Password, OldPass, false ) )
	    return SendError( playerid, "Old password didn't match the one you inserted!");

	if ( strlen( NewPass ) < 3 || strlen( NewPass ) > 20 )
	    return SendError( playerid, "New password may contain:~n~ Min. 3 Char. and Max. 20 Char.");

    BUD::JSCHash( NewPass, pPassHash );

    BUD::MultiSet( iUID, "sss", "passhash", 	pPassHash,
								"Password", 	NewPass,
								"Old_Password", OldPass );

	format( String, sizeof String, "Password has been changed!~n~~n~~r~~h~Old:~w~%s~n~~b~~h~New: ~w~%s", OldPass,NewPass );
	Info( playerid, String,9000 );

	return 1;
}
Reply
#2

Your logic flow is defect: you are trying to alter the password at the very beginning of the logic, before any validation has occured and some of the essential data isn't available yet (not to mention that some variables used aren't even initialized at this point, the compiler must have been quite upset with you).

This should work (not tested):

pawn Code:
CMD:changepass( playerid, params[])
{
    if ( !BUD::IsNameRegistered( PlayerName2( playerid ) ) )
        return SendError( playerid, "You must be registered to change your pass.~n~Use ~b~~h~/register~w~.");

    if ( P_DATA[ playerid ][ P_Logged ] == 0 )
        return SendError( playerid,  "Please ~b~~h~/login ~w~to change your password.");


    new NewPass[ 21 ], OldPass[ 129 ];
    if ( sscanf( params, "s[21]s[129]", OldPass, NewPass ))
        return SendUsage( playerid, "/changepass [OLD] [NEW]");

    new Password[ 20 ],
        String[ 129 ],
        pPassHash[  (64) + 1  ]
    ;
    new iUID = BUD::GetNameUID( PlayerName2( playerid ) );
    BUD::GetStringEntry( iUID, "Password", Password, 20 );

    if ( strcmp( Password, OldPass, false ) )
        return SendError( playerid, "Old password didn't match the one you inserted!");

    if ( strlen( NewPass ) < 3 || strlen( NewPass ) > 20 )
        return SendError( playerid, "New password may contain:~n~ Min. 3 Char. and Max. 20 Char.");

    BUD::JSCHash( NewPass, pPassHash );

    BUD::MultiSet( iUID, "sss", "passhash",     pPassHash,
                                "Password",     NewPass,
                                "Old_Password", OldPass );

    format( String, sizeof String, "Password has been changed!~n~~n~~r~~h~Old:~w~%s~n~~b~~h~New: ~w~%s", OldPass,NewPass );
    Info( playerid, String,9000 );

    return 1;
}
Reply
#3

Not working. I typed /Changepass asdasd to asdasd2 and it's Unkow Command
Reply
#4

It's Same Error
Reply
#5

What does your PlayerName2() function look like?
Reply
#6

PHP Code:
[CODE]CMD:changepassword(playerid,params[])
{
    if(
pInfo[playerid][Logged] == 1)
    {
        new 
pass[25],file[256], buf[145];
        if(
sscanf(params"s[25]"pass)) return SendClientMessage(playeridyellow"Usage: /Changepassword <New Password>");
        if(
strlen(pass) < || strlen(pass) > 20) return SendClientMessage(playerid,red,"Error: Password lenght must be between 3 - 20 chracters!");
        
WP_Hash(bufsizeof(buf), pass);
        
format(file256ACCOUNTS_PATHJGetName(playerid));
        new 
INI:ACCOUNT INI_Open(file);
        
INI_WriteString(ACCOUNT"Password"buf);
        
INI_Close(ACCOUNT);
        
format(Jstringsizeof(Jstring),"Your password has been successfully changed to '%s'",pass);
        return 
SendClientMessage(playerid,yellow,Jstring);
    }
    else return 
ShowMessage(playeridred4);
}
CMD:changepass(playerid,params[])
{
    return 
cmd_changepassword(playerid,params);
}
[/
CODE
Reply
#7

That most likely isn't going to work for him, he utilizes an entirely different user management system.
Reply
#8

Yes, the previous not working
Code:
stock PlayerName2(playerid) {
  new name[MAX_PLAYER_NAME];
  GetPlayerName(playerid, name, sizeof(name));
  return name;
}
Reply
#9

anybody?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)