diff --git a/cfg/sourcemod/pugsetup/all.txt b/cfg/sourcemod/pugsetup/all.txt new file mode 100644 index 00000000..ae11e0c1 --- /dev/null +++ b/cfg/sourcemod/pugsetup/all.txt @@ -0,0 +1 @@ +// add all maps on the server here \ No newline at end of file diff --git a/cfg/sourcemod/pugsetup/competitive.txt b/cfg/sourcemod/pugsetup/competitive.txt new file mode 100644 index 00000000..350ba220 --- /dev/null +++ b/cfg/sourcemod/pugsetup/competitive.txt @@ -0,0 +1 @@ +// add competitive maps here \ No newline at end of file diff --git a/cfg/sourcemod/pugsetup/fun.txt b/cfg/sourcemod/pugsetup/fun.txt new file mode 100644 index 00000000..f7081d43 --- /dev/null +++ b/cfg/sourcemod/pugsetup/fun.txt @@ -0,0 +1 @@ +// add fun maps for casual games here \ No newline at end of file diff --git a/scripting/pugsetup.sp b/scripting/pugsetup.sp index ce15befb..7eedc3bd 100644 --- a/scripting/pugsetup.sp +++ b/scripting/pugsetup.sp @@ -269,7 +269,7 @@ public void OnPluginStart() { "sm_pugsetup_force_defaults", "0", "Whether the default setup options are forced as the setup options (note that admins can override them still)."); g_InstantRunoffVotingCvar = CreateConVar( - "sm_pugsetup_instant_runoff_voting", "1", + "sm_pugsetup_instant_runoff_voting", "0", "If set, map votes will run instant-runoff style where each client selects their top 3 maps in preference order."); g_KnifeConfigCvar = CreateConVar( "sm_pugsetup_knife_cfg", "sourcemod/pugsetup/knife.cfg", @@ -2236,4 +2236,4 @@ stock bool PermissionFromString(const char[] permissionString, Permission& p, } return true; -} +} \ No newline at end of file diff --git a/scripting/pugsetup/mapvote.sp b/scripting/pugsetup/mapvote.sp index a5b01049..bbd31dd5 100644 --- a/scripting/pugsetup/mapvote.sp +++ b/scripting/pugsetup/mapvote.sp @@ -1,9 +1,52 @@ #define RANDOM_MAP_VOTE "-1" // must be in invalid index for array indexing +char mapGroups[][] = { + "competitive.txt", "fun.txt", "maps.txt" +}; + /** * Map voting functions */ public void CreateMapVote() { + StartMappoolVote(); +} +static void StartMappoolVote() { + Menu menu = new Menu(MappoolVoteHandler); + menu.SetTitle("%T", "VoteMenuTitle", LANG_SERVER); + menu.ExitButton = false; + for (int i = 0; i < sizeof(mapGroups); i++) { + char text[64], id[4]; + Format(text, 64, mapGroups[i]); + Format(id, 4, "%i", i); + ReplaceString(text, 64, ".txt", "", false); + AddMenuItem(menu, id, text); + } + VoteMenuToAll(menu, g_MapVoteTimeCvar.IntValue); +} +public int MappoolVoteHandler(Menu menu, MenuAction action, int param1, int param2) { + if (action == MenuAction_VoteEnd) { + int winner = GetMenuInt(menu, param1); + + ServerCommand("sm_pugsetup_maplist %s", mapGroups[winner]); + + char text[PLATFORM_MAX_PATH]; + Format(text, 64, mapGroups[winner]); + ReplaceString(text, 64, ".txt", "", false); + + PrintCenterTextAll("%t","MapVoteWinnerHintText", text); + + CreateTimer(0.5, Timer_Continue, _, TIMER_FLAG_NO_MAPCHANGE); + + } else if (action == MenuAction_End) { + CloseHandle(menu); + } + return 0; +} +public Action Timer_Continue(Handle timer) +{ + CreateMappoolVote(); +} +public void CreateMappoolVote() { if (g_ExcludedMaps.IntValue > 0 && g_MapList.Length > g_PastMaps.Length) { SetupMapVotePool(true); } else { @@ -22,6 +65,7 @@ public void CreateMapVote() { } static void StartMapVote() { + FillMapList(g_MapListCvar, g_MapVotePool); Menu menu = new Menu(MapVoteHandler); menu.SetTitle("%T", "VoteMenuTitle", LANG_SERVER); menu.ExitButton = false; @@ -39,6 +83,8 @@ static void StartMapVote() { } for (int i = 0; i < g_MapVotePool.Length; i++) { + char mapName[64]; + g_MapVotePool.GetString(i, mapName, sizeof(mapName)); AddMapIndexToMenu(menu, g_MapVotePool, i); }