From 962ea1bcf332c8e24589cc83ba2ef90c56d48816 Mon Sep 17 00:00:00 2001 From: The Crimson Tautology Date: Tue, 7 May 2013 20:26:13 -0400 Subject: [PATCH 1/5] Add nomgrep action --- .../scripting/nominations_extended.sp | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/addons/sourcemod/scripting/nominations_extended.sp b/addons/sourcemod/scripting/nominations_extended.sp index 298f880..300497e 100644 --- a/addons/sourcemod/scripting/nominations_extended.sp +++ b/addons/sourcemod/scripting/nominations_extended.sp @@ -87,6 +87,9 @@ public OnPluginStart() RegConsoleCmd("say_team", Command_Say); RegConsoleCmd("sm_nominate", Command_Nominate); + + RegConsoleCmd("sm_nomgrep", Command_Nomgrep); + RegConsoleCmd("sm_nomsearch", Command_Nomgrep); RegAdminCmd("sm_nominate_addmap", Command_Addmap, ADMFLAG_CHANGEMAP, "sm_nominate_addmap - Forces a map to be on the next mapvote."); @@ -283,6 +286,39 @@ public Action:Command_Nominate(client, args) return Plugin_Continue; } +public Action:Command_Nomgrep(client, args) +{ + if (!client || !IsNominateAllowed(client)) + { + return Plugin_Handled; + } + + if (args == 0) + { + ReplyToCommand(client, "[NE] Usage: sm_nomgrep "); + } + + decl String:search[MAP_NAME_LENGTH]; + GetCmdArg(1, search, sizeof(search)); + + return Plugin_Continue; +} + +BuildSearchMenu(client, String:search[MAP_NAME_LENGTH]) +{ + + new Handle:tmpMenu=CreateMenu(Handler_MapSelectMenu, MENU_ACTIONS_DEFAULT|MenuAction_DrawItem|MenuAction_DisplayItem); + new String:tmpMap[MAP_NAME_LENGTH]; + new tmpStyle; + + //For each map in the normal map menu + for (new i = 0; i < GetMenuItemCount(g_MapMenu); i++) + { + GetMenuItem(g_MapMenu, i, tmpMap, MAP_NAME_LENGTH); + } +} + + AttemptNominate(client) { SetMenuTitle(g_MapMenu, "%t", "Nominate Title", client); @@ -516,4 +552,4 @@ stock bool:IsNominateAllowed(client) } return true; -} \ No newline at end of file +} From 7d9effb0f6202b20792bc6d552773d1b1d6a7070 Mon Sep 17 00:00:00 2001 From: The Crimson Tautology Date: Tue, 7 May 2013 20:37:14 -0400 Subject: [PATCH 2/5] Finished the map search builder --- .../scripting/nominations_extended.sp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/addons/sourcemod/scripting/nominations_extended.sp b/addons/sourcemod/scripting/nominations_extended.sp index 300497e..c5d04f0 100644 --- a/addons/sourcemod/scripting/nominations_extended.sp +++ b/addons/sourcemod/scripting/nominations_extended.sp @@ -304,6 +304,7 @@ public Action:Command_Nomgrep(client, args) return Plugin_Continue; } +//Build a menu of maps in the maplist that also contain the search key. BuildSearchMenu(client, String:search[MAP_NAME_LENGTH]) { @@ -315,7 +316,24 @@ BuildSearchMenu(client, String:search[MAP_NAME_LENGTH]) for (new i = 0; i < GetMenuItemCount(g_MapMenu); i++) { GetMenuItem(g_MapMenu, i, tmpMap, MAP_NAME_LENGTH); + + if(StrContains(tmpMap, search, false) >= 0) + { + AddMenuItem(tmpMenu, tmpMap, tmpMap); + } + } + + if(GetMenuItemCount(tmpMenu) <= 0) + { + ReplyToCommand(client, "%t", "Map was not found", mapname); } + else + { + SetMenuTitle(tmpMenu, "%t", "Nominate Title", client); + DisplayMenu(tmpMenu, client, MENU_TIME_FOREVER); + } + + return; } From bba76048287a0fa38d5af13d8a9be7d0b03ad4fd Mon Sep 17 00:00:00 2001 From: The Crimson Tautology Date: Tue, 7 May 2013 20:49:46 -0400 Subject: [PATCH 3/5] Linked nomgrep to the build search menu function --- addons/sourcemod/scripting/nominations_extended.sp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/sourcemod/scripting/nominations_extended.sp b/addons/sourcemod/scripting/nominations_extended.sp index c5d04f0..fe356bc 100644 --- a/addons/sourcemod/scripting/nominations_extended.sp +++ b/addons/sourcemod/scripting/nominations_extended.sp @@ -301,6 +301,8 @@ public Action:Command_Nomgrep(client, args) decl String:search[MAP_NAME_LENGTH]; GetCmdArg(1, search, sizeof(search)); + BuildSearchMenu(client, search); + return Plugin_Continue; } From e7017978c6e9c829852a03861d0aa332a6513a06 Mon Sep 17 00:00:00 2001 From: The Crimson Tautology Date: Tue, 7 May 2013 21:05:14 -0400 Subject: [PATCH 4/5] Fixed typo --- addons/sourcemod/scripting/nominations_extended.sp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sourcemod/scripting/nominations_extended.sp b/addons/sourcemod/scripting/nominations_extended.sp index fe356bc..c96c84d 100644 --- a/addons/sourcemod/scripting/nominations_extended.sp +++ b/addons/sourcemod/scripting/nominations_extended.sp @@ -327,7 +327,7 @@ BuildSearchMenu(client, String:search[MAP_NAME_LENGTH]) if(GetMenuItemCount(tmpMenu) <= 0) { - ReplyToCommand(client, "%t", "Map was not found", mapname); + ReplyToCommand(client, "%t", "Map was not found", search); } else { From 00b83b0139f24ab7b90b0e9f912238cb570959db Mon Sep 17 00:00:00 2001 From: The Crimson Tautology Date: Sun, 19 May 2013 13:25:49 -0400 Subject: [PATCH 5/5] Fix tabs/spaces issue --- .../scripting/nominations_extended.sp | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/addons/sourcemod/scripting/nominations_extended.sp b/addons/sourcemod/scripting/nominations_extended.sp index c96c84d..9c423a9 100644 --- a/addons/sourcemod/scripting/nominations_extended.sp +++ b/addons/sourcemod/scripting/nominations_extended.sp @@ -25,7 +25,7 @@ * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software * by the Valve Corporation. You must obey the GNU General Public License in * all respects for all other code used. Additionally, AlliedModders LLC grants - * this exception to all derivative works. AlliedModders LLC defines further + * this exception to all derivative works. AlliedModders LLC defines further * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * or . * @@ -88,8 +88,8 @@ public OnPluginStart() RegConsoleCmd("sm_nominate", Command_Nominate); - RegConsoleCmd("sm_nomgrep", Command_Nomgrep); - RegConsoleCmd("sm_nomsearch", Command_Nomgrep); + RegConsoleCmd("sm_nomgrep", Command_Nomgrep); + RegConsoleCmd("sm_nomsearch", Command_Nomgrep); RegAdminCmd("sm_nominate_addmap", Command_Addmap, ADMFLAG_CHANGEMAP, "sm_nominate_addmap - Forces a map to be on the next mapvote."); @@ -288,52 +288,52 @@ public Action:Command_Nominate(client, args) public Action:Command_Nomgrep(client, args) { - if (!client || !IsNominateAllowed(client)) - { - return Plugin_Handled; - } + if (!client || !IsNominateAllowed(client)) + { + return Plugin_Handled; + } - if (args == 0) - { - ReplyToCommand(client, "[NE] Usage: sm_nomgrep "); - } + if (args == 0) + { + ReplyToCommand(client, "[NE] Usage: sm_nomgrep "); + } - decl String:search[MAP_NAME_LENGTH]; - GetCmdArg(1, search, sizeof(search)); + decl String:search[MAP_NAME_LENGTH]; + GetCmdArg(1, search, sizeof(search)); - BuildSearchMenu(client, search); + BuildSearchMenu(client, search); - return Plugin_Continue; + return Plugin_Continue; } //Build a menu of maps in the maplist that also contain the search key. BuildSearchMenu(client, String:search[MAP_NAME_LENGTH]) { - new Handle:tmpMenu=CreateMenu(Handler_MapSelectMenu, MENU_ACTIONS_DEFAULT|MenuAction_DrawItem|MenuAction_DisplayItem); - new String:tmpMap[MAP_NAME_LENGTH]; - new tmpStyle; + new Handle:tmpMenu=CreateMenu(Handler_MapSelectMenu, MENU_ACTIONS_DEFAULT|MenuAction_DrawItem|MenuAction_DisplayItem); + new String:tmpMap[MAP_NAME_LENGTH]; + new tmpStyle; - //For each map in the normal map menu - for (new i = 0; i < GetMenuItemCount(g_MapMenu); i++) - { - GetMenuItem(g_MapMenu, i, tmpMap, MAP_NAME_LENGTH); + //For each map in the normal map menu + for (new i = 0; i < GetMenuItemCount(g_MapMenu); i++) + { + GetMenuItem(g_MapMenu, i, tmpMap, MAP_NAME_LENGTH); - if(StrContains(tmpMap, search, false) >= 0) - { - AddMenuItem(tmpMenu, tmpMap, tmpMap); - } - } + if(StrContains(tmpMap, search, false) >= 0) + { + AddMenuItem(tmpMenu, tmpMap, tmpMap); + } + } - if(GetMenuItemCount(tmpMenu) <= 0) - { + if(GetMenuItemCount(tmpMenu) <= 0) + { ReplyToCommand(client, "%t", "Map was not found", search); - } - else - { - SetMenuTitle(tmpMenu, "%t", "Nominate Title", client); - DisplayMenu(tmpMenu, client, MENU_TIME_FOREVER); - } + } + else + { + SetMenuTitle(tmpMenu, "%t", "Nominate Title", client); + DisplayMenu(tmpMenu, client, MENU_TIME_FOREVER); + } return; }