#pragma semicolon 1 #pragma newdecls required #include #include #define VOTE_NO "###no###" #define VOTE_YES "###yes###" ConVar g_cvarExtendVoteTime = null; ConVar g_cvarExtendVotePercent = null; ConVar g_cvarMpMaxRounds = null; ConVar g_cvarMpFragLimit = null; ConVar g_cvarMpWinLimit = null; ConVar g_cvarMpTimeLimit = null; bool g_bGameOver = false; Address g_pGameOver; public Plugin myinfo = { name = "Map extend tools", author = "Obus + BotoX", description = "Adds map extension commands.", version = "1.0", url = "" }; public void OnPluginStart() { LoadTranslations("common.phrases"); LoadTranslations("basevotes.phrases"); g_cvarMpMaxRounds = FindConVar("mp_maxrounds"); g_cvarMpFragLimit = FindConVar("mp_fraglimit"); g_cvarMpWinLimit = FindConVar("mp_winlimit"); g_cvarMpTimeLimit = FindConVar("mp_timelimit"); g_cvarExtendVoteTime = CreateConVar("sm_extendvote_time", "15", "Time that will be added to mp_timelimit shall the extend vote succeed", FCVAR_NONE, true, 1.0); g_cvarExtendVotePercent = CreateConVar("sm_extendvote_percent", "0.6", "Percentage of \"yes\" votes required to consider the vote successful", FCVAR_NONE, true, 0.05, true, 1.0); AutoExecConfig(true, "plugin.Extend"); if (g_cvarMpMaxRounds != null) RegAdminCmd("sm_extend_rounds", Command_Extend_Rounds, ADMFLAG_GENERIC, "Add more rounds to mp_maxrounds"); else LogMessage("Failed to find \"mp_maxrounds\" console variable, related commands will be disabled."); if (g_cvarMpFragLimit != null) RegAdminCmd("sm_extend_frags", Command_Extend_Frags, ADMFLAG_GENERIC, "Add more frags to mp_fraglimit"); else LogMessage("Failed to find \"mp_fraglimit\" console variable, related commands will be disabled."); if (g_cvarMpWinLimit != null) RegAdminCmd("sm_extend_wins", Command_Extend_Wins, ADMFLAG_GENERIC, "Add more wins to mp_winlimit"); else LogMessage("Failed to find \"mp_winlimit\" console variable, related commands will be disabled."); if (g_cvarMpTimeLimit != null) { RegAdminCmd("sm_extend", Command_Extend, ADMFLAG_GENERIC, "Add more time to mp_timelimit"); RegAdminCmd("sm_extend_time", Command_Extend, ADMFLAG_GENERIC, "Add more time to mp_timelimit"); RegAdminCmd("sm_extendvote", Command_ExtendVote, ADMFLAG_GENERIC, "sm_extendvote [time] - Start an extendvote"); RegAdminCmd("sm_voteextend", Command_ExtendVote, ADMFLAG_GENERIC, "sm_voteextend [time] - Start an extendvote"); RegAdminCmd("sm_extend_vote", Command_ExtendVote, ADMFLAG_GENERIC, "sm_extend_vote [time] - Start an extendvote"); } else { LogMessage("Failed to find \"mp_timelimit\" console variable, related commands will be disabled."); } Handle hGameConf = LoadGameConfigFile("Extend.games"); if(hGameConf == INVALID_HANDLE) { g_bGameOver = false; LogError("Couldn't load Extend.games game config! GameOver cancel disabled."); return; } if(!(g_pGameOver = GameConfGetAddress(hGameConf, "GameOver"))) { g_bGameOver = false; delete hGameConf; LogError("Couldn't get GameOver address from game config! GameOver cancel disabled."); return; } g_bGameOver = true; delete hGameConf; } public Action Command_Extend_Rounds(int client, int argc) { if (argc < 1) { ReplyToCommand(client, "[SM] Usage: sm_extend_rounds "); return Plugin_Handled; } char sArgs[16]; GetCmdArg(1, sArgs, sizeof(sArgs)); if (sArgs[0] == '-') { int iRoundsToDeduct; if (!StringToIntEx(sArgs[1], iRoundsToDeduct)) { ReplyToCommand(client, "[SM] Invalid value"); return Plugin_Handled; } g_cvarMpMaxRounds.IntValue -= iRoundsToDeduct; LogAction(client, -1, "\"%L\" deducted \"%d\" rounds from \"mp_maxrounds\"", client, iRoundsToDeduct); return Plugin_Handled; } int iRoundsToAdd; if (!StringToIntEx(sArgs, iRoundsToAdd)) { ReplyToCommand(client, "[SM] Invalid value"); return Plugin_Handled; } g_cvarMpMaxRounds.IntValue += iRoundsToAdd; CancelGameOver(); LogAction(client, -1, "\"%L\" added \"%d\" rounds to \"mp_maxrounds\"", client, iRoundsToAdd); return Plugin_Handled; } public Action Command_Extend_Frags(int client, int argc) { if (argc < 1) { ReplyToCommand(client, "[SM] Usage: sm_extend_frags "); return Plugin_Handled; } char sArgs[16]; GetCmdArg(1, sArgs, sizeof(sArgs)); if (sArgs[0] == '-') { int iFragsToDeduct; if (!StringToIntEx(sArgs[1], iFragsToDeduct)) { ReplyToCommand(client, "[SM] Invalid value"); return Plugin_Handled; } g_cvarMpFragLimit.IntValue -= iFragsToDeduct; LogAction(client, -1, "\"%L\" deducted \"%d\" frags from \"mp_fraglimit\"", client, iFragsToDeduct); return Plugin_Handled; } int iFragsToAdd; if (!StringToIntEx(sArgs, iFragsToAdd)) { ReplyToCommand(client, "[SM] Invalid value"); return Plugin_Handled; } g_cvarMpFragLimit.IntValue += iFragsToAdd; CancelGameOver(); LogAction(client, -1, "\"%L\" added \"%d\" frags to \"mp_fraglimit\"", client, iFragsToAdd); return Plugin_Handled; } public Action Command_Extend_Wins(int client, int argc) { if (argc < 1) { ReplyToCommand(client, "[SM] Usage: sm_extend_wins "); return Plugin_Handled; } char sArgs[16]; GetCmdArg(1, sArgs, sizeof(sArgs)); if (sArgs[0] == '-') { int iWinsToDeduct; if (!StringToIntEx(sArgs[1], iWinsToDeduct)) { ReplyToCommand(client, "[SM] Invalid value"); return Plugin_Handled; } g_cvarMpWinLimit.IntValue -= iWinsToDeduct; LogAction(client, -1, "\"%L\" deducted \"%d\" wins from \"mp_winlimit\"", client, iWinsToDeduct); return Plugin_Handled; } int iWinsToAdd; if (!StringToIntEx(sArgs, iWinsToAdd)) { ReplyToCommand(client, "[SM] Invalid value"); return Plugin_Handled; } g_cvarMpWinLimit.IntValue += iWinsToAdd; CancelGameOver(); LogAction(client, -1, "\"%L\" added \"%d\" wins to \"mp_winlimit\"", client, iWinsToAdd); return Plugin_Handled; } public Action Command_Extend(int client, int argc) { if (argc < 1) { ReplyToCommand(client, "[SM] Usage: sm_extend