Instantly share code, notes, and snippets.
2spooky2me/My Menu Secret
Created Apr 20, 2016
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma semicolon 1 | |
#define DEBUG | |
#define PLUGIN_AUTHOR "" | |
#define PLUGIN_VERSION "0.00" | |
#include <sourcemod> | |
#include <sdktools> | |
#pragma newdecls required | |
public Plugin myinfo = | |
{ | |
name = "", | |
author = PLUGIN_AUTHOR, | |
description = "", | |
version = PLUGIN_VERSION, | |
url = "" | |
}; | |
public void OnPluginStart() | |
{ | |
RegConsoleCmd("menu", CmdShop); | |
} | |
public Action CmdShop(int client, int args) | |
{ | |
if(!IsValidClient(client)) | |
return Plugin_Handled; | |
Handle menu = CreateMenu(MenuHandelr); | |
SetMenuTitle(menu, "My first"); | |
AddMenuItem(menu, "Ak47", "Ak47"); | |
AddMenuItem(menu, "M4a1-s", "M4a1-s"); | |
AddMenuItem(menu, "M4a4", "M4a4"); | |
AddMenuItem(menu, "AWP", "AWP"); | |
AddMenuItem(menu, "Awp and a Five-SeveN", "Awp and a Five-SeveN"); | |
DisplayMenu(menu, client, 15); | |
return Plugin_Continue; | |
} | |
public int MenuHandelr(Menu menu, MenuAction action, int client, int itemNum) | |
{ | |
if(action == MenuAction_End || !IsValidClient(client)) | |
CloseHandle(menu); | |
if(action == MenuAction_Select) | |
{ | |
switch(itemNum) | |
{ | |
case 0: | |
{ | |
ReplyToCommand(client, "you bought a Ak-47"); | |
GivePlayerItem(client, "weapon_ak47"); | |
} | |
case 1: | |
{ | |
ReplyToCommand(client, "You bought a m4a1-s"); | |
GivePlayerItem(client, "weapon_m4a1_silencer"); | |
} | |
case 2: | |
{ | |
ReplyToCommand(client, "You bought a m4a4"); | |
GivePlayerItem(client, "weapon_m4a1"); | |
} | |
case 3: | |
{ | |
ReplyToCommand(client, "you bought a Awp"); | |
GivePlayerItem(client, "weapon_awp"); | |
} | |
case 4: | |
{ | |
ReplyToCommand(client, "you bought a Awp and a Five-SeveN"); | |
GivePlayerItem(client, "weapon_awp"); | |
GivePlayerItem(client, "weapon_fiveseveN"); | |
} | |
} | |
} | |
} | |
stock bool IsValidClient(int client, bool bAlive = false) | |
{ | |
if(client >= 1 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && (bAlive == false || IsPlayerAlive(client))) | |
{ | |
return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment