Hello I'm trying to update one of the plugins for my L4D server. It is one that gives players points. One of the issues I'm having is with the menu. It does not go back using the default back/#8 button when I try the !usepoints menu. However, when I use the !clientgivemenu menu, I'm able to use the default/#8 back button. I tried using the same formula and commands from the client give menu with the usepoints menu, but kept getting errors or the functions to items wouldn't work. Can anyone help based on the two examples below?
Working (default back button/#8 button in the menu works):
DisplayGiveItemMenu(client)
{
new Handle:menu = CreateMenu(MenuHandler_GiveItem);
decl String:title[100];
Format(title, sizeof(title), "Item Choose Page", client);
SetMenuTitle(menu, title);
SetMenuExitBackButton(menu, true);
AddMenuItem(menu, "0", "Shotgun");
AddMenuItem(menu, "1", "SMG");
AddMenuItem(menu, "2", "Rifle");
AddMenuItem(menu, "3", "Hunting Rifle");
AddMenuItem(menu, "4", "Auto Shotgun");
AddMenuItem(menu, "5", "Pipe Bomb");
AddMenuItem(menu, "6", "Next Page");
DisplayMenu(menu, client, MENU_TIME_FOREVER);
}
public MenuHandler_GiveItem(Handle:menu, MenuAction:action, param1, param2)
{
if (action == MenuAction_End)
{
CloseHandle(menu);
}
else if (action == MenuAction_Select)
{
decl String:info[32];
new flags6 = GetCommandFlags("give");
SetCommandFlags("give", flags6 & ~FCVAR_CHEAT);
switch (param2)
{
case 0: //shotgun
{
//Give the player a shotgun
FakeClientCommand(currenttarget, "give pumpshotgun");
DisplayGiveItemMenu(param1);
}
case 1: //smg
{
//Give the player a smg
FakeClientCommand(currenttarget, "give smg");
DisplayGiveItemMenu(param1);
}
case 2: //rifle
{
//Give the player a rifle
FakeClientCommand(currenttarget, "give rifle");
DisplayGiveItemMenu(param1);
}
case 3: //hunting rifle
{
//Give the player a hunting rifle
FakeClientCommand(currenttarget, "give hunting_rifle");
DisplayGiveItemMenu(param1);
}
case 4: //auto shotgun
{
//Give the player a autoshotgun
FakeClientCommand(currenttarget, "give autoshotgun");
DisplayGiveItemMenu(param1);
}
case 5: //pipe_bomb
{
//Give the player a pipe_bomb
FakeClientCommand(currenttarget, "give pipe_bomb");
DisplayGiveItemMenu(param1);
}
case 6: //Next Page
{
//Go to next page.
DisplayGiveItemMenu2(param1);
}
}
SetCommandFlags("give", flags6|FCVAR_CHEAT);
}
else if (action == MenuAction_Cancel)
{
DisplayGiveTargetMenu(param1);
}
}
Not Working (Default back/#8 button does not work on this one below):
public Action
ointsMenu3Func(clientId) {
new Handle:menu = CreateMenu(PointsMenuHandler3);
SetMenuTitle(menu, "Points: %d", points[clientId]);
SetMenuExitBackButton(menu, true);
AddMenuItem(menu, "option1", "Propane Tank");
AddMenuItem(menu, "option2", "Oxygen Tank");
AddMenuItem(menu, "option3", "Gas Can");
AddMenuItem(menu, "option4", "Previous Page");
DisplayMenu(menu, clientId, MENU_TIME_FOREVER);
return Plugin_Handled;
}
public PointsMenuHandler3(Handle:menu, MenuAction:action, client, itemNum)
{
if ( action == MenuAction_Select ) {
switch (itemNum)
{
case 0: //propane tank
{
if (GetConVarInt(propanetankpoints) < 0)
{
PrintToChat(client,"[SM] Sorry! The server has this purchasable disabled.");
}
else
{
buyitem[client] = 26;
FakeClientCommand(client, "pointsconfirm");
}
}
case 1: //oxygen tank
{
if (GetConVarInt(oxygentankpoints) < 0)
{
PrintToChat(client,"[SM] Sorry! The server has this purchasable disabled.");
}
else
{
buyitem[client] = 27;
FakeClientCommand(client, "pointsconfirm");
}
}
case 2: //gas can
{
if (GetConVarInt(gascanpoints) < 0)
{
PrintToChat(client,"[SM] Sorry! The server has this purchasable disabled.");
}
else
{
buyitem[client] = 29;
FakeClientCommand(client, "pointsconfirm");
}
}
case 3: //back
{
FakeClientCommand(client, "pointsmenu2");
}
}
}
}