#include <amxmodx>
#include <amxmisc>
#include <reapi>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN "fb_forwards"
#define VERSION "0.1"
#define AUTHOR "kanagava + Limbooc"
#define MODELS "models/you_are_banned_russian.mdl"
//#define SOUND_ANSWER "zvuk.wav"
#define IsPlayer(%0) (%0 >= 1 && %0 <= MaxClients)
//#define DONT_KICK //Кикать с сервера при бане, расскомнтируете если необходимо "поиздеваться" над игрокоми оставить игрока на сервере
public plugin_precache()
{
new szBuff[248];
formatex(szBuff, charsmax(szBuff), "%s", MODELS);
//server_print("%s", szBuff);
precache_model(szBuff);
#if defined SOUND_ANSWER
engfunc(EngFunc_PrecacheSound, SOUND_ANSWER);
#endif
}
forward fbans_player_banned_pre(id, userid)
forward fbans_player_banned_post(id, userid, bid)
new bool:g_iUserBanned[MAX_PLAYERS + 1]
new HamHook: g_iHamFwd_Entity_Block[13];
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
RegisterHookChain(RG_CBasePlayerWeapon_DefaultDeploy, "CBasePlayerWeapon_DefaultDeploy_Pre", false);
RegisterHookChain(RG_CBasePlayer_HasRestrictItem, "CBasePlayer_HasRestrictItem_Pre", false);
RegisterHookChain(RG_CBasePlayer_Spawn, "HC_CBasePlayer_PlayerSpawn_Post", true);
Hamsandwich_Init();
register_clcmd("say /banned", "Player_Banned");
}
public fbans_player_banned_pre(id, userid)
{
Player_Banned(id)
#if defined DONT_KICK
return PLUGIN_HANDLED;
#endif
}
public client_disconnected(id)
{
g_iUserBanned[id] = false;
}
public Player_Banned(id)
{
if(!is_user_connected(id)) return;
g_iUserBanned[id] = true;
#if defined SOUND_ANSWER
client_cmd(id, "spk %s", SOUND_ANSWER);
#endif
rg_remove_all_items(id);
rg_give_item(id, "weapon_knife");
set_member(id, m_iHideHUD, get_member(id, m_iHideHUD) | HIDEHUD_ALL);
}
public CBasePlayerWeapon_DefaultDeploy_Pre(const iEntity, const szViewModel[], const szWeaponModel[], const iAnim, const szAnimExt[], const skiplocal) {
new pId = get_member(iEntity, m_pPlayer);
if(!g_iUserBanned[pId])
return HC_CONTINUE;
SetHookChainArg(2, ATYPE_STRING, MODELS);
set_member(pId, m_flNextAttack, 99999.9);
return HC_CONTINUE;
}
public CBasePlayer_HasRestrictItem_Pre(id, ItemID:item, ItemRestType:type)
{
if(g_iUserBanned[id])
{
SetHookChainReturn(ATYPE_BOOL, true);
return HC_SUPERCEDE;
}
return HC_CONTINUE;
}
public HC_CBasePlayer_PlayerSpawn_Post(pId)
{
if(!g_iUserBanned[pId])
return HC_CONTINUE;
Player_Banned(pId)
return HC_CONTINUE;
}
Hamsandwich_Init() {
new const szEntityClass[][] =
{
"func_vehicle", // Управляемая машина
"func_tracktrain", // Управляемый поезд
"func_tank", // Управляемая пушка
"game_player_hurt", // При активации наносит игроку повреждения
"func_recharge", // Увеличение запаса бронижелета
"func_healthcharger", // Увеличение процентов здоровья
"game_player_equip", // Выдаёт оружие
"player_weaponstrip", // Забирает всё оружие
"trigger_hurt", // Наносит игроку повреждения
"trigger_gravity", // Устанавливает игроку силу гравитации
"armoury_entity", // Объект лежащий на карте, оружия, броня или гранаты
"weaponbox", // Оружие выброшенное игроком
"weapon_shield" // Щит
};
new iCount;
for(iCount = 0; iCount <= 7; iCount++)
{
DisableHamForward(
g_iHamFwd_Entity_Block[iCount] = RegisterHam(
Ham_Use, szEntityClass[iCount], "HamHook_EntityBlock_Pre", false
)
);
}
for(iCount = 8; iCount <= 12; iCount++)
{
DisableHamForward(
g_iHamFwd_Entity_Block[iCount] = RegisterHam(
Ham_Touch, szEntityClass[iCount], "HamHook_EntityBlock_Pre", false
)
);
}
}
public HamHook_EntityBlock_Pre(const iEntity, const iIndex) {
return (IsPlayer(iIndex) && g_iUserBanned[iIndex]) ? HAM_SUPERCEDE : HAM_IGNORED;
}
#if defined DONT_KICK
public fbans_active_ban_check(
const id, const userid, const banid,
const ban_created, const ban_length_int, const ban_reason[],
const admin_name[], const admin_steamid[], const player_name[],
const player_steamid[], const player_ip[], const ban_type[])
{
Player_Banned(id)
return PLUGIN_HANDLED;
}
#endif