Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] 4 digit code with leads

 
  • 0 Vote(s) - 0 Average
Pawn 4 digit code with leads
McZulian
Offline

Burgershot Member
Posts: 3
Threads: 3
Joined: Feb 2021
Reputation: 0
Location: Argentina
#1
2021-04-25, 12:12 AM (This post was last modified: 2021-04-25, 12:46 AM by McZulian.)
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
Radical
Offline

Burgershot Member
Posts: 148
Threads: 21
Joined: Dec 2020
Reputation: 16
#2
2021-04-25, 12:32 AM (This post was last modified: 2021-04-25, 12:02 PM by Radical.)
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+1);
            format(number, sizeof number, "%d", pass[i]);
            strins(string, number, i);
            correct++;
        }
    }
    printf("Output: %s (Correct: %i)\n", string, correct);
    return correct;
}
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode