Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define NUM_LOCKS 3
- int lock_code[NUM_LOCKS][3] = {{6, 9, 1}, {3, 2, 5}, {1, 7, 3}};
- int digit_pick[3];
- bool lock_picked[NUM_LOCKS];
- script 1 (int this_lock)
- {
- if (!lock_picked[this_lock])
- {
- int buttons, count, match, quit, wait;
- SetHUDSize(640, 480, 1);
- HUDMessage(s:"Forward and back change digits, use to pick, and fire to exit.";
- HUDMSG_PLAIN, 1, CR_WHITE, 0.1, 30.1, 0.0);
- SetPlayerProperty(0, 1, PROP_TOTALLYFROZEN);
- while (count < 3 && !quit)
- {
- buttons = GetPlayerInput(-1, INPUT_BUTTONS);
- if (buttons & BT_ATTACK)
- {
- quit = 1;
- }
- else if (buttons & BT_FORWARD)
- {
- digit_pick[count]++;
- digit_pick[count] %= 10;
- }
- else if (buttons & BT_BACK)
- {
- digit_pick[count] += 9;
- digit_pick[count] %= 10;
- }
- else if (buttons & BT_USE)
- {
- count++;
- }
- if (count < 3)
- {
- HUDMessage(i:digit_pick[count];
- HUDMSG_PLAIN, 2+count, CR_RED, 305.0+count*10.0, 240.0, 0);
- do
- {
- delay(1);
- wait++;
- }
- while (GetPlayerInput(-1, INPUT_BUTTONS) == buttons && wait < 5);
- wait = 0;
- }
- }
- if (!quit)
- {
- for (int i=0; i<3; i++)
- {
- if (lock_code[this_lock][i] == digit_pick[i])
- {
- match++;
- }
- digit_pick[i] = 0;
- }
- if (match == 3)
- {
- HUDMessage(s:"Lock combination accepted."; HUDMSG_FADEOUT, 5, CR_GREEN, 320.0, 200.0, 3.0, 1.0);
- lock_picked[this_lock] = 1;
- switch (this_lock)
- {
- case 1:
- //action for lock 1
- break;
- case 2:
- //action for lock 2
- break;
- case 3:
- //action for lock 3
- break;
- }
- }
- else
- {
- HUDMessage(s:"Invalid lock combination."; HUDMSG_FADEOUT, 5, CR_RED, 320.0, 200.0, 3.0, 1.0);
- }
- }
- HUDMessage(s:""; 0, 1, 0, 0, 0, 0);
- HUDMessage(s:""; 0, 2, 0, 0, 0, 0);
- HUDmessage(s:""; 0, 3, 0, 0, 0, 0);
- HUDMessage(s:""; 0, 4, 0, 0, 0, 0);
- SetPlayerProperty(0, 0, PROP_TOTALLYFROZEN);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement