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

HELP -> Giving Items Menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
scarlxrd1734
Junior Member
Join Date: Jul 2018
Location: Portugal
Old 09-25-2018 , 14:41   HELP -> Giving Items Menu
Reply With Quote #1

Hi guys. Today i started to do a plugin that has a menu with 3 choices. I want to if a client selects choice 1, 2 or 3 to get a gun. Where do i add in code to give AWP for example if client selects Choice1?

// code //

#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR "scarlxrd1734"
#define PLUGIN_VERSION "1.0.0"

#define CHOICE1 "#choice1"
#define CHOICE2 "#choice2"
#define CHOICE3 "#choice3"

#include <sourcemod>
#include <sdktools>

#pragma newdecls required

public Plugin myinfo =
{
name = "VIP Health On Spawn",
author = PLUGIN_AUTHOR,
description = "VIP Health has 120hp if has a or o flag",
version = PLUGIN_VERSION,
url = "https://steamcommunity.com/id/spirtbtx"
};

public void OnPluginStart()
{
LoadTranslations("vipkit_phrases");
RegAdminCmd("sm_vipkit", Command_VIPKit);
}

public int MenuHandler1(Menu menu, MenuAction action, int param1, int param2)
{
switch(action)
{
PrintToServer("Displaying Menu");
}

case MenuAction_Display:
{
char buffer[255];
Format(buffer, sizeof(buffer), "%T", "VIPKit", param1);

Panel panel = view_as<Panel>(param2);
panel.SetTitle(buffer);
PrintToServer("Client %d was sent menu with panel %x", param1, param2);
}

case MenuAction_Select:
{
char info[32];
menu.GetItem(param2, info, sizeof(info));
if (StrEqual(info, CHOICE3))
{
PrintToServer("Client %d somehow selected %s despite it being disabled", param1, info);
}
else
{
PrintToServer("Client %d selected %s"; param1, info);
}
}

case MenuAction_Cancel:
{
PrintToServer("Client %d's menu was cancelled for reason %d", param1, param2);
}

case MenuAction_End:
{
delete menu;
}

case MenuAction_DrawItem:
{
int style;
char info[32]
menu.GetItem(param2, info, sizeof(info), style);

if (StrEqual(info, CHOICE3))
{
return ITEMDRAW_DEFAULT;
}
else
{
return style;
}
}

case MenuAction_DisplayItem:
{
char info[32];
menu.GetItem(param2, info sizeof(info));

char display[64];

if (StrEqual(info, CHOICE3))
{
Format(display, sizeof(display), "%T", "Choice 3", param1);
return RedrawMenuItem(display);
}
}

return 0;
}

public Action Command_VIPKit(int client, int args)
{
Menu menu = new Menu(MenuHandler1, MENU_ACTIONS_ALL);
menu.SetTitle("%T", "VIPKit", LANG_SERVER);
menu.AddItem(CHOICE1, "Choice 1");
menu.AddItem(CHOICE2, "Choice 2");
menu.AddItem(CHOICE3, "Choice 3");
menu.ExitButton = false;
menu.Display(client, 20);

return Plugin_Handled;
}

Thanks for all the help!
scarlxrd1734 is offline
KewaiiGamer
Junior Member
Join Date: Aug 2017
Old 09-25-2018 , 14:55   Re: HELP -> Giving Items Menu
Reply With Quote #2

You don't seem to have any idea how that code even works (I am assuming that based on your question).

That being said I recommend reading the docs thoroughly to understand how the language works

https://wiki.alliedmods.net/Introduction_to_SourcePawn

If I were to answer your question and give you a direct solution to your issue you wouldn't learn anything and it would not be helpful at all
__________________
Owner of Galyre
All my projects are public and can be found on my GitHub
KewaiiGamer 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 07:30.


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