Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. #define NUM_LOCKS 3
  2.  
  3. int lock_code[NUM_LOCKS][3] = {{6, 9, 1}, {3, 2, 5}, {1, 7, 3}};
  4. int digit_pick[3];
  5. bool lock_picked[NUM_LOCKS];
  6.  
  7. script 1 (int this_lock)
  8. {
  9. if (!lock_picked[this_lock])
  10. {
  11. int buttons, count, match, quit, wait;
  12.  
  13. SetHUDSize(640, 480, 1);
  14. HUDMessage(s:"Forward and back change digits, use to pick, and fire to exit.";
  15. HUDMSG_PLAIN, 1, CR_WHITE, 0.1, 30.1, 0.0);
  16. SetPlayerProperty(0, 1, PROP_TOTALLYFROZEN);
  17.  
  18. while (count < 3 && !quit)
  19. {
  20. buttons = GetPlayerInput(-1, INPUT_BUTTONS);
  21.  
  22. if (buttons & BT_ATTACK)
  23. {
  24. quit = 1;
  25. }
  26. else if (buttons & BT_FORWARD)
  27. {
  28. digit_pick[count]++;
  29. digit_pick[count] %= 10;
  30. }
  31. else if (buttons & BT_BACK)
  32. {
  33. digit_pick[count] += 9;
  34. digit_pick[count] %= 10;
  35. }
  36. else if (buttons & BT_USE)
  37. {
  38. count++;
  39. }
  40.  
  41. if (count < 3)
  42. {
  43. HUDMessage(i:digit_pick[count];
  44. HUDMSG_PLAIN, 2+count, CR_RED, 305.0+count*10.0, 240.0, 0);
  45. do
  46. {
  47. delay(1);
  48. wait++;
  49. }
  50. while (GetPlayerInput(-1, INPUT_BUTTONS) == buttons && wait < 5);
  51. wait = 0;
  52. }
  53. }
  54.  
  55. if (!quit)
  56. {
  57. for (int i=0; i<3; i++)
  58. {
  59. if (lock_code[this_lock][i] == digit_pick[i])
  60. {
  61. match++;
  62. }
  63. digit_pick[i] = 0;
  64. }
  65.  
  66. if (match == 3)
  67. {
  68. HUDMessage(s:"Lock combination accepted."; HUDMSG_FADEOUT, 5, CR_GREEN, 320.0, 200.0, 3.0, 1.0);
  69. lock_picked[this_lock] = 1;
  70.  
  71. switch (this_lock)
  72. {
  73. case 1:
  74. //action for lock 1
  75. break;
  76. case 2:
  77. //action for lock 2
  78. break;
  79. case 3:
  80. //action for lock 3
  81. break;
  82. }
  83. }
  84. else
  85. {
  86. HUDMessage(s:"Invalid lock combination."; HUDMSG_FADEOUT, 5, CR_RED, 320.0, 200.0, 3.0, 1.0);
  87. }
  88. }
  89.  
  90. HUDMessage(s:""; 0, 1, 0, 0, 0, 0);
  91. HUDMessage(s:""; 0, 2, 0, 0, 0, 0);
  92. HUDmessage(s:""; 0, 3, 0, 0, 0, 0);
  93. HUDMessage(s:""; 0, 4, 0, 0, 0, 0);
  94. SetPlayerProperty(0, 0, PROP_TOTALLYFROZEN);
  95. }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement