Raised This Month: $51 Target: $400
 12% 

Help with Compiling L4D Script


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Raikage
Junior Member
Join Date: Jun 2020
Old 04-02-2023 , 16:17   Help with Compiling L4D Script
Reply With Quote #1

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 ActionointsMenu3Func(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");
}
}
}
}
Raikage is offline
Earendil
Senior Member
Join Date: Jan 2020
Location: Spain
Old 04-02-2023 , 16:27   Re: Help with Compiling L4D Script
Reply With Quote #2

First of all, this is AMX Mod X subforum. Your question is about SourceMod, wrong forum.

SourceMod menus are paginated, you can put all elements in the same menu handler and SM will handle the next/prev options.

Spoiler


I modified everything on the fly, maybe there are some errors, check it out.
__________________
>>My plugins<<
>>GitHub<<

Last edited by Earendil; 04-02-2023 at 16:32. Reason: I noticed this is the wrong forum for that
Earendil is offline
Raikage
Junior Member
Join Date: Jun 2020
Old 04-02-2023 , 23:33   Re: Help with Compiling L4D Script
Reply With Quote #3

Thanks for your help. I'll try it out!

Quote:
Originally Posted by Earendil View Post
First of all, this is AMX Mod X subforum. Your question is about SourceMod, wrong forum.

SourceMod menus are paginated, you can put all elements in the same menu handler and SM will handle the next/prev options.

Spoiler


I modified everything on the fly, maybe there are some errors, check it out.
Raikage is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:32.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode