mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-06 18:08:26 +00:00
Added replay deletion to admin menu.
This commit is contained in:
parent
c1b93bfdff
commit
799d6ba65b
@ -24,6 +24,7 @@
|
||||
|
||||
#undef REQUIRE_PLUGIN
|
||||
#include <shavit>
|
||||
#include <adminmenu>
|
||||
|
||||
#undef REQUIRE_EXTENSIONS
|
||||
#include <cstrike>
|
||||
@ -129,6 +130,10 @@ char gS_ChatStrings[CHATSETTINGS_SIZE][128];
|
||||
// replay settings
|
||||
char gS_ReplayStrings[REPLAYSTRINGS_SIZE][MAX_NAME_LENGTH];
|
||||
|
||||
// admin menu
|
||||
TopMenu gH_AdminMenu = null;
|
||||
TopMenuObject gH_TimerCommands = INVALID_TOPMENUOBJECT;
|
||||
|
||||
// database related things
|
||||
Database gH_SQL = null;
|
||||
char gS_MySQLPrefix[32];
|
||||
@ -217,6 +222,12 @@ public void OnPluginStart()
|
||||
|
||||
AutoExecConfig();
|
||||
|
||||
// admin menu
|
||||
if(LibraryExists("adminmenu") && ((gH_AdminMenu = GetAdminTopMenu()) != null))
|
||||
{
|
||||
OnAdminMenuReady(gH_AdminMenu);
|
||||
}
|
||||
|
||||
// hooks
|
||||
HookEvent("player_spawn", Player_Event, EventHookMode_Pre);
|
||||
HookEvent("player_death", Player_Event, EventHookMode_Pre);
|
||||
@ -250,6 +261,60 @@ public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] n
|
||||
}
|
||||
}
|
||||
|
||||
public void OnAdminMenuCreated(Handle topmenu)
|
||||
{
|
||||
if(gH_AdminMenu == null || (topmenu == gH_AdminMenu && gH_TimerCommands != INVALID_TOPMENUOBJECT))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gH_TimerCommands = gH_AdminMenu.AddCategory("Timer Commands", CategoryHandler, "shavit_admin", ADMFLAG_RCON);
|
||||
}
|
||||
|
||||
public void CategoryHandler(Handle topmenu, TopMenuAction action, TopMenuObject object_id, int param, char[] buffer, int maxlength)
|
||||
{
|
||||
if(action == TopMenuAction_DisplayTitle)
|
||||
{
|
||||
FormatEx(buffer, maxlength, "%T:", "TimerCommands", param);
|
||||
}
|
||||
|
||||
else if(action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
FormatEx(buffer, maxlength, "%T", "TimerCommands", param);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnAdminMenuReady(Handle topmenu)
|
||||
{
|
||||
if((gH_AdminMenu = GetAdminTopMenu()) != null)
|
||||
{
|
||||
if(gH_TimerCommands == INVALID_TOPMENUOBJECT)
|
||||
{
|
||||
gH_TimerCommands = gH_AdminMenu.FindCategory("Timer Commands");
|
||||
|
||||
if(gH_TimerCommands == INVALID_TOPMENUOBJECT)
|
||||
{
|
||||
OnAdminMenuCreated(topmenu);
|
||||
}
|
||||
}
|
||||
|
||||
gH_AdminMenu.AddItem("sm_deletereplay", AdminMenu_DeleteReplay, gH_TimerCommands, "sm_deletereplay", ADMFLAG_RCON);
|
||||
}
|
||||
}
|
||||
|
||||
public void AdminMenu_DeleteReplay(Handle topmenu, TopMenuAction action, TopMenuObject object_id, int param, char[] buffer, int maxlength)
|
||||
{
|
||||
if(action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
FormatEx(buffer, maxlength, "%t", "DeleteReplayAdminMenu");
|
||||
}
|
||||
|
||||
else if(action == TopMenuAction_SelectOption)
|
||||
{
|
||||
Command_DeleteReplay(param, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public int Native_GetReplayBotFirstFrame(Handle handler, int numParams)
|
||||
{
|
||||
SetNativeCellRef(2, gF_StartTick[GetNativeCell(1)]);
|
||||
|
||||
@ -116,7 +116,6 @@ public void OnAllPluginsLoaded()
|
||||
{
|
||||
if(gH_SQL == null)
|
||||
{
|
||||
|
||||
Shavit_OnDatabaseLoaded();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
"Phrases"
|
||||
{
|
||||
// ---------- Menus ---------- //
|
||||
"DeleteReplayAdminMenu"
|
||||
{
|
||||
"en" "Delete replay"
|
||||
}
|
||||
"DeleteReplayMenuTitle"
|
||||
{
|
||||
"en" "Delete a replay:"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user