home *** CD-ROM | disk | FTP | other *** search
- $curVoteTopic = "";
- $curVoteAction = "";
- $curVoteOption = "";
- $curVoteCount = 0;
-
- function Admin::changeMissionMenu(%clientId)
- {
- Client::buildMenu(%clientId, "Pick Mission Type", "cmtype", true);
- %index = 1;
- for(%type = 1; %type < $MLIST::TypeCount; %type++)
- if($MLIST::Type[%type] != "Training")
- {
- Client::addMenuItem(%clientId, %index @ $MLIST::Type[%type], %type @ " 0");
- %index++;
- }
- }
-
- function processMenuCMType(%clientId, %options)
- {
- %curItem = 0;
- %option = getWord(%options, 0);
- %first = getWord(%options, 1);
- Client::buildMenu(%clientId, "Pick Mission", "cmission", true);
-
- for(%i = 0; (%misIndex = getWord($MLIST::MissionList[%option], %first + %i)) != -1; %i++)
- {
- if(%i > 6)
- {
- Client::addMenuItem(%clientId, %i+1 @ "More missions...", "more " @ %first + %i @ " " @ %option);
- break;
- }
- Client::addMenuItem(%clientId, %i+1 @ $MLIST::EName[%misIndex], %misIndex @ " " @ %option);
- }
- }
-
- function processMenuCMission(%clientId, %option)
- {
- if(getWord(%option, 0) == "more")
- {
- %first = getWord(%option, 1);
- %type = getWord(%option, 2);
- processMenuCMType(%clientId, %type @ " " @ %first);
- return;
- }
- %mi = getWord(%option, 0);
- %mt = getWord(%option, 1);
-
- %misName = $MLIST::EName[%mi];
- %misType = $MLIST::Type[%mt];
-
- // verify that this is a valid mission:
- if(%misType == "" || %misType == "Training")
- return;
- for(%i = 0; true; %i++)
- {
- %misIndex = getWord($MLIST::MissionList[%mt], %i);
- if(%misIndex == %mi)
- break;
- if(%misIndex == -1)
- return;
- }
- if(%clientId.isAdmin)
- {
- messageAll(0, Client::getName(%clientId) @ " changed the mission to " @ %misName @ " (" @ %misType @ ")");
- Vote::changeMission();
- Server::loadMission(%misName);
- }
- else
- {
- Admin::startVote(%clientId, "change the mission to " @ %misName @ " (" @ %misType @ ")", "cmission", %misName);
- Game::menuRequest(%clientId);
- }
- }
-
- function remoteAdminPassword(%client, %password)
- {
- if($AdminPassword != "" && %password == $AdminPassword)
- {
- %client.isAdmin = true;
- %client.isSuperAdmin = true;
- }
- }
-
- function remoteSetPassword(%client, %password)
- {
- if(%client.isSuperAdmin)
- $Server::Password = %password;
- }
-
- function remoteSetTimeLimit(%client, %time)
- {
- %time = floor(%time);
- if(%time == $Server::timeLimit || (%time != 0 && %time < 1))
- return;
- if(%client.isAdmin)
- {
- $Server::timeLimit = %time;
- if(%time)
- messageAll(0, Client::getName(%client) @ " changed the time limit to " @ %time @ " minute(s).");
- else
- messageAll(0, Client::getName(%client) @ " disabled the time limit.");
-
- }
- }
-
- function remoteSetTeamInfo(%client, %team, %teamName, %skinBase)
- {
- if(%team >= 0 && %team < 8 && %client.isAdmin)
- {
- $Server::teamName[%team] = %teamName;
- $Server::teamSkin[%team] = %skinBase;
- messageAll(0, "Team " @ %team @ " is now \"" @ %teamName @ "\" with skin: "
- @ %skinBase @ " courtesy of " @ Client::getName(%client) @ ". Changes will take effect next mission.");
- }
- }
-
- function Admin::setTeamDamageEnable(%admin, %enabled)
- {
- if(%admin == -1 || %admin.isAdmin)
- {
- if(%enabled)
- {
- $Server::TeamDamageScale = 1;
- if(%admin == -1)
- messageAll(0, "Team damage set to ENABLED by consensus.");
- else
- messageAll(0, Client::getName(%admin) @ " ENABLED team damage.");
- }
- else
- {
- $Server::TeamDamageScale = 0;
- if(%admin == -1)
- messageAll(0, "Team damage set to DISABLED by consensus.");
- else
- messageAll(0, Client::getName(%admin) @ " DISABLED team damage.");
- }
- }
- }
-
- function Admin::kick(%admin, %client)
- {
- if(%admin == -1 || %admin.isAdmin)
- {
- if(%client.isSuperAdmin)
- {
- if(%admin == -1)
- messageAll(0, "A super admin cannot be kicked.");
- else
- Client::sendMessage(%admin, 0, "A super admin cannot be kicked.");
- return;
- }
- %ip = Client::getTransportAddress(%client);
- if(%ip == "")
- return;
- BanList::add(%ip, 60);
- if(%admin == -1)
- Net::kick(%client, "You were kicked by consensus.");
- else
- Net::kick(%client, "You were kicked by " @ Client::getName(%admin));
- }
- }
-
- function Admin::setModeFFA(%clientId)
- {
- if($Server::TourneyMode && (%clientId == -1 || %clientId.isAdmin))
- {
- if(%clientId == -1)
- messageAll(0, "Server switched to Free-For-All Mode.");
- else
- messageAll(0, "Server switched to Free-For-All Mode by " @ Client::getName(%clientId) @ ".");
-
- $Server::TourneyMode = false;
- if(!$matchStarted && !$countdownStarted)
- {
- if($Server::warmupTime)
- Server::Countdown($Server::warmupTime);
- else
- Game::startMatch();
- }
- }
- }
-
- function Admin::setModeTourney(%clientId)
- {
- if(!$Server::TourneyMode && (%clientId == -1 || %clientId.isAdmin))
- {
- if(%clientId == -1)
- messageAll(0, "Server switched to Tournament Mode.");
- else
- messageAll(0, "Server switched to Tournament Mode by " @ Client::getName(%clientId) @ ".");
-
- $Server::TourneyMode = true;
- Server::nextMission();
- }
- }
-
- function Admin::voteFailed()
- {
- if($curVoteAction == "kick" || $curVoteAction == "admin")
- $curVoteOption.voteTarget = "";
- }
-
- function Admin::voteSucceded()
- {
- if($curVoteAction == "kick")
- {
- if($curVoteOption.voteTarget)
- Admin::kick(-1, $curVoteOption);
- }
- else if($curVoteAction == "admin")
- {
- if($curVoteOption.voteTarget)
- {
- $curVoteOption.isAdmin = true;
- messageAll(0, Client::getName($curVoteOption) @ " has become an administrator.");
- if($curVoteOption.menuMode == "options")
- Game::menuRequest($curVoteOption);
- }
- $curVoteOption.voteTarget = false;
- }
- else if($curVoteAction == "cmission")
- {
- messageAll(0, "Changing to mission " @ $curVoteOption @ ".");
- Vote::changeMission();
- Server::loadMission($curVoteOption);
- }
- else if($curVoteAction == "tourney")
- Admin::setModeTourney(-1);
- else if($curVoteAction == "ffa")
- Admin::setModeFFA(-1);
- else if($curVoteAction == "etd")
- Admin::setTeamDamageEnable(-1, true);
- else if($curVoteAction == "dtd")
- Admin::setTeamDamageEnable(-1, false);
- }
-
- function Admin::countVotes(%curVote)
- {
- // if %end is true, cancel the vote either way
- if(%curVote != $curVoteCount)
- return;
-
- %votesFor = 0;
- %votesAgainst = 0;
- %totalClients = 0;
- %totalVotes = 0;
- for(%cl = Client::getFirst(); %cl != -1; %cl = Client::getNext(%cl))
- {
- %totalClients++;
- if(%cl.vote == "yes")
- {
- %votesFor++;
- %totalVotes++;
- }
- else if(%cl.vote == "no")
- {
- %votesAgainst++;
- %totalVotes++;
- }
- }
- if(%totalVotes / %totalClients >= $Server::MinVotesPct &&
- %votesFor / %totalVotes >= $Server::VoteWinMargin &&
- %totalVotes >= $Server::MinVotes)
- {
- messageAll(0, "Vote to " @ $curVoteTopic @ " passed: " @ %votesFor @ " to " @ %votesAgainst @ " with " @ %totalClients - (%votesFor + %votesAgainst) @ " abstentions.");
- Admin::voteSucceded();
- }
- else
- {
- messageAll(0, "Vote to " @ $curVoteTopic @ " did not pass: " @ %votesFor @ " to " @ %votesAgainst @ " with " @ %totalClients - (%votesFor + %votesAgainst) @ " abstentions.");
- Admin::voteFailed();
- }
- $curVoteTopic = "";
- }
-
- function Admin::startVote(%clientId, %topic, %action, %option)
- {
- if(%clientId.lastVoteTime == "")
- %clientId.lastVoteTime = -$Server::MinVoteTime;
- %diff = %clientId.lastVoteTime + $Server::MinVoteTime - getSimTime();
-
- if(%diff > 0)
- {
- Client::sendMessage(%clientId, 0, "You can't start another vote for " @ floor(%diff) @ " seconds.");
- return;
- }
- if($curVoteTopic == "")
- {
- %clientId.lastVoteTime = getSimTime();
- $curVoteTopic = %topic;
- $curVoteAction = %action;
- $curVoteOption = %option;
- $curVoteCount++;
- bottomprintall("<jc><f1>" @ Client::getName(%clientId) @ " <f0>initiated a vote to <f1>" @ $curVoteTopic, 10);
- for(%cl = Client::getFirst(); %cl != -1; %cl = Client::getNext(%cl))
- %cl.vote = "";
- %clientId.vote = "yes";
- for(%cl = Client::getFirst(); %cl != -1; %cl = Client::getNext(%cl))
- if(%cl.menuMode == "options")
- Game::menuRequest(%clientId);
- schedule("Admin::countVotes(" @ $curVoteCount @ ", true);", $Server::VotingTime, 35);
- }
- else
- {
- Client::sendMessage(%clientId, 0, "Voting already in progress.");
- }
- }
-
- function Game::menuRequest(%clientId)
- {
- %curItem = 0;
- Client::buildMenu(%clientId, "Options", "options", true);
- if(!$matchStarted || !$Server::TourneyMode)
- {
- Client::addMenuItem(%clientId, %curItem++ @ "Change Teams/Observe", "changeteams");
- }
- if(%clientId.selClient)
- {
- %sel = %clientId.selClient;
- %name = Client::getName(%sel);
-
- if($curVoteTopic == "" && !%clientId.isAdmin)
- {
- Client::addMenuItem(%clientId, %curItem++ @ "Vote to admin " @ %name, "vadmin " @ %sel);
- Client::addMenuItem(%clientId, %curItem++ @ "Vote to kick " @ %name, "vkick " @ %sel);
- }
- if(%clientId.isAdmin)
- {
- Client::addMenuItem(%clientId, %curItem++ @ "Kick " @ %name, "kick " @ %sel);
- Client::addMenuItem(%clientId, %curItem++ @ "Change " @ %name @ "'s team", "fteamchange " @ %sel);
- }
- if(%clientId.muted[%sel])
- Client::addMenuItem(%clientId, %curItem++ @ "Unmute " @ %name, "unmute " @ %sel);
- else
- Client::addMenuItem(%clientId, %curItem++ @ "Mute " @ %name, "mute " @ %sel);
-
- }
- if($curVoteTopic != "" && %clientId.vote == "")
- {
- Client::addMenuItem(%clientId, %curItem++ @ "Vote YES to " @ $curVoteTopic, "voteYes " @ $curVoteCount);
- Client::addMenuItem(%clientId, %curItem++ @ "Vote NO to " @ $curVoteTopic, "voteNo " @ $curVoteCount);
- }
- else if($curVoteTopic == "" && !%clientId.isAdmin)
- {
- Client::addMenuItem(%clientId, %curItem++ @ "Vote to change mission", "vcmission");
- if($Server::TeamDamageScale == 1.0)
- Client::addMenuItem(%clientId, %curItem++ @ "Vote to disable team damage", "vdtd");
- else
- Client::addMenuItem(%clientId, %curItem++ @ "Vote to enable team damage", "vetd");
-
- if($Server::TourneyMode)
- Client::addMenuItem(%clientId, %curItem++ @ "Vote to enter FFA mode", "vcffa");
- else
- Client::addMenuItem(%clientId, %curItem++ @ "Vote to enter Tournament mode", "vctourney");
-
- }
- else if(%clientId.isAdmin)
- {
- Client::addMenuItem(%clientId, %curItem++ @ "Change mission", "cmission");
- if($Server::TeamDamageScale == 1.0)
- Client::addMenuItem(%clientId, %curItem++ @ "Disable team damage", "dtd");
- else
- Client::addMenuItem(%clientId, %curItem++ @ "Enable team damage", "etd");
-
- if($Server::TourneyMode)
- Client::addMenuItem(%clientId, %curItem++ @ "Change to FFA mode", "cffa");
- else
- Client::addMenuItem(%clientId, %curItem++ @ "Change to Tournament mode", "ctourney");
- }
- }
-
- function remoteSelectClient(%clientId, %selId)
- {
- if(%clientId.selClient != %selId)
- {
- %clientId.selClient = %selId;
- if(%clientId.menuMode == "options")
- Game::menuRequest(%clientId);
- remoteEval(%clientId, "setInfoLine", 1, "Player Info for " @ Client::getName(%selId) @ ":");
- remoteEval(%clientId, "setInfoLine", 2, "Real Name: " @ $Client::info[%selId, 1]);
- remoteEval(%clientId, "setInfoLine", 3, "Email Addr: " @ $Client::info[%selId, 2]);
- remoteEval(%clientId, "setInfoLine", 4, "Tribe: " @ $Client::info[%selId, 3]);
- remoteEval(%clientId, "setInfoLine", 5, "URL: " @ $Client::info[%selId, 4]);
- remoteEval(%clientId, "setInfoLine", 6, "Other: " @ $Client::info[%selId, 5]);
- }
- }
-
- function processMenuFPickTeam(%clientId, %team)
- {
- if(%clientId.isAdmin)
- processMenuPickTeam(%clientId.ptc, %team, %clientId);
- %clientId.ptc = "";
- }
-
- function processMenuPickTeam(%clientId, %team, %adminClient)
- {
- checkPlayerCash(%clientId);
- if(%team != -1 && %team == Client::getTeam(%clientId))
- return;
-
- if(%clientId.observerMode == "justJoined")
- {
- %clientId.observerMode = "";
- centerprint(%clientId, "");
- }
-
- if((!$matchStarted || !$Server::TourneyMode || %adminClient) && %team == -2)
- {
- if(Observer::enterObserverMode(%clientId))
- {
- if(%adminClient == "")
- messageAll(0, Client::getName(%clientId) @ " became an observer.");
- else
- messageAll(0, Client::getName(%clientId) @ " was forced into observer mode by " @ Client::getName(%adminClient) @ ".");
- Game::resetScores(%clientId);
- Game::refreshClientScore(%clientId);
- }
- return;
- }
-
- %player = Client::getOwnedObject(%clientId);
- if(%player != -1 && getObjectType(%player) == "Player" && !Player::isDead(%player)) {
- playNextAnim(%clientId);
- Player::kill(%clientId);
- }
- %clientId.observerMode = "";
- if(%adminClient == "")
- messageAll(0, Client::getName(%clientId) @ " changed teams.");
- else
- messageAll(0, Client::getName(%clientId) @ " was teamchanged by " @ Client::getName(%adminClient) @ ".");
-
- if(%team == -1)
- {
- Game::assignClientTeam(%clientId);
- %team = Client::getTeam(%clientId);
- }
- GameBase::setTeam(%clientId, %team);
- %clientId.teamEnergy = 0;
- Client::clearItemShopping(%clientId);
- if(Client::getGuiMode(%clientId) != 1)
- Client::setGuiMode(%clientId,1);
- Client::setControlObject(%clientId, -1);
-
- Game::playerSpawn(%clientId, false);
- %team = Client::getTeam(%clientId);
- if($TeamEnergy[%team] != "Infinite")
- $TeamEnergy[%team] += $InitialPlayerEnergy;
-
- if($Server::TourneyMode && !$CountdownStarted)
- {
- // loop through all the clients and see if any are still in
- // pickingTeam observer mode:
- %playerCount = 0;
- for(%cl = Client::getFirst(); %cl != -1; %cl = Client::getNext(%cl))
- {
- if(%cl.observerMode == "pickingTeam")
- return;
- if(%cl.observerMode == "pregame")
- %playerCount++;
- }
- if(%playerCount != 0)
- Server::Countdown(30);
- }
- }
-
- function processMenuOptions(%clientId, %option)
- {
- %opt = getWord(%option, 0);
- %cl = getWord(%option, 1);
-
- if(%opt == "fteamchange")
- {
- %clientId.ptc = %cl;
- Client::buildMenu(%clientId, "Pick a team:", "FPickTeam", true);
- Client::addMenuItem(%clientId, "0Observer", -2);
- Client::addMenuItem(%clientId, "1Automatic", -1);
- for(%i = 0; %i < getNumTeams(); %i = %i + 1)
- Client::addMenuItem(%clientId, (%i+2) @ getTeamName(%i), %i);
- return;
- }
- else if(%opt == "changeteams")
- {
- if(!$matchStarted || !$Server::TourneyMode)
- {
- Client::buildMenu(%clientId, "Pick a team:", "PickTeam", true);
- Client::addMenuItem(%clientId, "0Observer", -2);
- Client::addMenuItem(%clientId, "1Automatic", -1);
- for(%i = 0; %i < getNumTeams(); %i = %i + 1)
- Client::addMenuItem(%clientId, (%i+2) @ getTeamName(%i), %i);
- return;
- }
- }
- else if(%opt == "mute")
- %clientId.muted[%cl] = true;
- else if(%opt == "unmute")
- %clientId.muted[%cl] = "";
- else if(%opt == "vkick")
- {
- %cl.voteTarget = true;
- Admin::startVote(%clientId, "kick " @ Client::getName(%cl), "kick", %cl);
- }
- else if(%opt == "vadmin")
- {
- %cl.voteTarget = true;
- Admin::startVote(%clientId, "admin " @ Client::getName(%cl), "admin", %cl);
- }
- else if(%opt == "vetd")
- Admin::startVote(%clientId, "enable team damage", "etd", 0);
- else if(%opt == "vdtd")
- Admin::startVote(%clientId, "disable team damage", "dtd", 0);
- else if(%opt == "etd")
- Admin::setTeamDamageEnable(%clientId, true);
- else if(%opt == "dtd")
- Admin::setTeamDamageEnable(%clientId, false);
- else if(%opt == "vcffa")
- Admin::startVote(%clientId, "change to Free For All mode", "ffa", 0);
- else if(%opt == "vctourney")
- Admin::startVote(%clientId, "change to Tournament mode", "tourney", 0);
- else if(%opt == "cffa")
- Admin::setModeFFA(%clientId);
- else if(%opt == "ctourney")
- Admin::setModeTourney(%clientId);
- else if(%opt == "voteYes" && %cl == $curVoteCount)
- %clientId.vote = "yes";
- else if(%opt == "voteNo" && %cl == $curVoteCount)
- %clientId.vote = "no";
- else if(%opt == "kick")
- {
- Client::buildMenu(%clientId, "Confirm kick:", "kaffirm", true);
- Client::addMenuItem(%clientId, "1Kick " @ Client::getName(%cl), "yes " @ %cl);
- Client::addMenuItem(%clientId, "2Don't kick " @ Client::getName(%cl), "no " @ %cl);
- return;
- }
- else if(%opt == "vcmission" || %opt == "cmission")
- {
- Admin::changeMissionMenu(%clientId, %opt == "cmission");
- return;
- }
- Game::menuRequest(%clientId);
- }
-
- function processMenuKAffirm(%clientId, %opt)
- {
- if(getWord(%opt, 0) == "yes")
- Admin::kick(%clientId, getWord(%opt, 1));
- Game::menuRequest(%clientId);
- }