#pragma semicolon 1
#include <sourcemod>
#include <sdktools_functions>
new Handle:g_Msg;
RemoveNades(iClient);
public OnPluginStart()
{
g_Msg = CreateConVar("sm_grenade_msg", "1", "Message On/Off", FCVAR_NOTIFY, true, 0.0, true, 1.0);
HookEvent("player_spawn", Event_OnPlayerSpawn);
HookEvent("hegrenade_detonate", Event_HeGrenadeDetonate);
HookEvent("flashbang_detonate", Event_FlashBangDetonate);
HookEvent("smokegrenade_detonate", Event_SmokeGrenadeDetonate);
HookEvent("decoy_detonate", Event_DecoyGrenadeDetonate);
HookEvent("molotov_detonate", Event_MolotovGrenadeDetonate);
}
public Event_OnPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid")), value_hp, value_armor;
if (client > 0 && IsPlayerAlive(client))
{
if (GetUserFlagBits(client) & ADMFLAG_ROOT)
{
value_hp = 250;
value_armor = 100;
}
else
{
value_hp = 200;
value_armor = 50;
}
GivePlayerItem(client, "weapon_hegrenade");
GivePlayerItem(client, "weapon_flashbang");
GivePlayerItem(client, "weapon_smokegrenade");
GivePlayerItem(client, "weapon_decoy");
GivePlayerItem(client, "weapon_molotov");
SetEntProp(client, Prop_Send, "m_iHealth", value_hp);
SetEntProp(client, Prop_Send, "m_ArmorValue", value_armor);
if(GetConVarBool(g_Msg)) PrintToChat(client, "\x01\x05[SM]\x03 Получены гранаты");
}
}
public Event_HeGrenadeDetonate(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if(client > 0 && IsPlayerAlive(client))
{
if (GetUserFlagBits(client) & ADMFLAG_ROOT)
{
CreateTimer(10.0, GiveHE, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
}
else
{
CreateTimer(20.0, GiveHE, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
}
if(GetConVarBool(g_Msg)) PrintToChat(client, "\x01\x05[SM] \x03Получена HE граната");
}
}
public Action:GiveHE(Handle:hTimer, any:UserId)
{
new client = GetClientOfUserId(UserId);
if(client && IsPlayerAlive(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))
{
if (GetUserFlagBits(client) & ADMFLAG_ROOT)
{
CreateTimer(10.0, GiveFL, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
}
else
{
CreateTimer(20.0, GiveFL, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
}
if(GetConVarBool(g_Msg)) PrintToChat(client, "\x01\x05[SM] \x03Получена FLASHBANG граната");
}
}
public Action:GiveFL(Handle:hTimer, any:UserId)
{
new client = GetClientOfUserId(UserId);
if(client && IsPlayerAlive(client))
{
GivePlayerItem(client, "weapon_flashbang");
if(GetConVarBool(g_Msg)) PrintToChat(client, "\x01\x05[SM] \x03Получена HE граната");
}
}
public Event_SmokeGrenadeDetonate(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if(client > 0 && IsPlayerAlive(client))
{
if (GetUserFlagBits(client) & ADMFLAG_ROOT)
{
CreateTimer(10.0, GiveSM, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
}
else
{
CreateTimer(20.0, GiveSM, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
}
if(GetConVarBool(g_Msg)) PrintToChat(client, "\x01\x05[SM] \x03Получена SMOKE граната");
}
}
public Action:GiveSM(Handle:hTimer, any:UserId)
{
new client = GetClientOfUserId(UserId);
if(client && IsPlayerAlive(client))
{
GivePlayerItem(client, "weapon_smokegrenade");
if(GetConVarBool(g_Msg)) PrintToChat(client, "\x01\x05[SM] \x03Получена HE граната");
}
}
public Event_DecoyGrenadeDetonate(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if(client > 0 && IsPlayerAlive(client))
{
if (GetUserFlagBits(client) & ADMFLAG_ROOT)
{
CreateTimer(10.0, GiveDC, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
}
else
{
CreateTimer(20.0, GiveDC, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
}
if(GetConVarBool(g_Msg)) PrintToChat(client, "\x01\x05[SM] \x03Получена DECOY граната");
}
}
public Action:GiveDC(Handle:hTimer, any:UserId)
{
new client = GetClientOfUserId(UserId);
if(client && IsPlayerAlive(client))
{
GivePlayerItem(client, "weapon_decoy");
if(GetConVarBool(g_Msg)) PrintToChat(client, "\x01\x05[SM] \x03Получена HE граната");
}
}
public Event_MolotovGrenadeDetonate(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if(client > 0 && IsPlayerAlive(client))
{
if (GetUserFlagBits(client) & ADMFLAG_ROOT)
{
CreateTimer(10.0, GiveML, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
}
else
{
CreateTimer(20.0, GiveML, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
}
if(GetConVarBool(g_Msg)) PrintToChat(client, "\x01\x05[SM] \x03Получена MOLOTOV граната");
}
}
public Action:GiveML(Handle:hTimer, any:UserId)
{
new client = GetClientOfUserId(UserId);
if(client && IsPlayerAlive(client))
{
GivePlayerItem(client, "weapon_molotov");
if(GetConVarBool(g_Msg)) PrintToChat(client, "\x01\x05[SM] \x03Получена HE граната");
}
}
stock RemoveNades(iClient)
{
while (RemoveWeaponBySlot(iClient, 3)) {}
}
stock bool:RemoveWeaponBySlot(iClient, slot)
{
new entity_index = GetPlayerWeaponSlot(iClient, slot);
if (entity_index > 0)
{
RemovePlayerItem(iClient, entity_index);
AcceptEntityInput(entity_index, "Kill");
return true;
}
return false;
}