• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] 4 digit code with leads
#1
What i'm trying to say is this:
I'm doing a 4 digit code password and you can try to guess it.
For example: The password is 1563
And i try to guess it and try: 6593
The server tells me what numbers i got right: X5X3

I don't know how to do this comparison that can output which numbers are right
  Reply
#2
Code:
main() {
    EnterPassword(6, 5, 9, 3,      1, 5, 6, 3);
}

EnterPassword(pass_0, pass_1, pass_2, pass_3, password_0, password_1, password_2, password_3) {
    new correct, pass[4], password[4], string[5] = "XXXX", number[4];
    pass[0] = pass_0, pass[1] = pass_1, pass[2] = pass_2, pass[3] = pass_3;
    password[0] = password_0, password[1] = password_1, password[2] = password_2, password[3] = password_3;
    for(new i; i < 4; i) {
        if(password[i] == pass[i]) {
            strdel(string, i, i);
            format(number, sizeof number, "%d", pass[i]);
            strins(string, number, i);
            correct;
        }
    }
    printf("Output: %s (Correct: %i)\n", string, correct);
    return correct;
}
  Reply


Forum Jump: