/Changepass Not working
#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


Messages In This Thread
/Changepass Not working - by buzifej - 26.10.2014, 10:39
Re: /Changepass Not working - by Thomas. - 26.10.2014, 10:56
Re: /Changepass Not working - by buzifej - 26.10.2014, 11:18
Re: /Changepass Not working - by buzifej - 26.10.2014, 11:31
Re: /Changepass Not working - by Thomas. - 26.10.2014, 11:33
Re: /Changepass Not working - by AYOUYOU - 26.10.2014, 11:34
Re: /Changepass Not working - by Thomas. - 26.10.2014, 11:37
Re: /Changepass Not working - by buzifej - 26.10.2014, 11:42
Re: /Changepass Not working - by buzifej - 26.10.2014, 16:26

Forum Jump:


Users browsing this thread: 1 Guest(s)