#include <sdktools_functions>
new Handle:g_Msg;
public OnPluginStart()
{
g_Msg = CreateConVar("sm_grenade_msg", "0", "Message On/Off", FCVAR_NOTIFY, true, 0.0, true, 1.0);
HookEvent("player_spawn", Event_OnPlayerSpawn, EventHookMode_PostNoCopy);
HookEvent("hegrenade_detonate", Event_HeGrenadeDetonate);
HookEvent("flashbang_detonate", Event_FlashBangDetonate);
HookEvent("smokegrenade_detonate", Event_SmokeGrenadeDetonate);
}
public Event_OnPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if(client > 0 && IsPlayerAlive(client))
CreateTimer(0.2, GiveSpawn, client);
}
public Action:GiveSpawn(Handle:timer, any:client)
{
new value_hp, value_armor;
if (GetUserFlagBits(client) & ADMFLAG_ROOT)
{
value_hp = 150;
value_armor = 125;
}
else
{
value_hp = 110;
value_armor = 120;
}
GivePlayerItem(client, "weapon_hegrenade");
GivePlayerItem(client, "weapon_flashbang");
GivePlayerItem(client, "weapon_smokegrenade");
if(GetConVarBool(g_Msg)) PrintToChat(client, "\x01\x05[SM] \x03Получены гранаты.");
SetEntProp(client, Prop_Send, "m_iHealth", value_hp);
SetEntProp(client, Prop_Send, "m_ArmorValue", value_armor);
}
public Event_HeGrenadeDetonate(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if(client > 0 || IsPlayerAlive(client))
CreateTimer(30.0, GiveHE, client);
}
public Action:GiveHE(Handle:timer, any:client)
{
GivePlayerItem(client, "weapon_hegrenade");
if(GetConVarBool(g_Msg)) PrintToChat(client, "\x01\x05[SM] \x03Получена HE граната!");
}
public Event_FlashBangDetonate(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if(client > 0 || IsPlayerAlive(client))
{
GivePlayerItem(client, "weapon_flashbang");
if(GetConVarBool(g_Msg)) PrintToChat(client, "\x01\x05[SM] \x03Получена FLASHBANG граната");
}
}
public Event_SmokeGrenadeDetonate(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if(client > 0 || IsPlayerAlive(client))
{
GivePlayerItem(client, "weapon_smokegrenade");
if(GetConVarBool(g_Msg)) PrintToChat(client, "\x01\x05[SM] \x03Получена SMOKE граната");
}
}