#include <amxmodx>
#include <reapi>
new Float: g_fOrigin[3], Float: g_fAngles[3];
new bool:g_bC4Planted = false;
public plugin_init()
{
register_plugin("Retake: Auto Planting", "0.1", "maFFyoZZyk")
// RegisterHookChain(RG_CSGameRules_RestartRound, "RoundStart_Pre", true); // Отлавливаем момент начала раунда
RegisterHookChain(RG_CBasePlayer_Spawn, "CBasePlayer_Spawn_Post", true); // Отлавливаем момент спавна игрока
RegisterHookChain(RG_RoundEnd, "RoundEnd_Post", true); // Отлавливаем момент конца раунда
RegisterHookChain(RG_CSGameRules_GoToIntermission, "CSGameRules_GoToIntermission_Post", true); // Отлавливаем момент конца карты
}
public OnConfigsExecuted()
{
set_cvar_num("mp_give_player_c4", 0); // Запрет выдачи бомбы
}
public CBasePlayer_Spawn_Post(id)
{
if(is_user_connected(id))
{
new target = NULLENT, class[] = "func_bomb_target";
while ((target = rg_find_ent_by_class(target, class)))
{
if (!g_bC4Planted && get_member(id, m_iTeam) == TEAM_TERRORIST)
{
g_bC4Planted = true;
get_entvar( id, var_origin, g_fOrigin );
get_entvar( id, var_angles, g_fAngles );
rg_plant_bomb(id, g_fOrigin, g_fAngles);
}
break;
}
}
return 1;
}
public RoundEnd_Post(WinStatus:status, ScenarioEventEndRound:event, Float:tmDelay)
{
g_bC4Planted = false;
}
public CSGameRules_GoToIntermission_Post()
{
set_cvar_num("mp_give_player_c4", 1);
}