Member
|
08-28-2012
, 09:11
Vip Menu
|
#1
|
Ok, so I finally made some commands for custom1 (o) flag, and made a vip menu by adminmenu.sp...
But I can't get it, how can I make that menu now appear for someone with flag o when he types in console: "sm_vip" or in chat: "!vip".. Any suggestions ? Thanks in Advance
Here's the code:
Code:
#pragma semicolon 1
#include <sourcemod>
#include <topmenus>
//Put the rest of the include files you need up here
public Plugin:myinfo =
{
name = "Vip Plugin",
author = "Hmh",
description = "It's a Vip Plugin :O",
version = "1.0.0.0",
url = ""
};
//All of this is optional behind this except the include string.
/* Forwards */
new Handle:hOnAdminMenuReady = INVALID_HANDLE;
new Handle:hOnAdminMenuCreated = INVALID_HANDLE;
/* Menus */
new Handle:hAdminMenu = INVALID_HANDLE;
/* Top menu objects */
new TopMenuObject:obj_playercmds = INVALID_TOPMENUOBJECT;
new TopMenuObject:obj_votingcmds = INVALID_TOPMENUOBJECT;
#include "vipmenu/dynamicmenu.sp"
public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
{
CreateNative("GetAdminTopMenu", __GetAdminTopMenu);
CreateNative("AddTargetsToMenu", __AddTargetsToMenu);
CreateNative("AddTargetsToMenu2", __AddTargetsToMenu2);
RegPluginLibrary("vipmenu");
return APLRes_Success;
}
public OnPluginStart()
{
LoadTranslations("vipcommon.phrases");
LoadTranslations("vipmenu.phrases");
hOnAdminMenuCreated = CreateGlobalForward("OnAdminMenuCreated", ET_Ignore, Param_Cell);
hOnAdminMenuReady = CreateGlobalForward("OnAdminMenuReady", ET_Ignore, Param_Cell);
RegAdminCmd("sm_vip", Command_DisplayMenu, ADMFLAG_CUSTOM1, "Displays the VIP menu");
RegAdminCmd("sm_vip", Command_DisplayMenu, ADMFLAG_CUSTOM1, "Displays the VIP menu");
}
public OnConfigsExecuted()
{
decl String:path[PLATFORM_MAX_PATH];
decl String:error[256];
BuildPath(Path_SM, path, sizeof(path), "configs/vipmenu_sorting.txt");
if (!LoadTopMenuConfig(hAdminMenu, path, error, sizeof(error)))
{
LogError("Could not load VIP menu config (file \"%s\": %s)", path, error);
return;
}
}
public OnMapStart()
{
ParseConfigs();
}
public OnAllPluginsLoaded()
{
hAdminMenu = CreateTopMenu(DefaultCategoryHandler);
obj_playercmds = AddToTopMenu(hAdminMenu,
"PlayerCommands",
TopMenuObject_Category,
DefaultCategoryHandler,
INVALID_TOPMENUOBJECT);
obj_votingcmds = AddToTopMenu(hAdminMenu,
"VotingCommands",
TopMenuObject_Category,
DefaultCategoryHandler,
INVALID_TOPMENUOBJECT);
BuildDynamicMenu();
Call_StartForward(hOnAdminMenuCreated);
Call_PushCell(hAdminMenu);
Call_Finish();
Call_StartForward(hOnAdminMenuReady);
Call_PushCell(hAdminMenu);
Call_Finish();
}
public DefaultCategoryHandler(Handle:topmenu,
TopMenuAction:action,
TopMenuObject:object_id,
param,
String:buffer[],
maxlength)
{
if (action == TopMenuAction_DisplayTitle)
{
if (object_id == INVALID_TOPMENUOBJECT)
{
Format(buffer, maxlength, "%T:", "Admin Menu", param);
}
else if (object_id == obj_playercmds)
{
Format(buffer, maxlength, "%T:", "Player Commands", param);
}
else if (object_id == obj_votingcmds)
{
Format(buffer, maxlength, "%T:", "Voting Commands", param);
}
}
else if (action == TopMenuAction_DisplayOption)
{
if (object_id == obj_playercmds)
{
Format(buffer, maxlength, "%T", "Player Commands", param);
}
else if (object_id == obj_votingcmds)
{
Format(buffer, maxlength, "%T", "Voting Commands", param);
}
}
}
public __GetAdminTopMenu(Handle:plugin, numParams)
{
return _:hAdminMenu;
}
public __AddTargetsToMenu(Handle:plugin, numParams)
{
new bool:alive_only = false;
if (numParams >= 4)
{
alive_only = GetNativeCell(4);
}
return UTIL_AddTargetsToMenu(GetNativeCell(1), GetNativeCell(2), GetNativeCell(3), alive_only);
}
public __AddTargetsToMenu2(Handle:plugin, numParams)
{
return UTIL_AddTargetsToMenu2(GetNativeCell(1), GetNativeCell(2), GetNativeCell(3));
}
public Action:Command_DisplayMenu(client, args)
{
if (client == 0)
{
ReplyToCommand(client, "[SM] %t", "Command is in-game only");
return Plugin_Handled;
}
DisplayTopMenu(hAdminMenu, client, TopMenuPosition_Start);
return Plugin_Handled;
}
stock UTIL_AddTargetsToMenu2(Handle:menu, source_client, flags)
{
decl String:user_id[12];
decl String:name[MAX_NAME_LENGTH];
decl String:display[MAX_NAME_LENGTH+12];
new num_clients;
for (new i = 1; i <= MaxClients; i++)
{
if (!IsClientConnected(i) || IsClientInKickQueue(i))
{
continue;
}
if (((flags & COMMAND_FILTER_NO_BOTS) == COMMAND_FILTER_NO_BOTS)
&& IsFakeClient(i))
{
continue;
}
if (((flags & COMMAND_FILTER_CONNECTED) != COMMAND_FILTER_CONNECTED)
&& !IsClientInGame(i))
{
continue;
}
if (((flags & COMMAND_FILTER_ALIVE) == COMMAND_FILTER_ALIVE)
&& !IsPlayerAlive(i))
{
continue;
}
if (((flags & COMMAND_FILTER_DEAD) == COMMAND_FILTER_DEAD)
&& IsPlayerAlive(i))
{
continue;
}
if ((source_client && ((flags & COMMAND_FILTER_NO_IMMUNITY) != COMMAND_FILTER_NO_IMMUNITY))
&& !CanUserTarget(source_client, i))
{
continue;
}
IntToString(GetClientUserId(i), user_id, sizeof(user_id));
GetClientName(i, name, sizeof(name));
Format(display, sizeof(display), "%s (%s)", name, user_id);
AddMenuItem(menu, user_id, display);
num_clients++;
}
return num_clients;
}
stock UTIL_AddTargetsToMenu(Handle:menu, source_client, bool:in_game_only, bool:alive_only)
{
new flags = 0;
if (!in_game_only)
{
flags |= COMMAND_FILTER_CONNECTED;
}
if (alive_only)
{
flags |= COMMAND_FILTER_ALIVE;
}
return UTIL_AddTargetsToMenu2(menu, source_client, flags);
}
Last edited by gedas147; 08-28-2012 at 09:12.
|
|