#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <cstrike>
#include <adminmenu>
#pragma semicolon 1
#pragma newdecls required
public Plugin myinfo =
{
name = "p250 Round",
author = "Not",
description = "p250 Round",
version = "1.0",
url = "not@uaplayer.com"
};
bool g_bIsKnifeRound = false;
bool g_bNextRoundKnife = false;
TopMenu g_AdminMenu = null;
public void OnPluginStart()
{
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
HookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy);
for (int client = 1; client <= MaxClients; client++)
{
if (!IsClientInGame(client))
continue;
OnClientPostAdminCheck(client);
}
TopMenu topmenu;
if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != null))
OnAdminMenuReady(topmenu);
}
public void OnAdminMenuReady(Handle hTopMenu)
{
TopMenu topmenu = TopMenu.FromHandle(hTopMenu);
if (topmenu == g_AdminMenu)
return;
g_AdminMenu = topmenu;
TopMenuObject obj_server_commands = g_AdminMenu.FindCategory(ADMINMENU_SERVERCOMMANDS);
if (obj_server_commands != INVALID_TOPMENUOBJECT)
g_AdminMenu.AddItem("sm_deagle_round", AdminMenu_KnifeRound, obj_server_commands, "sm_deagle_round", ADMFLAG_GENERIC);
}
public void AdminMenu_KnifeRound(Handle topmenu, TopMenuAction action, TopMenuObject topobj_id, int client, char[] buffer, int maxlength)
{
switch (action)
{
case TopMenuAction_DisplayOption:
Format(buffer, maxlength, g_bNextRoundKnife ? "Отменить пистолетный раунд" : "Включить пистолетный раунд");
case TopMenuAction_SelectOption:
{
if (g_bNextRoundKnife)
{
g_bNextRoundKnife = false;
PrintToChatAll("[SM] Админ %N отменил пистолетный раунд в следующем раунде", client);
}
else
{
g_bNextRoundKnife = true;
PrintToChatAll("[SM] Админ %N включил пистолетный раунд в следующем раунде", client);
}
if (g_AdminMenu != null)
DisplayTopMenu(g_AdminMenu, client, TopMenuPosition_LastCategory);
}
}
}
public void OnMapStart()
{
g_bIsKnifeRound = false;
g_bNextRoundKnife = false;
}
public void OnClientPostAdminCheck(int client)
{
SDKHook(client, SDKHook_WeaponCanUse, Hook_WeaponCanUse);
}
public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
if (g_bNextRoundKnife)
{
g_bNextRoundKnife = false;
g_bIsKnifeRound = true;
for (int client = 1; client <= MaxClients; client++)
{
if (!IsClientInGame(client) || !IsPlayerAlive(client))
continue;
StripPlayer(client);
GivePlayerItem(client, "weapon_deagle");
}
PrintToChatAll("Начался пистолетный раунд!");
}
}
public void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
{
g_bIsKnifeRound = false;
}
public Action Hook_WeaponCanUse(int client, int weapon)
{
if (g_bIsKnifeRound)
{
char[] szWeapon = new char[32];
if (IsValidEdict(weapon) && GetEdictClassname(weapon, szWeapon, 32) && StrContains(szWeapon, "deagle") != -1)
return Plugin_Continue;
return Plugin_Handled;
}
return Plugin_Continue;
}
void StripPlayer(int client)
{
for (int slot = CS_SLOT_PRIMARY, weapon; slot <= CS_SLOT_C4; slot++)
{
while ((weapon = GetPlayerWeaponSlot(client, slot)) != -1)
{
RemovePlayerItem(client, weapon);
AcceptEntityInput(weapon, "Kill");
}
}
}