Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case MSG_Public: if (!p) break;
- {
- if (started && voting) // only check during voting phase
- {
- if ((p->team == 0) || (p->team == 1)) // only players on team 0/1 can vote
- {
- if (get_tag(p, VOTED) == 0) // only can vote once, otherwise vote is changed
- {
- if (isNumeric(msg))
- {
- int vote = atoi(msg);
- if ((vote < 1) || (vote > 3)) // invalid input
- sendPrivate(p, "You must vote between 1-3 lives.");
- else // if it's between 1-5
- {
- // globals to be called only in voting phase (v1-v3)
- sendPrivate(p, "You have voted for " + (String)msg + " lives.");
- set_tag(p, VOTED, 1); // store that they voted once
- set_tag(p, LASTVOTE, vote); // store their vote in case they wish to change it
- if (vote == 1)
- ++v1;
- else if (vote == 2)
- ++v2;
- else if (vote == 3)
- ++v3;
- }
- }
- else
- sendPrivate(p, "You must vote between 1-3 lives.");
- }
- else
- {
- if (isNumeric(msg))
- {
- int vote = atoi(msg);
- if ((vote < 1) || (vote > 3)) // invalid input
- sendPrivate(p, "You must vote between 1-3 lives.");
- else // if it's between 1-3
- {
- if ((get_tag(p, LASTVOTE) == vote))
- sendPrivate(p, "You have already voted for " + (String)msg + " lives.");
- else
- {
- sendPrivate(p, "You have changed your vote to " + (String)msg + " lives.");
- if (get_tag(p, LASTVOTE) == 1) // deduct a count from his last vote
- --v1;
- else if (get_tag(p, LASTVOTE) == 2)
- --v2;
- else if (get_tag(p, LASTVOTE) == 3)
- --v3;
- if (vote == 1)
- ++v1;
- else if (vote == 2)
- ++v2;
- else if (vote == 3)
- ++v3;
- }
- }
- }
- else
- sendPrivate(p, "You must vote between 1-3 lives.");
- }
- }
- else
- sendPrivate(p, "You must be in a ship to cast a vote!");
- }
- }
- if ((countdown[5] == 0) && (started)) // voting ends
- {
- if (voting)
- {
- voting = false;
- int lives = 0;
- if ((v1 >= v2) && (v1 >= v3))
- lives = 1;
- else if ((v2 >= v1) && (v2 >= v3))
- lives = 2;
- else if ((v3 >= v1) && (v3 >= v2))
- lives = 3;
- else if ((v1 == 0) || (v2 == 0) || (v3 == 0))
- lives = 1;
- String lives_s;
- _itoa(lives, lives_s, 10);
- game_lives = lives;
- if (lives > 1)
- sendPublic(2, "*arena [VOTE ENDED] We will be playing with " + (String)lives_s.msg + " lives!");
- else if (lives == 1)
- sendPublic(2, "*arena [VOTE ENDED] We will be playing with 1 life (SUDDEN DEATH).");
- objOn(lives); // toggle graphical HUD
- countdown[1] = 5; // start game
- sendPublic("*lockarena");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement