std::string LogDetail::displayCallsign( bz_ApiString callsign ) { std::ostringstream result; result << strlen( callsign.c_str() ) << ":" << callsign.c_str(); return result.str(); }
void initiatekeepaway(bz_eTeamType plyrteam, bz_ApiString plyrcallsign, int plyrID) { keepaway.team = plyrteam; keepaway.callsign = plyrcallsign.c_str(); if (keepaway.callsign.size() > 16) { std::string tofix = truncate(keepaway.callsign, 16); keepaway.callsign = tofix; } keepaway.id = plyrID; keepaway.startTime = bz_getCurrentTime(); keepaway.TTHminutes = (int)(keepaway.adjustedTime/60 + 0.5); keepaway.TTHseconds = 30; keepaway.toldFlagFree = false; bool multipleof30 = false; if ((int)((keepaway.adjustedTime / 30) + 0.5) != (double)(keepaway.adjustedTime / 30)) multipleof30 = false; else multipleof30 = true; if (!multipleof30) { if ((!keepaway.teamPlay || keepaway.team == eRogueTeam)) bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "%s has %s flag; %i secs left!", keepaway.callsign.c_str(), keepaway.flagToKeep.c_str(), (int)keepaway.adjustedTime); else bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "%s (%s) has %s flag; %i secs left!", getTeamColor(keepaway.team), keepaway.callsign.c_str(), keepaway.flagToKeep.c_str(), (int)keepaway.adjustedTime); } if (keepaway.soundEnabled) { bz_APIIntList *playerList = bz_newIntList(); bz_getPlayerIndexList ( playerList ); for ( unsigned int i = 0; i < playerList->size(); i++ ) { bz_BasePlayerRecord *player = bz_getPlayerByIndex(playerList->operator[](i)); if (player) { if ((player->team != keepaway.team || player->team == eRogueTeam) && player->playerID != keepaway.id) bz_sendPlayCustomLocalSound(player->playerID,"flag_alert"); else bz_sendPlayCustomLocalSound(player->playerID,"teamgrab"); } bz_freePlayerRecord(player); } bz_deleteIntList(playerList); } return; }
bool TCTFCommands::handle(int playerID, bz_ApiString _command, bz_ApiString _message, bz_APIStringList * /*_param*/ ) { std::string command = _command.c_str(); std::string message = _message.c_str(); bz_BasePlayerRecord *fromPlayer = bz_getPlayerByIndex(playerID); if (fromPlayer) { if (!fromPlayer->admin) { bz_sendTextMessage(BZ_SERVER, playerID, "You must be admin to use the ctfcaptime commands."); bz_freePlayerRecord(fromPlayer); return true; } bz_freePlayerRecord(fromPlayer); } if (command == "tctfon") { tctf.enabled = true; if (!tctf.timerRunning) ResetTeamData(); bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "Timed CTF is enabled."); return true; } if (command == "tctfoff") { tctf.enabled = false; tctf.timerRunning = false; bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "Timed CTF is disabled."); return true; } if (command == "fairctfon") { tctf.fairCTFEnabled = true; bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "Fair CTF is enabled."); return true; } if (command == "fairctfoff") { tctf.fairCTFEnabled = false; bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "Fair CTF is disabled."); if (!tctf.timerRunning) ResetTeamData(); return true; } if (command == "tctfsoundon") { tctf.soundEnabled = true; bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "Timed CTF sound is enabled."); return true; } if (command == "tctfsoundoff") { tctf.soundEnabled = false; bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "Timed CTF sound is disabled."); return true; } if (command == "tctfstatus") { if (tctf.enabled && !tctf.timerRunning) bz_sendTextMessagef(BZ_SERVER, playerID, "Timed CTF is currently enabled, but not running."); if (tctf.enabled && tctf.timerRunning) bz_sendTextMessagef(BZ_SERVER, playerID, "Timed CTF is currently enabled, and running"); if (!tctf.enabled) bz_sendTextMessagef(BZ_SERVER, playerID, "Timed CTF is currently disabled."); if (!tctf.fairCTFEnabled) bz_sendTextMessagef(BZ_SERVER, playerID, "Fair CTF is currently disabled"); if (tctf.fairCTFEnabled) bz_sendTextMessagef(BZ_SERVER, playerID, "Fair CTF is currently enabled"); if (!tctf.soundEnabled) bz_sendTextMessagef(BZ_SERVER, playerID, "Timed CTF sounds are currently disabled"); if (tctf.soundEnabled) bz_sendTextMessagef(BZ_SERVER, playerID, "Timed CTF sounds are currently enabled"); tctf.adjTime = (int) (tctf.timeLimit / 60 + 0.5); bz_sendTextMessagef(BZ_SERVER, playerID, "CTF capture time is currently set to: %i minutes", tctf.adjTime); return true; } // explicit time command handler: if (command == "tctftime") { double inputvalue = ConvertToInt(message); if (inputvalue > 0) { tctf.timeLimit = inputvalue * 60; tctf.adjTime = (int) (tctf.timeLimit / 60 + 0.5); bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "CTF capture time has been set to %i minutes.", tctf.adjTime); if (!tctf.enabled) bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "(Timed CTF is still disabled)"); ResetTeamData(); return true; } else { bz_sendTextMessagef(BZ_SERVER, playerID, "CTF capture time invalid: must be between 1 and 120 minutes."); return true; } return true; } return false; }
bool MapChangeCommandHandler::handle ( int playerID, bz_ApiString command, bz_ApiString message, bz_APIStringList *params ) { std::string cmd; tolower(command.c_str(),cmd); std::string param; if ( params && params->size() ) param = params->get(0).c_str(); if ( cmd == "mapnext" ) { if (bz_getAdmin (playerID) || bz_hasPerm(playerID,"mapchange")) nextMap(); else bz_sendTextMessage(BZ_SERVER,playerID,"You do not have permision to change maps"); return true; } else if ( cmd == "mapreset" ) { if (bz_getAdmin (playerID) || bz_hasPerm(playerID,"mapchange")) { resetGames(); currentIndex = -1; nextMap(); } else bz_sendTextMessage(BZ_SERVER,playerID,"You do not have permision to reset map rotation"); return true; } else if ( cmd == "mapcyclemode" ) { if (param.size()) { if (bz_getAdmin (playerID) || bz_hasPerm(playerID,"mapchange")) { cycleMode = cycleFromString(param.c_str()); std::string mode = "Map Rotation Mode changed to "; mode += param.c_str(); bz_sendTextMessage(BZ_SERVER,BZ_ALLUSERS,mode.c_str()); } else bz_sendTextMessage(BZ_SERVER,playerID,"You do not have permision to set map modes"); } else { std::string mode = "Current Map Rotation Mode:"; mode += cycleToString(cycleMode); bz_sendTextMessage(BZ_SERVER,playerID,mode.c_str()); } return true; } else if ( cmd == "mapendmode" ) { if (param.size()) { if (bz_getAdmin (playerID) || bz_hasPerm(playerID,"mapchange")) { startTime = bz_getCurrentTime(); endCond = condFromString(param); std::string mode = "Map End Condition changed to "; mode += param; bz_sendTextMessage(BZ_SERVER,BZ_ALLUSERS,mode.c_str()); } else bz_sendTextMessage(BZ_SERVER,playerID,"You do not have permision to set map modes"); } else { std::string mode = "Current End Condtion:"; mode += condToString(endCond); bz_sendTextMessage(BZ_SERVER,playerID,mode.c_str()); } return true; } else if ( cmd == "maplist" ) { bz_sendTextMessage(BZ_SERVER,playerID,"Maps In Rotation"); for (int i = 0; i < (int)gameList.size(); i++ ) bz_sendTextMessage(BZ_SERVER,playerID,gameList[i].mapFile.c_str()); return true; } else if ( cmd == "maplimit" ) { if (endCond == eNoPlayers || endCond == eManual ) { bz_sendTextMessage(BZ_SERVER,playerID,"The currnet mode has no numeric limit"); return true; } if (param.size()) { if (bz_getAdmin (playerID) || bz_hasPerm(playerID,"mapchange")) { std::string mode = "Map Change limit changed to "; if (endCond == eTimedGame) { startTime = bz_getCurrentTime(); timeLimit = atof(param.c_str())*60; mode += param.c_str(); mode += "minutes"; } else { scoreCapLimit = atoi(param.c_str()); mode += param.c_str(); if (endCond == eMaxKillScore) mode += " Kills"; else mode += " Caps"; } bz_sendTextMessage(BZ_SERVER,BZ_ALLUSERS,mode.c_str()); } else { std::string mode = "Map Change limit is "; if (endCond == eTimedGame) mode += format("%f minutes", timeLimit/60.0); else { mode += format("%d", scoreCapLimit); if (endCond == eMaxKillScore) mode += " Kills"; else mode += " Caps"; } bz_sendTextMessage(BZ_SERVER,playerID,"You do not have permision to set map limits"); } } else { std::string mode = "Current End Condtion:"; mode += condToString(endCond); bz_sendTextMessage(BZ_SERVER,playerID,mode.c_str()); } return true; } return false; }
bool KOTHCommands::handle(int playerID, bz_ApiString _command, bz_ApiString _message, bz_APIStringList * /*_param*/ ) { std::string command = _command.c_str(); std::string message = _message.c_str(); const char *kingmessage = _message.c_str(); if (command == "kingsay") { if (koth.id != -1) bz_sendTextMessage(playerID, koth.id, kingmessage); else bz_sendTextMessage(BZ_SERVER, playerID, "There is no one attempting to be king right now."); return true; } bz_BasePlayerRecord *fromPlayer = bz_getPlayerByIndex(playerID); if (fromPlayer) { if (!fromPlayer->admin) { bz_sendTextMessage(BZ_SERVER, playerID, "You must be admin to use the koth commands."); bz_freePlayerRecord(fromPlayer); return true; } bz_freePlayerRecord(fromPlayer); } if (command == "kothon") { koth.enabled = true; bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill is enabled."); return true; } if (command == "kothoff") { koth.enabled = false; bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill is disabled."); return true; } if (command == "kothsoundon") { koth.soundEnabled = true; bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill sounds are enabled."); return true; } if (command == "kothsoundoff") { koth.soundEnabled = false; bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill sounds are disabled."); return true; } if (command == "kothtimemult") { double inputvalue = ConvertToNum(message, 1, 99); if (inputvalue > 0) { koth.timeMult = (inputvalue / 100); bz_sendTextMessagef(BZ_SERVER, playerID, "Auto time multiplier set to %i percent.", (int) (koth.timeMult * 100 + 0.5)); } else { bz_sendTextMessagef(BZ_SERVER, playerID, "Auto time multiplier (%i) must be between 1 and 99 percent.", (int) (koth.timeMult * 100 + 0.5)); } autoTime(); return true; } if (command == "kothtimemultmin") { double inputvalue = ConvertToNum(message, 1, 99); if (inputvalue > 0) { koth.timeMultMin = (inputvalue / 100); bz_sendTextMessagef(BZ_SERVER, playerID, "Auto time multiplier minimum set to %i percent.", (int) (koth.timeMultMin * 100 + 0.5)); } else { bz_sendTextMessagef(BZ_SERVER, playerID, "Auto time multiplier minimum must be between 1 and 99 percent."); } autoTime(); return true; } if (command == "kothstatus") { if (koth.enabled) bz_sendTextMessagef(BZ_SERVER, playerID, "King of the Hill is currently enabled."); if (!koth.enabled) bz_sendTextMessagef(BZ_SERVER, playerID, "King of the Hill is currently disabled."); if (koth.soundEnabled) bz_sendTextMessagef(BZ_SERVER, playerID, "King of the Hill sounds are currently enabled."); if (!koth.soundEnabled) bz_sendTextMessagef(BZ_SERVER, playerID, "King of the Hill sounds are currently disabled."); if (koth.autoTimeOn) bz_sendTextMessagef(BZ_SERVER, playerID, "Automatic time adjustment is currently enabled."); if (!koth.autoTimeOn) bz_sendTextMessagef(BZ_SERVER, playerID, "Automatic time adjustment is currently disabled."); bz_sendTextMessagef(BZ_SERVER, playerID, "Time multiplier = %i percent.", (int) (koth.timeMult * 100 + 0.5)); bz_sendTextMessagef(BZ_SERVER, playerID, "Time multiplier minimum = %i percent.", (int) (koth.timeMultMin * 100 + 0.5)); int AdjTime = (int) (koth.adjustedTime + 0.5); bz_sendTextMessagef(BZ_SERVER, playerID, "King of the Hill hold time is currently set to: %i seconds", AdjTime); return true; } // explicit time command handler: if (command == "kothtime") { double inputvalue = ConvertToNum(message, 1, 7200); if (inputvalue > 0) { koth.TTH = inputvalue; autoTime(); int AdjTime = (int) (inputvalue + 0.5); bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill hold time has been set to %i seconds.", AdjTime); } else { bz_sendTextMessagef(BZ_SERVER, playerID, "King of the Hill hold time invalid: must be between 1 and 7200 seconds."); } autoTime(); return true; } if (command == "kothautotimeon") { koth.autoTimeOn = true; autoTime(); bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill automatic time adjustment on."); return true; } if (command == "kothautotimeoff") { koth.autoTimeOn = false; koth.adjustedTime = koth.TTH; autoTime(); bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "King of the Hill automatic time adjustment off."); return true; } return false; }
bool TimeLimit::SlashCommand ( int playerID, bz_ApiString cmd, bz_ApiString, bz_APIStringList* cmdParams ) { if (strcasecmp (cmd.c_str(), "timelimit")) { return false; } // Check permissions if (! bz_hasPerm(playerID,"TIMELIMIT")) { bz_sendTextMessagef (BZ_SERVER, playerID, "You do not have permission to run the timelimit command"); return true; } // If the server is not configured for manual countdown the timelimit // command can't be used if (! bz_isTimeManualStart()) { bz_sendTextMessagef (BZ_SERVER, playerID, "This server was not configured for manual clock countdowns"); return true; } if (cmdParams->get(0).c_str()[0] == '\0') { bz_sendTextMessagef (BZ_SERVER, playerID, "Usage : /timelimit <minutes>|show|reset"); return true; } // displaying the current timelimit if (strcasecmp(cmdParams->get(0).c_str(),"show") == 0 ) { bz_sendTextMessagef (BZ_SERVER, playerID,"Match duration is set to %.0f minute(s)",(bz_getTimeLimit() / 60)); return true; } // check if there is already a countdown in progress or if a match is // already in progress if ( bz_isCountDownInProgress() ) { bz_sendTextMessagef (BZ_SERVER, playerID, "There is a countdown already in progress, match duration can't be changed now"); return true; } else if ( bz_isCountDownActive() ) { bz_sendTextMessagef (BZ_SERVER, playerID, "A game is already in progress, match duration can't be changed now"); return true; } bz_BasePlayerRecord *playerRecord; playerRecord = bz_getPlayerByIndex(playerID); // resets the timer to the default if (strcasecmp(cmdParams->get(0).c_str(),"reset") == 0 ) { bz_setTimeLimit(saveTimeLimit); bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Match duration reset to %.0f minute(s) by %s",(bz_getTimeLimit() / 60),playerRecord->callsign.c_str()); return true; } unsigned i, nonumber=0; for (i=0; i < strlen(cmdParams->get(0).c_str()); i++) { if (isdigit(cmdParams->get(0).c_str()[i]) == 0) nonumber=1; } if (nonumber == 0 ) { float limit = (float)atof(cmdParams->get(0).c_str()); // Don't allow timelimit being equal or lower then 0 if (limit > 0 ) { if (! isValidTime(limit)) { showMatchDurations(playerID); return true; } bz_setTimeLimit(limit * 60); bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Match duration set to %.0f minute(s) by %s",(bz_getTimeLimit() / 60),playerRecord->callsign.c_str()); } else { bz_sendTextMessagef (BZ_SERVER, playerID, "Match duration can't be equal or lower then 0"); return true; } } else { bz_sendTextMessagef (BZ_SERVER, playerID, "Not a correct value"); return true; } return true; }
bool KeepAwayCommands::SlashCommand ( int playerID, bz_ApiString _command, bz_ApiString _message, bz_APIStringList * /*_param*/ ) { std::string command = _command.c_str(); std::string message = _message.c_str(); const char* keepermessage = _message.c_str(); if ( command == "kas" ) { if (keepaway.id != -1) bz_sendTextMessage (playerID, keepaway.id, keepermessage); else bz_sendTextMessage(BZ_SERVER, playerID, "There is no one keeping the flag right now."); return true; } if ( command == "kaf" ) { if (keepaway.id == -1) bz_sendTextMessagef (BZ_SERVER, playerID, "The Keep Away flag is: %s", convertFlag(keepaway.flagToKeep).c_str()); else bz_sendTextMessagef (BZ_SERVER, playerID, "%s has Keep Away flag: %s", keepaway.callsign.c_str(), convertFlag(keepaway.flagToKeep).c_str()); return true; } bz_BasePlayerRecord *fromPlayer = bz_getPlayerByIndex(playerID); if (fromPlayer) { if (!fromPlayer->admin) { bz_sendTextMessage(BZ_SERVER, playerID, "You must be admin to use the keepaway commands."); bz_freePlayerRecord(fromPlayer); return true; } bz_freePlayerRecord(fromPlayer); } if ( command == "kasoundoff" ) { keepaway.soundEnabled = false; bz_sendTextMessage (BZ_SERVER, playerID, "Keep Away sounds are disabled."); return true; } if ( command == "kasoundon" ) { keepaway.soundEnabled = true; bz_sendTextMessage (BZ_SERVER, playerID, "Keep Away sounds are enabled."); return true; } if ( command == "kaflagresetoff" ) { keepaway.flagResetEnabled = false; bz_sendTextMessage (BZ_SERVER, playerID, "Keep Away flag reset is disabled."); return true; } if ( command == "kaflagreseton" ) { keepaway.flagResetEnabled = true; bz_sendTextMessage (BZ_SERVER, playerID, "Keep Away flag reset is enabled."); return true; } if ( command == "kaf+" ) { if (!keepaway.forcedFlags) // this will always create an open spot for getFlag(), if it's needed bz_removePlayerFlag (keepaway.id); keepaway.id = -1; keepaway.team = eNoTeam; keepaway.toldFlagFree = false; keepaway.flagToKeep = getFlag(); keepaway.lastReminder = bz_getCurrentTime(); bz_sendTextMessagef(BZ_SERVER, playerID, "Keep Away flag advanced to: %s", convertFlag(keepaway.flagToKeep).c_str()); return true; } if ( command == "kaon") { keepaway.enabled = true; bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Keep Away is enabled."); return true; } if ( command == "kaoff") { keepaway.enabled = false; bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Keep Away is disabled."); return true; } if ( command == "katimemult") { double inputvalue = ConvertToNum(message, 1, 99); if (inputvalue > 0) { keepaway.timeMult = (inputvalue/100); bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away auto time multiplier set to %i percent.", (int)(keepaway.timeMult*100 + 0.5)); } else bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away auto time multiplier must be between 1 and 99 percent.", (int)(keepaway.timeMult*100 + 0.5)); autoTime(); return true; } if ( command == "katimemultmin") { double inputvalue = ConvertToNum(message, 1, 99); if (inputvalue > 0) { keepaway.timeMultMin = (inputvalue/100); bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away auto time multiplier minimum set to %i percent.", (int)(keepaway.timeMultMin*100 + 0.5)); } else bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away auto time multiplier minimum must be between 1 and 99 percent."); autoTime(); return true; } if ( command == "kastatus") { if (keepaway.enabled) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away is currently enabled."); if (!keepaway.enabled) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away is currently disabled."); if (keepaway.autoTimeOn) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away automatic time adjustment is currently enabled."); if (!keepaway.autoTimeOn) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away automatic time adjustment is currently disabled."); bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away time multiplier = %i percent.", (int)(keepaway.timeMult*100 + 0.5)); bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away time multiplier minimum = %i percent.", (int)(keepaway.timeMultMin*100 + 0.5)); int AdjTime = (int)(keepaway.adjustedTime + 0.5); bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away hold time is currently set to: %i seconds", AdjTime); if (keepaway.forcedFlags) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away forced flags is enabled."); if (!keepaway.forcedFlags) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away forced flags is disabled."); if (keepaway.soundEnabled) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away sounds are enabled."); if (!keepaway.soundEnabled) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away sounds are disabled."); if (keepaway.flagResetEnabled) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away flag reset is enabled."); if (!keepaway.flagResetEnabled) bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away flag reset is disabled."); return true; } // explicit time command handler: if ( command == "katime" ) { double inputvalue = ConvertToNum(message, 1, 7200); if (inputvalue > 0 ) { keepaway.TTH = inputvalue; autoTime(); int AdjTime = (int)(inputvalue + 0.5); bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Keep Away hold time has been set to %i seconds.", AdjTime); } else bz_sendTextMessagef (BZ_SERVER, playerID, "Keep Away hold time invalid: must be between 1 and 7200 seconds."); autoTime(); return true; } if ( command == "kaautotimeon") { keepaway.autoTimeOn = true; autoTime(); bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Keep Away automatic time adjustment on."); return true; } if ( command == "kaautotimeoff") { keepaway.autoTimeOn = false; keepaway.adjustedTime = keepaway.TTH; autoTime(); bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Keep Away automatic time adjustment off."); return true; } if ( command == "kaffon") { keepaway.forcedFlags = true; bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Forced flags on."); return true; } if ( command == "kaffoff") { keepaway.forcedFlags = false; bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Forced flags off."); return true; } return false; }
bool LastChatCommand::SlashCommand ( int playerID, bz_ApiString _command, bz_ApiString _message, bz_APIStringList * /*_param*/ ) { std::string command = _command.c_str(); std::string message = _message.c_str(); bz_BasePlayerRecord *fromPlayer = bz_getPlayerByIndex(playerID); if (!fromPlayer) return false; if ( !fromPlayer->admin ) { bz_sendTextMessage(BZ_SERVER,playerID,"You must be admin to use the ChatHistory plugin"); bz_freePlayerRecord(fromPlayer); return true; } bz_freePlayerRecord(fromPlayer); if ( command == "last") { std::vector<std::string> params = tokenize(message,std::string(" "),0,true); if ( params.size() <2) { bz_sendTextMessage(BZ_SERVER,playerID,"Usage: /last <NUMBER OF LINES> <CALLSIGN>"); return true; } unsigned int numLines = (unsigned int)atoi(params[0].c_str()); if ( numLines == 0 ) numLines = 5; std::map<std::string,tvChatHistory>::iterator itr = chatHistories.find(tolower(params[1])); if ( itr == chatHistories.end() || !itr->second.size()) { bz_sendTextMessage(BZ_SERVER,playerID,"That player has no chat history."); return true; } tvChatHistory &history = itr->second; if ( history.size() < numLines ) numLines = (unsigned int )history.size(); bz_sendTextMessage(BZ_SERVER,playerID,format("Last %d message for %s",numLines,params[1].c_str()).c_str()); for ( unsigned int i = 0; i < numLines-1; i++ ) { std::string chatItem = history[history.size()-i]; bz_sendTextMessage(BZ_SERVER,playerID,format("%d<%s> %s",i,params[1].c_str(),chatItem.c_str()).c_str()); } return true; } if ( command == "flushchat") { chatHistories.clear(); bz_sendTextMessage(BZ_SERVER,playerID,"Chat History has been flushed"); return true; } return false; }
bool flagResetTimerHandler::SlashCommand (int playerID, bz_ApiString _command, bz_ApiString _message, bz_APIStringList *params) { std::string command = _command.c_str(); std::string message = _message.c_str(); bz_BasePlayerRecord *playerdata; playerdata = bz_getPlayerByIndex(playerID); if(command == "flagresetunused" && (bz_hasPerm(playerID, "flagMaster")||bz_hasPerm(playerID, "FLAGMASTER"))) { if(gameStyle=="ctf") { for(unsigned int i = getNumTeams(); i < bz_getNumFlags(); i++) { if(bz_flagPlayer(i)==-1) bz_resetFlag(i); } } else { for(unsigned int i = 0; i < bz_getNumFlags(); i++) { if(bz_flagPlayer(i)==-1) bz_resetFlag(i); } } nextReset = bz_getCurrentTime()+(timeLimitMinutes*60); return 1; } else if(command == "frsettime" && (bz_hasPerm(playerID, "flagMaster")||bz_hasPerm(playerID, "FLAGMASTER"))) { double invalue = ConvertToInteger(message); if (invalue > 0) { timeLimitMinutes=invalue; bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Flag reset time has been set to %i minutes by %s.", timeLimitMinutes,playerdata->callsign.c_str()); nextReset = bz_getCurrentTime()+(timeLimitMinutes*60); } else { bz_sendTextMessagef (BZ_SERVER, playerID, "Flag reset time invalid: must be between 1 and 120 minutes."); } return 1; } else if(command == "frcurrenttime") { bz_sendTextMessagef (BZ_SERVER, playerID, "Current flag reset time is set to: %i minute(s).",timeLimitMinutes); } else { bz_sendTextMessage(BZ_SERVER,playerID,"You do not have the permission to run the flag reset commands."); } bz_freePlayerRecord(playerdata); return 1; }
bool TeamFlagResetIOHandler::SlashCommand ( int playerID, bz_ApiString _command, bz_ApiString _message, bz_APIStringList * /*_param*/ ) { std::string command = _command.c_str(); std::string message = _message.c_str(); bz_BasePlayerRecord *fromPlayer = bz_getPlayerByIndex(playerID); if (fromPlayer) { if (!fromPlayer->admin) { bz_sendTextMessage(BZ_SERVER,playerID,"You must be admin to use the teamflagreset commands."); bz_freePlayerRecord(fromPlayer); return true; } bz_freePlayerRecord(fromPlayer); } if ( command == "tfrtime") { double invalue = ConvertToInteger(message); if (invalue > 0){ tfr.timerOff = false; tfr.idleTime = invalue * 60; int AdjTime = (int)(tfr.idleTime / 60 + 0.5); bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Team flag idle time has been set to %i minutes.", AdjTime); ResetFlagData(); return true; } else{ bz_sendTextMessagef (BZ_SERVER, playerID, "Team flag idle time invalid: must be between 1 and 120 minutes."); return true; } return true; } if ( command == "tfroff") { tfr.timerOff = true; bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Team flag reset is disabled."); return true; } if ( command == "tfron") { tfr.timerOff = false; ResetFlagData(); bz_sendTextMessagef (BZ_SERVER, BZ_ALLUSERS, "Team flag reset is enabled."); return true; } if ( command == "tfrstatus") { if (tfr.timerOff) bz_sendTextMessagef (BZ_SERVER, playerID, "Team flag reset is disabled."); else bz_sendTextMessagef (BZ_SERVER, playerID, "Team flag reset is enabled."); int AdjTime = (int)(tfr.idleTime / 60 + 0.5); bz_sendTextMessagef (BZ_SERVER, playerID, "Team flag idle time is: %i minutes.", AdjTime); return true; } return false; }