Skip to content

Commit

Permalink
Merge pull request #101 from R1KO/fix_adminmenu_access
Browse files Browse the repository at this point in the history
Fix access to manage vip in admin menu & cmds
  • Loading branch information
R1KO authored Apr 10, 2022
2 parents aa21fae + 74bc5f9 commit c55733f
Show file tree
Hide file tree
Showing 13 changed files with 277 additions and 323 deletions.
61 changes: 11 additions & 50 deletions addons/sourcemod/scripting/VIP_Core.sp
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,17 @@
#include <clientprefs>

#if !defined VIP_VERSION
#define VIP_VERSION "3.0.2 R"
#define VIP_VERSION "3.0.3 R"
#endif


#define DEBUG_MODE 0 // Режим отладки
#define DEBUG_MODE 0 // Режим отладки

#define USE_ADMINMENU 1 // Включение админ-меню для управления VIP
#define USE_ADMINMENU 1 // Включение админ-меню для управления VIP

#define USE_MORE_SERVERS 1 // Включить/Отключить режим при котором если ID сервера у игрока 0 - то VIP будет работать на всех серверах


#if USE_ADMINMENU 1
#undef REQUIRE_PLUGIN
#include <adminmenu>
#define REQUIRE_PLUGIN
#endif

public Plugin myinfo =
{
name = "[VIP] Core",
Expand Down Expand Up @@ -68,9 +62,9 @@ public void OnPluginStart()
LoadTranslations("common.phrases");
LoadTranslations("core.phrases");

g_iMaxPageItems = GetMaxPageItems(GetMenuStyleHandle(MenuStyle_Default));
g_hFeaturesArray = new ArrayList(ByteCountToCells(FEATURE_NAME_LENGTH));
GLOBAL_TRIE = new StringMap();
g_iMaxPageItems = GetMaxPageItems(GetMenuStyleHandle(MenuStyle_Default));
g_hFeaturesArray = new ArrayList(ByteCountToCells(FEATURE_NAME_LENGTH));
GLOBAL_TRIE = new StringMap();

// Fix DataPack positions in sm 1.10
DataPack hDataPack = new DataPack();
Expand All @@ -84,56 +78,23 @@ public void OnPluginStart()

VIPMenu_Setup();
#if USE_ADMINMENU 1
VIPAdminMenu_Setup();
AdminMenu_Setup();
#endif

Cvars_Setup();
API_SetupForwards();

HookEvent("player_spawn", Event_PlayerSpawn);
HookEvent("player_death", Event_PlayerDeath);
HookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy);
HookEventEx("cs_match_end_restart", Event_MatchEndRestart, EventHookMode_PostNoCopy);
HookEvent("player_spawn", Event_PlayerSpawn);
HookEvent("player_death", Event_PlayerDeath);
HookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy);
HookEventEx("cs_match_end_restart", Event_MatchEndRestart, EventHookMode_PostNoCopy);

CMD_Setup();

g_EngineVersion = GetEngineVersion();

#if USE_ADMINMENU 1
RegConsoleCmd("sm_vipadmin", VIPAdmin_CMD);

if(LibraryExists("adminmenu"))
{
TopMenu hTopMenu = GetAdminTopMenu();
if(hTopMenu != null)
{
OnAdminMenuReady(hTopMenu);
}
}
#endif
}

public void OnAllPluginsLoaded()
{
DB_OnPluginStart();
}

#if USE_ADMINMENU 1
public Action OnClientSayCommand(int iClient, const char[] szCommand, const char[] szArgs)
{
if(iClient > 0 && iClient <= MaxClients && szArgs[0])
{
if(g_iClientInfo[iClient] & IS_WAIT_CHAT_SEARCH)
{
if(g_iClientInfo[iClient] & IS_WAIT_CHAT_SEARCH)
{
ShowWaitSearchMenu(iClient, szArgs);
}

return Plugin_Handled;
}
}

return Plugin_Continue;
}
#endif
24 changes: 12 additions & 12 deletions addons/sourcemod/scripting/vip/API.sp
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ static Handle g_hGlobalForward_OnClientDisconnect;
void API_SetupForwards()
{
// Global Forwards
g_hGlobalForward_OnClientPreLoad = CreateGlobalForward("VIP_OnClientPreLoad", ET_Hook, Param_Cell);
g_hGlobalForward_OnVIPLoaded = CreateGlobalForward("VIP_OnVIPLoaded", ET_Ignore);
g_hGlobalForward_OnClientLoaded = CreateGlobalForward("VIP_OnClientLoaded", ET_Ignore, Param_Cell, Param_Cell);
g_hGlobalForward_OnVIPClientLoaded = CreateGlobalForward("VIP_OnVIPClientLoaded", ET_Ignore, Param_Cell);
g_hGlobalForward_OnVIPClientAdded = CreateGlobalForward("VIP_OnVIPClientAdded", ET_Ignore, Param_Cell, Param_Cell);
g_hGlobalForward_OnVIPClientRemoved = CreateGlobalForward("VIP_OnVIPClientRemoved", ET_Ignore, Param_Cell, Param_String, Param_Cell);
g_hGlobalForward_OnPlayerSpawn = CreateGlobalForward("VIP_OnPlayerSpawn", ET_Ignore, Param_Cell, Param_Cell, Param_Cell);
g_hGlobalForward_OnShowClientInfo = CreateGlobalForward("VIP_OnShowClientInfo", ET_Hook, Param_Cell, Param_String, Param_String, Param_Cell);
g_hGlobalForward_OnFeatureToggle = CreateGlobalForward("VIP_OnFeatureToggle", ET_Ignore, Param_Cell, Param_String, Param_Cell, Param_CellByRef);
g_hGlobalForward_OnFeatureRegistered = CreateGlobalForward("VIP_OnFeatureRegistered", ET_Ignore, Param_String);
g_hGlobalForward_OnFeatureUnregistered = CreateGlobalForward("VIP_OnFeatureUnregistered", ET_Ignore, Param_String);
g_hGlobalForward_OnClientDisconnect = CreateGlobalForward("VIP_OnClientDisconnect", ET_Ignore, Param_Cell, Param_Cell);
g_hGlobalForward_OnClientPreLoad = CreateGlobalForward("VIP_OnClientPreLoad", ET_Hook, Param_Cell);
g_hGlobalForward_OnVIPLoaded = CreateGlobalForward("VIP_OnVIPLoaded", ET_Ignore);
g_hGlobalForward_OnClientLoaded = CreateGlobalForward("VIP_OnClientLoaded", ET_Ignore, Param_Cell, Param_Cell);
g_hGlobalForward_OnVIPClientLoaded = CreateGlobalForward("VIP_OnVIPClientLoaded", ET_Ignore, Param_Cell);
g_hGlobalForward_OnVIPClientAdded = CreateGlobalForward("VIP_OnVIPClientAdded", ET_Ignore, Param_Cell, Param_Cell);
g_hGlobalForward_OnVIPClientRemoved = CreateGlobalForward("VIP_OnVIPClientRemoved", ET_Ignore, Param_Cell, Param_String, Param_Cell);
g_hGlobalForward_OnPlayerSpawn = CreateGlobalForward("VIP_OnPlayerSpawn", ET_Ignore, Param_Cell, Param_Cell, Param_Cell);
g_hGlobalForward_OnShowClientInfo = CreateGlobalForward("VIP_OnShowClientInfo", ET_Hook, Param_Cell, Param_String, Param_String, Param_Cell);
g_hGlobalForward_OnFeatureToggle = CreateGlobalForward("VIP_OnFeatureToggle", ET_Ignore, Param_Cell, Param_String, Param_Cell, Param_CellByRef);
g_hGlobalForward_OnFeatureRegistered = CreateGlobalForward("VIP_OnFeatureRegistered", ET_Ignore, Param_String);
g_hGlobalForward_OnFeatureUnregistered = CreateGlobalForward("VIP_OnFeatureUnregistered", ET_Ignore, Param_String);
g_hGlobalForward_OnClientDisconnect = CreateGlobalForward("VIP_OnClientDisconnect", ET_Ignore, Param_Cell, Param_Cell);
}

// Global Forwards
Expand Down
Loading

0 comments on commit c55733f

Please sign in to comment.