SourceMod Donor
Join Date: May 2008
Location: Atlanta, GA
|
10-09-2009
, 21:57
AddToTopMenu Category Problem?
|
#1
|
Hello all, long time no see.
I've been passing the unemployment time by working on some sourcemod goodies again. This time, I decided to learn to modify the admin menu, categories, items etc..
I've run across an odd issue I'm hoping someone can help with. Based on the information in the Wiki for creating new categories, I've added my own category, along with numerous options within said category.
The problem is, whenever I pull up the admin menu using sm_admin, it defaults into the Player Options menu, instead of the base admin menu. If you exit out of the menu, issue sm_admin again, you get the base menu per normal behaviour.
The custom category and items themselves work great, I'm just battling this odd initial sm_admin menu behaviour.
I won't post the entire plugin code in the snippet, however I will post all menu related entries, and attach the full code if someone chooses to toy with it for themself.
Testing using SM 1.2.4 Release
Thanks for the assist in advance,
(Yes, I named it bling, I was bored. lol)
X
PHP Code:
#pragma semicolon 1 #include <sourcemod> #include <sdktools> #undef REQUIRE_PLUGIN #include <adminmenu> #define VERSION "0.5"
new Handle:hAdminMenu = INVALID_HANDLE;
public OnPluginStart() { /* Account for late loading */ new Handle:topmenu; if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE)) { OnAdminMenuReady(topmenu); } } public OnLibraryRemoved(const String:name[]) { if (StrEqual(name, "adminmenu")) { hAdminMenu = INVALID_HANDLE; } } public OnAdminMenuReady(Handle:topmenu) { if (topmenu == hAdminMenu) { return; } hAdminMenu = topmenu; new TopMenuObject:obj_blingoptions = AddToTopMenu(hAdminMenu,"Bling Options",TopMenuObject_Category,Bling_CategoryHandler,INVALID_TOPMENUOBJECT); AddToTopMenu(hAdminMenu,"sm_bling_noscope",TopMenuObject_Item,Bling_MenuHandler,obj_blingoptions,"sm_kick",ADMFLAG_GENERIC); AddToTopMenu(hAdminMenu,"sm_bling_headshot",TopMenuObject_Item,Bling_MenuHandler,obj_blingoptions,"sm_kick",ADMFLAG_GENERIC); AddToTopMenu(hAdminMenu,"sm_bling_headshotsounds",TopMenuObject_Item,Bling_MenuHandler,obj_blingoptions,"sm_kick",ADMFLAG_GENERIC); AddToTopMenu(hAdminMenu,"sm_bling_knifekillsounds",TopMenuObject_Item,Bling_MenuHandler,obj_blingoptions,"sm_kick",ADMFLAG_GENERIC); AddToTopMenu(hAdminMenu,"sm_bling_bulletpath",TopMenuObject_Item,Bling_MenuHandler,obj_blingoptions,"sm_kick",ADMFLAG_GENERIC); AddToTopMenu(hAdminMenu,"sm_bling_dissolver",TopMenuObject_Item,Bling_MenuHandler,obj_blingoptions,"sm_kick",ADMFLAG_GENERIC); if (g_dissolver) { AddToTopMenu(hAdminMenu,"sm_bling_dissolvetype",TopMenuObject_Item,Bling_MenuHandler,obj_blingoptions,"sm_kick",ADMFLAG_GENERIC); } AddToTopMenu(hAdminMenu,"sm_bling_oneshotkill",TopMenuObject_Item,Bling_MenuHandler,obj_blingoptions,"sm_kick",ADMFLAG_GENERIC); AddToTopMenu(hAdminMenu,"sm_bling_blood",TopMenuObject_Item,Bling_MenuHandler,obj_blingoptions,"sm_kick",ADMFLAG_GENERIC); AddToTopMenu(hAdminMenu,"sm_bling_noblock",TopMenuObject_Item,Bling_MenuHandler,obj_blingoptions,"sm_kick",ADMFLAG_GENERIC); } public Bling_MenuHandler(Handle:topmenu,TopMenuAction:action,TopMenuObject:object_id,param,String:buffer[],maxlength) { new String:obj_str[64]; GetTopMenuObjName(topmenu, object_id, obj_str, sizeof(obj_str)); if (action == TopMenuAction_DisplayOption) { if (StrEqual(obj_str, "sm_bling_noscope")) { if (g_noscope) { menutext = "Scout No Scope: Enabled"; } else { menutext = "Scout No Scope: Disabled"; } } else if (StrEqual(obj_str, "sm_bling_headshot")) { if (g_headshot) { menutext = "Headshot Only: Enabled"; } else { menutext = "Headshot Only: Disabled"; } } else if (StrEqual(obj_str, "sm_bling_headshotsounds")) { if (g_headshotsounds) { menutext = "Headshot Sounds: Enabled"; } else { menutext = "Headshot Sounds: Disabled"; } } else if (StrEqual(obj_str, "sm_bling_knifekillsounds")) { if (g_knifekillsounds) { menutext = "Knifekill Sounds: Enabled"; } else { menutext = "Knifekill Sounds: Disabled"; } } else if (StrEqual(obj_str, "sm_bling_bulletpath")) { if (g_bulletpath) { menutext = "Laser Bulletpaths: Enabled"; } else { menutext = "Laser Bulletpaths: Disabled"; } } else if (StrEqual(obj_str, "sm_bling_dissolver")) { if (g_dissolver) { menutext = "Ragdoll Dissolver: Enabled"; } else { menutext = "Ragdoll Dissolver: Disabled"; } } else if (StrEqual(obj_str, "sm_bling_dissolvetype")) { if (g_dissolvetype == 0) { menutext = "Ragdoll Dissolve Type: Random"; } else if (g_dissolvetype == 1) { menutext = "Ragdoll Dissolve Type: Energy"; } else if (g_dissolvetype == 2) { menutext = "Ragdoll Dissolve Type: Energy & Electrical"; } } else if (StrEqual(obj_str, "sm_bling_oneshotkill")) { if (g_oneshotkill) { menutext = "One Shot Kills: Enabled"; } else { menutext = "One Shot Kills: Disabled"; } } else if (StrEqual(obj_str, "sm_bling_blood")) { if (g_blood) { menutext = "Blood Effects: Enabled"; } else { menutext = "Blood Effects: Disabled"; } } else if (StrEqual(obj_str, "sm_bling_noblock")) { if (g_noblock) { menutext = "No-Block: Enabled"; } else { menutext = "No-Block: Disabled"; } } Format(buffer, maxlength, menutext); } else if (action == TopMenuAction_SelectOption) { if (StrEqual(obj_str, "sm_bling_noscope")) { if (g_noscope) { SetConVarBool(Handle:g_Cvarnoscope, false); } else { SetConVarBool(Handle:g_Cvarnoscope, true); } } else if (StrEqual(obj_str, "sm_bling_headshot")) { if (g_headshot) { SetConVarBool(Handle:g_Cvarheadshot, false); } else { SetConVarBool(Handle:g_Cvarheadshot, true); } } else if (StrEqual(obj_str, "sm_bling_headshotsounds")) { if (g_headshotsounds) { SetConVarBool(Handle:g_Cvarheadshotsounds, false); } else { SetConVarBool(Handle:g_Cvarheadshotsounds, true); } } else if (StrEqual(obj_str, "sm_bling_knifekillsounds")) { if (g_knifekillsounds) { SetConVarBool(Handle:g_Cvarknifekillsounds, false); } else { SetConVarBool(Handle:g_Cvarknifekillsounds, true); } } else if (StrEqual(obj_str, "sm_bling_bulletpath")) { if (g_bulletpath) { SetConVarBool(Handle:g_Cvarbulletpath, false); } else { SetConVarBool(Handle:g_Cvarbulletpath, true); } } else if (StrEqual(obj_str, "sm_bling_dissolver")) { if (g_dissolver) { SetConVarBool(Handle:g_Cvardissolver, false); } else { SetConVarBool(Handle:g_Cvardissolver, true); } } else if (StrEqual(obj_str, "sm_bling_dissolvetype")) { if (g_dissolvetype == 0) { SetConVarInt(Handle:g_Cvardissolvetype, 1); } else if (g_dissolvetype == 1) { SetConVarInt(Handle:g_Cvardissolvetype, 2); } else if (g_dissolvetype == 2) { SetConVarInt(Handle:g_Cvardissolvetype, 0); } } else if (StrEqual(obj_str, "sm_bling_oneshotkill")) { if (g_oneshotkill) { SetConVarBool(Handle:g_Cvaroneshotkill, false); } else { SetConVarBool(Handle:g_Cvaroneshotkill, true); } } else if (StrEqual(obj_str, "sm_bling_blood")) { if (g_blood) { SetConVarBool(Handle:g_Cvarblood, false); } else { SetConVarBool(Handle:g_Cvarblood, true); } } else if (StrEqual(obj_str, "sm_bling_noblock")) { if (g_noblock) { SetConVarBool(Handle:g_Cvarnoblock, false); } else { SetConVarBool(Handle:g_Cvarnoblock, true); } } } RedisplayAdminMenu(Handle:hAdminMenu,param); }
public Bling_CategoryHandler(Handle:topmenu,TopMenuAction:action,TopMenuObject:object_id,param,String:buffer[],maxlength) { if (action == TopMenuAction_DisplayTitle) { Format(buffer, maxlength, "Bling Options:"); } else if (action == TopMenuAction_DisplayOption) { Format(buffer, maxlength, "Bling Options"); } }
__________________
Last edited by XARIUS; 10-09-2009 at 22:14.
|
|