Skip to content
This repository was archived by the owner on Jan 12, 2022. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 58 additions & 2 deletions addons/sourcemod/scripting/nominations_extended.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http://www.sourcemod.net/license.php>.
*
Expand Down Expand Up @@ -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 <mapname> - Forces a map to be on the next mapvote.");

Expand Down Expand Up @@ -283,6 +286,59 @@ 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 <search key>");
}

decl String:search[MAP_NAME_LENGTH];
GetCmdArg(1, search, sizeof(search));

BuildSearchMenu(client, search);

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;

//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(GetMenuItemCount(tmpMenu) <= 0)
{
ReplyToCommand(client, "%t", "Map was not found", search);
}
else
{
SetMenuTitle(tmpMenu, "%t", "Nominate Title", client);
DisplayMenu(tmpMenu, client, MENU_TIME_FOREVER);
}

return;
}


AttemptNominate(client)
{
SetMenuTitle(g_MapMenu, "%t", "Nominate Title", client);
Expand Down Expand Up @@ -516,4 +572,4 @@ stock bool:IsNominateAllowed(client)
}

return true;
}
}