Advertisement
Guest User

Untitled

a guest
May 19th, 2019
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. case MSG_Public: if (!p) break;
  2. {
  3. if (started && voting) // only check during voting phase
  4. {
  5. if ((p->team == 0) || (p->team == 1)) // only players on team 0/1 can vote
  6. {
  7. if (get_tag(p, VOTED) == 0) // only can vote once, otherwise vote is changed
  8. {
  9. if (isNumeric(msg))
  10. {
  11. int vote = atoi(msg);
  12.  
  13. if ((vote < 1) || (vote > 3)) // invalid input
  14. sendPrivate(p, "You must vote between 1-3 lives.");
  15. else // if it's between 1-5
  16. {
  17. // globals to be called only in voting phase (v1-v3)
  18. sendPrivate(p, "You have voted for " + (String)msg + " lives.");
  19. set_tag(p, VOTED, 1); // store that they voted once
  20. set_tag(p, LASTVOTE, vote); // store their vote in case they wish to change it
  21.  
  22. if (vote == 1)
  23. ++v1;
  24. else if (vote == 2)
  25. ++v2;
  26. else if (vote == 3)
  27. ++v3;
  28. }
  29. }
  30. else
  31. sendPrivate(p, "You must vote between 1-3 lives.");
  32. }
  33. else
  34. {
  35. if (isNumeric(msg))
  36. {
  37. int vote = atoi(msg);
  38.  
  39. if ((vote < 1) || (vote > 3)) // invalid input
  40. sendPrivate(p, "You must vote between 1-3 lives.");
  41. else // if it's between 1-3
  42. {
  43. if ((get_tag(p, LASTVOTE) == vote))
  44. sendPrivate(p, "You have already voted for " + (String)msg + " lives.");
  45. else
  46. {
  47. sendPrivate(p, "You have changed your vote to " + (String)msg + " lives.");
  48.  
  49. if (get_tag(p, LASTVOTE) == 1) // deduct a count from his last vote
  50. --v1;
  51. else if (get_tag(p, LASTVOTE) == 2)
  52. --v2;
  53. else if (get_tag(p, LASTVOTE) == 3)
  54. --v3;
  55.  
  56. if (vote == 1)
  57. ++v1;
  58. else if (vote == 2)
  59. ++v2;
  60. else if (vote == 3)
  61. ++v3;
  62. }
  63. }
  64. }
  65. else
  66. sendPrivate(p, "You must vote between 1-3 lives.");
  67. }
  68. }
  69. else
  70. sendPrivate(p, "You must be in a ship to cast a vote!");
  71. }
  72. }
  73.  
  74. if ((countdown[5] == 0) && (started)) // voting ends
  75. {
  76. if (voting)
  77. {
  78. voting = false;
  79. int lives = 0;
  80.  
  81. if ((v1 >= v2) && (v1 >= v3))
  82. lives = 1;
  83. else if ((v2 >= v1) && (v2 >= v3))
  84. lives = 2;
  85. else if ((v3 >= v1) && (v3 >= v2))
  86. lives = 3;
  87. else if ((v1 == 0) || (v2 == 0) || (v3 == 0))
  88. lives = 1;
  89.  
  90. String lives_s;
  91. _itoa(lives, lives_s, 10);
  92. game_lives = lives;
  93.  
  94. if (lives > 1)
  95. sendPublic(2, "*arena [VOTE ENDED] We will be playing with " + (String)lives_s.msg + " lives!");
  96. else if (lives == 1)
  97. sendPublic(2, "*arena [VOTE ENDED] We will be playing with 1 life (SUDDEN DEATH).");
  98.  
  99. objOn(lives); // toggle graphical HUD
  100. countdown[1] = 5; // start game
  101. sendPublic("*lockarena");
  102. }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement