Downloads containing votekick.mut

Downloads
Name Author Game Mode Rating
JJ2+ Only: Vote kickingFeatured Download szmol96 Mutator 8.7 Download file

File preview

#pragma name "Votekick"

const int timeout = 30; //Time limit in seconds
int counter = 0;
bool votingActive = false;

uint playerToKick = 0;
string reasonForKicking = "";
int votes = 0;

int activePlayers() {
	uint number = 0;
	for(uint i = 0; i < 32; i++) {
		if (jjPlayers[i].isActive) number++;
	}
	return number;
}

void onMain() {
	if (jjIsServer && votingActive) {
		if (votes > activePlayers() / 2) {
			jjChat("/kick " + playerToKick + " " + reasonForKicking);
			votingActive = false;
			playerToKick = 0;
			reasonForKicking = "";
			votes = 0;
			counter = 0;
		}
		
		if (counter == timeout * 70) {
			jjConsole("Kick voting for " + join(jjPlayers[playerToKick- 1].name.split("|"), "") + " timed out.", true);
			playerToKick = 0;
			reasonForKicking = "";
			votes = 0;
			votingActive = false;
			counter = 0;
		}
		
		counter++;
	}
}

void onChat(int clientID, string &in stringReceived, CHAT::Type chatType) {
	array<string> results;
	if (jjIsServer) {
		if (jjRegexIsValid(stringReceived) && jjRegexMatch(stringReceived, "!votekick\\s+(\\d+)\\s+(.+?)\\s*", results, true) && !votingActive) {
			if (jjPlayers[parseInt(results[1]) - 1].isActive) {
				jjConsole(join(jjPlayers[clientID].name.split("|"), "") + " started a kick voting against " + join(jjPlayers[parseInt(results[1]) - 1].name.split("|"), ""), true);
				jjConsole("Reason: " + results[2], true);
				playerToKick = parseInt(results[1]);
				reasonForKicking = results[2];
				votingActive = true;
			}
		}
		if (votingActive && stringReceived == "!y") {
			votes++;
			jjConsole(join(jjPlayers[clientID].name.split("|"), "") + " voted yes.", true);
		}
	}
}