Участник
Пользователь
- Сообщения
- 49
- Реакции
- 9
Всем привет! Решил немного изменить плагин, сделав возможность сломать С4 только игроку с флагом доступа.
Добавил вот что:
Но как я понял этого недостаточно. Т.е игроку будет выводится инфа, будет идти прогресс поломки, но ломаться в конечном итоге не будет, или я ошибаюсь?
Подскажите пожалуйста, куда еще нужно прописать условие для полноценной работы.
Спасибо!
// Copyright © 2017 Vaqtincha
/**
* Credits:
*
* - s1lent - за проект ReGameDLL (и за sdk)
* - voed - за идею (плагина "CT Bomb Defusing")
*
*/
///■■■■■■■■■■■■■■■■■■■■■■■ CONFIG START ■■■■■■■■■■■■■■■■■■■■■■■//
#define DEFUSE_TIME 8 // Время разминирование в секундах (с щипцами 2 раза быстрее)
#define FIXING_TIME 5 // Время исправление бомбы в секундах (чтоб запретить просто закомментируйте)
#define BOMB_DETONATE_TIME 1 // Время взрыва после плента (0 = сразу)
#define BOMB_RADIUS 100 // Радиус взрыва. Закомментить если нужен дефолтный (по дефолту 500 юнитов)
//#define BOMB_USE_SAMPLE "weapons/c4_disarmed.wav" // Закомментируйте, если не нужен
//#define CANT_ATTACK // Запретить атаку(ЛКМ) при дефузе/фиксе (как в оригинале)
//#define CANT_RUN // Заморозка при при дефузе/фиксе (как в оригинале)
#define TEST_PRINT_CHAT // для тестов
///■■■■■■■■■■■■■■■■■■■■■■■■ CONFIG END ■■■■■■■■■■■■■■■■■■■■■■■■//
#include <amxmodx>
#include <hamsandwich>
#include <reapi>
#if AMXX_VERSION_NUM < 183
#include <colorchat>
#endif
#define PL_VERSION "0.0.4"
#define MAX_BOMB_RADIUS 2048.0
#define IsPlayer(%1) (1 <= %1 <= g_iMaxPlayers)
#define IsOnGround(%1) ((get_entvar(%1, var_flags) & FL_ONGROUND) == FL_ONGROUND)
new g_iMaxPlayers, g_iC4TimerOld, bot_deathmatch
#if defined CANT_RUN
new HookChain:g_hResetMaxSpeed
#endif
new HamHook:g_hBombThink
new g_pBombDefuser, g_pBombPlanter, g_pBombFixer
new bool:g_bStartDefuse, bool:g_bBombCracked, bool:g_bStartFix
new Float:g_flFixCountDown, Float:g_flNextFix, Float:g_flDefuseCountDown, Float:g_flNextDefuse
#if defined BOMB_RADIUS
new Float:g_flBombRadiusDefault
#endif
#if defined BOMB_USE_SAMPLE
public plugin_precache()
{
precache_sound(BOMB_USE_SAMPLE)
}
#endif
public plugin_init()
{
register_plugin("CT Bomb Cracker", PL_VERSION, "Vaqtincha")
if(!get_member_game(m_bMapHasBombTarget))
{
pause("ad")
return
}
register_logevent("LogEvent_BombPlanted", 3, "2=Planted_The_Bomb")
RegisterHam(Ham_ObjectCaps, "weaponbox", "CWeaponbox_ObjectCaps", .Post = false)
RegisterHam(Ham_Use, "weaponbox", "CWeaponbox_Use", .Post = false)
DisableHamForward(g_hBombThink = RegisterHam(Ham_Think, "weaponbox", "CWeaponbox_Think", .Post = false))
RegisterHam(Ham_Item_AddToPlayer, "weapon_c4", "CBasePlayerItem_AddToPlayer", .Post = true)
RegisterHookChain(RG_RoundEnd, "RoundEnd", .post = false)
RegisterHookChain(RG_CSGameRules_RestartRound, "CSGameRules_RestartRound", .post = false)
#if defined CANT_RUN
DisableHookChain(g_hResetMaxSpeed = RegisterHookChain(RG_CBasePlayer_ResetMaxSpeed, "CBasePlayer_ResetMaxSpeed", .post = false))
#endif
#if defined BOMB_RADIUS
g_flBombRadiusDefault = floatmin(Float:get_member_game(m_flBombRadius), MAX_BOMB_RADIUS)
#endif
bot_deathmatch = get_cvar_pointer("bot_deathmatch")
g_iMaxPlayers = get_maxplayers()
}
#if AMXX_VERSION_NUM < 183
public client_disconnect(pPlayer)
#else
public client_disconnected(pPlayer)
#endif
{
if(pPlayer == g_pBombDefuser) {
g_pBombDefuser = 0
}
else if(pPlayer == g_pBombPlanter) {
g_pBombPlanter = 0
}
else if(pPlayer == g_pBombFixer) {
g_pBombFixer = 0
}
}
public CSGameRules_RestartRound()
{
#if defined BOMB_RADIUS
if(g_flBombRadiusDefault > 0.0 && g_bBombCracked) {
set_member_game(m_flBombRadius, g_flBombRadiusDefault)
}
#endif
ForwardToggle(false)
g_bStartDefuse = g_bBombCracked = g_bStartFix = false
g_flDefuseCountDown = g_flNextDefuse = g_flFixCountDown = g_flNextFix = 0.0
g_pBombDefuser = g_pBombPlanter = g_pBombFixer = 0
}
public RoundEnd(const WinStatus:status, const ScenarioEventEndRound:event, const Float:tmDelay)
{
if(!g_bBombCracked) // || !g_pBombDefuser
return HC_CONTINUE
if(status == WINSTATUS_TERRORISTS && event == ROUND_TARGET_BOMB)
{
if(/* IsPlayer(g_pBombPlanter) && */ is_user_connected(g_pBombPlanter))
{
new Float:flFrags
get_entvar(g_pBombPlanter, var_frags, flFrags)
if(flFrags) {
set_entvar(g_pBombPlanter, var_frags, flFrags - 3.0)
}
}
rg_round_end(tmDelay, WINSTATUS_CTS, ROUND_BOMB_DEFUSED)
// set_member_game(m_iNumCTWins, get_member_game(m_iNumCTWins) + 1)
rg_update_teamscores(.iCtsWins = 1)
SetHookChainReturn(ATYPE_INTEGER, false)
return HC_SUPERCEDE
}
return HC_CONTINUE
}
public LogEvent_BombPlanted()
{
if(!g_bBombCracked) // || !g_pBombDefuser
return
g_pBombPlanter = get_loguser_index()
if(is_user_connected(g_pBombPlanter))
{
if(random(2) == 1)
client_print_color(g_pBombPlanter, print_team_default, "^4* ^1Через ^3%d ^1сек. вам пздс.", BOMB_DETONATE_TIME)
else
client_print_color(g_pBombPlanter, print_team_default, "^4* ^1У вас есть ^3%d ^1сек. чтоб спасать свою жопу", BOMB_DETONATE_TIME)
}
}
#if defined CANT_RUN
public CBasePlayer_ResetMaxSpeed(const pPlayer)
{
if(pPlayer != g_pBombDefuser)
return HC_CONTINUE
set_entvar(pPlayer, var_maxspeed, 1.0)
return HC_SUPERCEDE
}
#endif
public CBasePlayerItem_AddToPlayer(const pWeapon, const pPlayer)
{
if(pWeapon <= 0)
return HAM_IGNORED
new pWeaponBox = get_entvar(pWeapon, var_owner)
if(pWeaponBox > 0 && FClassnameIs(pWeaponBox, "weaponbox")) {
set_task(0.2, "CWeaponBox_Killed", pWeaponBox)
}
if(g_bBombCracked && is_user_connected(pPlayer)) {
SendFakeAmmo(pPlayer) // типа подсказка (!) :D
}
return HAM_IGNORED
}
// Кто-то поднял бомбу при дефузе/фиксе отменим все
public CWeaponBox_Killed(const pWeaponBox)
{
if(is_nullent(pWeaponBox))
{
// server_print("g_bStartFix %s g_bStartDefuse %s", g_bStartFix ? "true":"false", g_bStartDefuse ? "true":"false")
if(g_bStartFix)
{
FinishDefuse(g_pBombFixer)
g_pBombFixer = 0
}
if(g_bStartDefuse)
{
FinishDefuse(g_pBombDefuser)
g_pBombDefuser = 0
}
}
}
public CWeaponbox_Think(const pWeaponBox)
{
if(pWeaponBox <= 0 || !get_member(pWeaponBox, m_WeaponBox_bIsBomb))
return HAM_IGNORED
new Float:flCurTime = get_gametime()
if(g_bStartDefuse && IsPlayer(g_pBombDefuser))
{
if(flCurTime < g_flDefuseCountDown)
{
new bool:bOnGround = IsOnGround(g_pBombDefuser)
if(flCurTime > g_flNextDefuse || !bOnGround)
{
if(!bOnGround) {
client_print(g_pBombDefuser, print_center, "Вы должны находиться на земле^rчтобы сломать бомбу!")
}
FinishDefuse(g_pBombDefuser)
g_pBombDefuser = 0
return HAM_IGNORED
}
}
else if(flCurTime >= g_flDefuseCountDown && get_entvar(g_pBombDefuser, var_deadflag) == DEAD_NO && (get_user_flags(g_pBombDefuser) & ADMIN_VOTE))
{
client_print(g_pBombDefuser, print_center, "Вы успешно сломали бомбу!")
FinishDefuse(g_pBombDefuser)
// BotPlantBomb(1)
PrintChatAll()
g_pBombFixer = 0
g_bBombCracked = true
g_iC4TimerOld = get_member_game(m_iC4Timer)
set_member_game(m_iC4Timer, max(0, BOMB_DETONATE_TIME))
#if defined BOMB_RADIUS
set_member_game(m_flBombRadius, floatmin(BOMB_RADIUS.0, MAX_BOMB_RADIUS))
#endif
}
else
{
FinishDefuse(g_pBombDefuser)
g_pBombDefuser = 0
}
}
else if(g_bStartFix && IsPlayer(g_pBombFixer))
{
if(flCurTime < g_flFixCountDown)
{
new bool:bOnGround = IsOnGround(g_pBombFixer)
if(flCurTime > g_flNextFix || !bOnGround)
{
if(!bOnGround) {
client_print(g_pBombFixer, print_center, "Вы должны находиться на земле^rчтобы исправить бомбу!")
}
FinishDefuse(g_pBombFixer)
g_pBombFixer = 0
return HAM_IGNORED
}
}
else if(flCurTime >= g_flFixCountDown && get_entvar(g_pBombFixer, var_deadflag) == DEAD_NO)
{
client_print(g_pBombFixer, print_center, "Вы успешно исправили бомбу!")
FinishDefuse(g_pBombFixer)
// BotPlantBomb(0)
// PrintChatAll() // пока нет сообщений для теров
g_pBombDefuser = 0
g_bBombCracked = false
if(g_iC4TimerOld) {
set_member_game(m_iC4Timer, g_iC4TimerOld)
}
#if defined BOMB_RADIUS
if(g_flBombRadiusDefault > 0.0) {
set_member_game(m_flBombRadius, g_flBombRadiusDefault)
}
#endif
}
else
{
FinishDefuse(g_pBombFixer)
g_pBombFixer = 0
}
}
// CWeaponBox::BombThink() nextthink = 1.0 CGrenade::C4Think() nextthink = 0.12
set_entvar(pWeaponBox, var_nextthink, flCurTime + 0.2)
return HAM_SUPERCEDE
}
public CWeaponbox_ObjectCaps(const pWeaponBox)
{
if(pWeaponBox <= 0 || !get_member(pWeaponBox, m_WeaponBox_bIsBomb))
return HAM_IGNORED
SetHamReturnInteger(FCAP_CONTINUOUS_USE|FCAP_ONOFF_USE) // FCAP_ONOFF_USE unpressed button hook (value == 0.0)
return HAM_SUPERCEDE
}
public CWeaponbox_Use(const pWeaponBox, const pPlayer, const pCaller, const use_type, const Float:value)
{
if(pWeaponBox <= 0 || !IsPlayer(pPlayer) /* || !IsOnGround(pWeaponBox) */ )
return HAM_IGNORED
new TeamName:iTeam = get_member(pPlayer, m_iTeam)
#if !defined FIXING_TIME
if(iTeam != TEAM_CT)
return HAM_SUPERCEDE
#endif
new Float:flCurTime = get_gametime()
#if defined FIXING_TIME
if(iTeam == TEAM_CT)
#endif
{
if(g_bBombCracked)
{
if(g_pBombDefuser != pPlayer) {
client_print(pPlayer, print_center, "Бомба уже сломана!")
}
return HAM_SUPERCEDE
}
if(value == 1.0)
{
if(g_bStartDefuse)
{
g_flNextDefuse = flCurTime + 0.2
return HAM_SUPERCEDE // return HAM_IGNORED
}
new iSeconds = (get_member(pPlayer, m_bHasDefuser) ? (DEFUSE_TIME / 2) : DEFUSE_TIME)
g_bStartDefuse = true
g_pBombDefuser = pPlayer
g_flDefuseCountDown = flCurTime + float(iSeconds)
g_flNextDefuse = flCurTime + 0.2
StartDefuse(pPlayer, pWeaponBox, iSeconds)
}
else if(value == 0.0)
{
FinishDefuse(pPlayer)
g_pBombDefuser = 0
}
}
#if defined FIXING_TIME
else if(iTeam == TEAM_TERRORIST)
{
if(!g_bBombCracked)
{
if(g_pBombFixer != pPlayer) {
client_print(pPlayer, print_center, "Бомба исправен!")
}
return HAM_SUPERCEDE
}
if(value == 1.0)
{
if(g_bStartFix)
{
g_flNextFix = flCurTime + 0.2
return HAM_SUPERCEDE // return HAM_IGNORED
}
g_bStartFix = true
g_pBombFixer = pPlayer
g_flFixCountDown = flCurTime + float(FIXING_TIME)
g_flNextFix = flCurTime + 0.2
StartDefuse(pPlayer, pWeaponBox, FIXING_TIME)
}
else if(value == 0.0)
{
FinishDefuse(pPlayer)
g_pBombFixer = 0
}
}
#endif
return HAM_IGNORED
}
StartDefuse(const pPlayer, const pWeaponBox, const iTime)
{
#if defined BOMB_USE_SAMPLE
emit_sound(pWeaponBox, CHAN_WEAPON, BOMB_USE_SAMPLE, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
#endif
#if defined CANT_ATTACK
set_member(pPlayer, m_bIsDefusing, true)
#endif
#if defined CANT_RUN
set_entvar(pPlayer, var_maxspeed, 1.0)
#endif
rg_send_bartime(pPlayer, iTime)
set_member(pPlayer, m_bShieldDrawn, true)
ForwardToggle(true)
}
FinishDefuse(const pPlayer)
{
g_bStartDefuse = g_bStartFix = false
g_flDefuseCountDown = g_flNextDefuse = g_flFixCountDown = g_flNextFix = 0.0
ForwardToggle(false)
if(is_user_connected(pPlayer))
{
rg_send_bartime(pPlayer, 0) // reset bartime
#if defined CANT_RUN
rg_reset_maxspeed(pPlayer)
#endif
#if defined CANT_ATTACK
set_member(pPlayer, m_bIsDefusing, false)
#endif
set_member(pPlayer, m_bShieldDrawn, false)
}
}
ForwardToggle(const bool:Enable)
{
if(Enable)
{
EnableHamForward(g_hBombThink)
#if defined CANT_RUN
EnableHookChain(g_hResetMaxSpeed)
#endif
}
else
{
DisableHamForward(g_hBombThink)
#if defined CANT_RUN
DisableHookChain(g_hResetMaxSpeed)
#endif
}
}
PrintChatAll()
{
new iPlayers[32], szDefuserName[32], szTempMsg[140], iCount, pReceiver
get_players(iPlayers, iCount, "ace", "CT")
get_user_name(g_pBombDefuser, szDefuserName, charsmax(szDefuserName))
switch(random_num(1, 7))
{
case 1: formatex(szTempMsg, charsmax(szTempMsg), "^3%s^1^4: ^1Можно больше не кемперить на бомблейсе...", szDefuserName)
case 2: formatex(szTempMsg, charsmax(szTempMsg), "^3%s^1^4: ^1Дам совет: Держите себя подольше от бомблейса ^4:)", szDefuserName)
case 3: formatex(szTempMsg, charsmax(szTempMsg), "^4* ^3%s ^1оставил подарок террористам.", szDefuserName)
case 4: formatex(szTempMsg, charsmax(szTempMsg), "^3%s^1^4: ^1Уряя я ломал бомбу ^4:D", szDefuserName)
case 5: formatex(szTempMsg, charsmax(szTempMsg), "^4* ^1Похоже ^3%s ^1хотел пошутить над террористами.", szDefuserName)
case 6: formatex(szTempMsg, charsmax(szTempMsg), "^4* ^1Ваш тиммейт ^3%s ^1сломал бомбу ^4хД", szDefuserName)
case 7: formatex(szTempMsg, charsmax(szTempMsg), "^4* ^1Осторожно! ^3%s ^1только что ломал бомбу.", szDefuserName)
}
for(--iCount; iCount >= 0; iCount--)
{
pReceiver = iPlayers[iCount]
#if !defined TEST_PRINT_CHAT
if(g_pBombDefuser == pReceiver)
continue
#endif
client_print_color(pReceiver, print_team_default, "%s", szTempMsg)
}
}
stock SendFakeAmmo(const pPlayer)
{
static gmsgAmmoPickup; static const AMMO_C4 = 14
if(gmsgAmmoPickup || (gmsgAmmoPickup = get_user_msgid("AmmoPickup")))
{
set_msg_block(gmsgAmmoPickup, BLOCK_ONCE)
message_begin(MSG_ONE, gmsgAmmoPickup, .player = pPlayer)
write_byte(AMMO_C4)
write_byte(2) // amount
message_end()
}
}
stock BotPlantBomb(value)
{
if(!bot_deathmatch)
return
if((value == 1 && random_float(0.0, 5.00) < 1.77) || value == 0) {
set_pcvar_num(bot_deathmatch, value)
}
}
// by VEN
stock get_loguser_index()
{
new loguser[80], name[32]
read_logargv(0, loguser, charsmax(loguser))
parse_loguser(loguser, name, charsmax(name))
return get_user_index(name)
}
/**
* Credits:
*
* - s1lent - за проект ReGameDLL (и за sdk)
* - voed - за идею (плагина "CT Bomb Defusing")
*
*/
///■■■■■■■■■■■■■■■■■■■■■■■ CONFIG START ■■■■■■■■■■■■■■■■■■■■■■■//
#define DEFUSE_TIME 8 // Время разминирование в секундах (с щипцами 2 раза быстрее)
#define FIXING_TIME 5 // Время исправление бомбы в секундах (чтоб запретить просто закомментируйте)
#define BOMB_DETONATE_TIME 1 // Время взрыва после плента (0 = сразу)
#define BOMB_RADIUS 100 // Радиус взрыва. Закомментить если нужен дефолтный (по дефолту 500 юнитов)
//#define BOMB_USE_SAMPLE "weapons/c4_disarmed.wav" // Закомментируйте, если не нужен
//#define CANT_ATTACK // Запретить атаку(ЛКМ) при дефузе/фиксе (как в оригинале)
//#define CANT_RUN // Заморозка при при дефузе/фиксе (как в оригинале)
#define TEST_PRINT_CHAT // для тестов
///■■■■■■■■■■■■■■■■■■■■■■■■ CONFIG END ■■■■■■■■■■■■■■■■■■■■■■■■//
#include <amxmodx>
#include <hamsandwich>
#include <reapi>
#if AMXX_VERSION_NUM < 183
#include <colorchat>
#endif
#define PL_VERSION "0.0.4"
#define MAX_BOMB_RADIUS 2048.0
#define IsPlayer(%1) (1 <= %1 <= g_iMaxPlayers)
#define IsOnGround(%1) ((get_entvar(%1, var_flags) & FL_ONGROUND) == FL_ONGROUND)
new g_iMaxPlayers, g_iC4TimerOld, bot_deathmatch
#if defined CANT_RUN
new HookChain:g_hResetMaxSpeed
#endif
new HamHook:g_hBombThink
new g_pBombDefuser, g_pBombPlanter, g_pBombFixer
new bool:g_bStartDefuse, bool:g_bBombCracked, bool:g_bStartFix
new Float:g_flFixCountDown, Float:g_flNextFix, Float:g_flDefuseCountDown, Float:g_flNextDefuse
#if defined BOMB_RADIUS
new Float:g_flBombRadiusDefault
#endif
#if defined BOMB_USE_SAMPLE
public plugin_precache()
{
precache_sound(BOMB_USE_SAMPLE)
}
#endif
public plugin_init()
{
register_plugin("CT Bomb Cracker", PL_VERSION, "Vaqtincha")
if(!get_member_game(m_bMapHasBombTarget))
{
pause("ad")
return
}
register_logevent("LogEvent_BombPlanted", 3, "2=Planted_The_Bomb")
RegisterHam(Ham_ObjectCaps, "weaponbox", "CWeaponbox_ObjectCaps", .Post = false)
RegisterHam(Ham_Use, "weaponbox", "CWeaponbox_Use", .Post = false)
DisableHamForward(g_hBombThink = RegisterHam(Ham_Think, "weaponbox", "CWeaponbox_Think", .Post = false))
RegisterHam(Ham_Item_AddToPlayer, "weapon_c4", "CBasePlayerItem_AddToPlayer", .Post = true)
RegisterHookChain(RG_RoundEnd, "RoundEnd", .post = false)
RegisterHookChain(RG_CSGameRules_RestartRound, "CSGameRules_RestartRound", .post = false)
#if defined CANT_RUN
DisableHookChain(g_hResetMaxSpeed = RegisterHookChain(RG_CBasePlayer_ResetMaxSpeed, "CBasePlayer_ResetMaxSpeed", .post = false))
#endif
#if defined BOMB_RADIUS
g_flBombRadiusDefault = floatmin(Float:get_member_game(m_flBombRadius), MAX_BOMB_RADIUS)
#endif
bot_deathmatch = get_cvar_pointer("bot_deathmatch")
g_iMaxPlayers = get_maxplayers()
}
#if AMXX_VERSION_NUM < 183
public client_disconnect(pPlayer)
#else
public client_disconnected(pPlayer)
#endif
{
if(pPlayer == g_pBombDefuser) {
g_pBombDefuser = 0
}
else if(pPlayer == g_pBombPlanter) {
g_pBombPlanter = 0
}
else if(pPlayer == g_pBombFixer) {
g_pBombFixer = 0
}
}
public CSGameRules_RestartRound()
{
#if defined BOMB_RADIUS
if(g_flBombRadiusDefault > 0.0 && g_bBombCracked) {
set_member_game(m_flBombRadius, g_flBombRadiusDefault)
}
#endif
ForwardToggle(false)
g_bStartDefuse = g_bBombCracked = g_bStartFix = false
g_flDefuseCountDown = g_flNextDefuse = g_flFixCountDown = g_flNextFix = 0.0
g_pBombDefuser = g_pBombPlanter = g_pBombFixer = 0
}
public RoundEnd(const WinStatus:status, const ScenarioEventEndRound:event, const Float:tmDelay)
{
if(!g_bBombCracked) // || !g_pBombDefuser
return HC_CONTINUE
if(status == WINSTATUS_TERRORISTS && event == ROUND_TARGET_BOMB)
{
if(/* IsPlayer(g_pBombPlanter) && */ is_user_connected(g_pBombPlanter))
{
new Float:flFrags
get_entvar(g_pBombPlanter, var_frags, flFrags)
if(flFrags) {
set_entvar(g_pBombPlanter, var_frags, flFrags - 3.0)
}
}
rg_round_end(tmDelay, WINSTATUS_CTS, ROUND_BOMB_DEFUSED)
// set_member_game(m_iNumCTWins, get_member_game(m_iNumCTWins) + 1)
rg_update_teamscores(.iCtsWins = 1)
SetHookChainReturn(ATYPE_INTEGER, false)
return HC_SUPERCEDE
}
return HC_CONTINUE
}
public LogEvent_BombPlanted()
{
if(!g_bBombCracked) // || !g_pBombDefuser
return
g_pBombPlanter = get_loguser_index()
if(is_user_connected(g_pBombPlanter))
{
if(random(2) == 1)
client_print_color(g_pBombPlanter, print_team_default, "^4* ^1Через ^3%d ^1сек. вам пздс.", BOMB_DETONATE_TIME)
else
client_print_color(g_pBombPlanter, print_team_default, "^4* ^1У вас есть ^3%d ^1сек. чтоб спасать свою жопу", BOMB_DETONATE_TIME)
}
}
#if defined CANT_RUN
public CBasePlayer_ResetMaxSpeed(const pPlayer)
{
if(pPlayer != g_pBombDefuser)
return HC_CONTINUE
set_entvar(pPlayer, var_maxspeed, 1.0)
return HC_SUPERCEDE
}
#endif
public CBasePlayerItem_AddToPlayer(const pWeapon, const pPlayer)
{
if(pWeapon <= 0)
return HAM_IGNORED
new pWeaponBox = get_entvar(pWeapon, var_owner)
if(pWeaponBox > 0 && FClassnameIs(pWeaponBox, "weaponbox")) {
set_task(0.2, "CWeaponBox_Killed", pWeaponBox)
}
if(g_bBombCracked && is_user_connected(pPlayer)) {
SendFakeAmmo(pPlayer) // типа подсказка (!) :D
}
return HAM_IGNORED
}
// Кто-то поднял бомбу при дефузе/фиксе отменим все
public CWeaponBox_Killed(const pWeaponBox)
{
if(is_nullent(pWeaponBox))
{
// server_print("g_bStartFix %s g_bStartDefuse %s", g_bStartFix ? "true":"false", g_bStartDefuse ? "true":"false")
if(g_bStartFix)
{
FinishDefuse(g_pBombFixer)
g_pBombFixer = 0
}
if(g_bStartDefuse)
{
FinishDefuse(g_pBombDefuser)
g_pBombDefuser = 0
}
}
}
public CWeaponbox_Think(const pWeaponBox)
{
if(pWeaponBox <= 0 || !get_member(pWeaponBox, m_WeaponBox_bIsBomb))
return HAM_IGNORED
new Float:flCurTime = get_gametime()
if(g_bStartDefuse && IsPlayer(g_pBombDefuser))
{
if(flCurTime < g_flDefuseCountDown)
{
new bool:bOnGround = IsOnGround(g_pBombDefuser)
if(flCurTime > g_flNextDefuse || !bOnGround)
{
if(!bOnGround) {
client_print(g_pBombDefuser, print_center, "Вы должны находиться на земле^rчтобы сломать бомбу!")
}
FinishDefuse(g_pBombDefuser)
g_pBombDefuser = 0
return HAM_IGNORED
}
}
else if(flCurTime >= g_flDefuseCountDown && get_entvar(g_pBombDefuser, var_deadflag) == DEAD_NO && (get_user_flags(g_pBombDefuser) & ADMIN_VOTE))
{
client_print(g_pBombDefuser, print_center, "Вы успешно сломали бомбу!")
FinishDefuse(g_pBombDefuser)
// BotPlantBomb(1)
PrintChatAll()
g_pBombFixer = 0
g_bBombCracked = true
g_iC4TimerOld = get_member_game(m_iC4Timer)
set_member_game(m_iC4Timer, max(0, BOMB_DETONATE_TIME))
#if defined BOMB_RADIUS
set_member_game(m_flBombRadius, floatmin(BOMB_RADIUS.0, MAX_BOMB_RADIUS))
#endif
}
else
{
FinishDefuse(g_pBombDefuser)
g_pBombDefuser = 0
}
}
else if(g_bStartFix && IsPlayer(g_pBombFixer))
{
if(flCurTime < g_flFixCountDown)
{
new bool:bOnGround = IsOnGround(g_pBombFixer)
if(flCurTime > g_flNextFix || !bOnGround)
{
if(!bOnGround) {
client_print(g_pBombFixer, print_center, "Вы должны находиться на земле^rчтобы исправить бомбу!")
}
FinishDefuse(g_pBombFixer)
g_pBombFixer = 0
return HAM_IGNORED
}
}
else if(flCurTime >= g_flFixCountDown && get_entvar(g_pBombFixer, var_deadflag) == DEAD_NO)
{
client_print(g_pBombFixer, print_center, "Вы успешно исправили бомбу!")
FinishDefuse(g_pBombFixer)
// BotPlantBomb(0)
// PrintChatAll() // пока нет сообщений для теров
g_pBombDefuser = 0
g_bBombCracked = false
if(g_iC4TimerOld) {
set_member_game(m_iC4Timer, g_iC4TimerOld)
}
#if defined BOMB_RADIUS
if(g_flBombRadiusDefault > 0.0) {
set_member_game(m_flBombRadius, g_flBombRadiusDefault)
}
#endif
}
else
{
FinishDefuse(g_pBombFixer)
g_pBombFixer = 0
}
}
// CWeaponBox::BombThink() nextthink = 1.0 CGrenade::C4Think() nextthink = 0.12
set_entvar(pWeaponBox, var_nextthink, flCurTime + 0.2)
return HAM_SUPERCEDE
}
public CWeaponbox_ObjectCaps(const pWeaponBox)
{
if(pWeaponBox <= 0 || !get_member(pWeaponBox, m_WeaponBox_bIsBomb))
return HAM_IGNORED
SetHamReturnInteger(FCAP_CONTINUOUS_USE|FCAP_ONOFF_USE) // FCAP_ONOFF_USE unpressed button hook (value == 0.0)
return HAM_SUPERCEDE
}
public CWeaponbox_Use(const pWeaponBox, const pPlayer, const pCaller, const use_type, const Float:value)
{
if(pWeaponBox <= 0 || !IsPlayer(pPlayer) /* || !IsOnGround(pWeaponBox) */ )
return HAM_IGNORED
new TeamName:iTeam = get_member(pPlayer, m_iTeam)
#if !defined FIXING_TIME
if(iTeam != TEAM_CT)
return HAM_SUPERCEDE
#endif
new Float:flCurTime = get_gametime()
#if defined FIXING_TIME
if(iTeam == TEAM_CT)
#endif
{
if(g_bBombCracked)
{
if(g_pBombDefuser != pPlayer) {
client_print(pPlayer, print_center, "Бомба уже сломана!")
}
return HAM_SUPERCEDE
}
if(value == 1.0)
{
if(g_bStartDefuse)
{
g_flNextDefuse = flCurTime + 0.2
return HAM_SUPERCEDE // return HAM_IGNORED
}
new iSeconds = (get_member(pPlayer, m_bHasDefuser) ? (DEFUSE_TIME / 2) : DEFUSE_TIME)
g_bStartDefuse = true
g_pBombDefuser = pPlayer
g_flDefuseCountDown = flCurTime + float(iSeconds)
g_flNextDefuse = flCurTime + 0.2
StartDefuse(pPlayer, pWeaponBox, iSeconds)
}
else if(value == 0.0)
{
FinishDefuse(pPlayer)
g_pBombDefuser = 0
}
}
#if defined FIXING_TIME
else if(iTeam == TEAM_TERRORIST)
{
if(!g_bBombCracked)
{
if(g_pBombFixer != pPlayer) {
client_print(pPlayer, print_center, "Бомба исправен!")
}
return HAM_SUPERCEDE
}
if(value == 1.0)
{
if(g_bStartFix)
{
g_flNextFix = flCurTime + 0.2
return HAM_SUPERCEDE // return HAM_IGNORED
}
g_bStartFix = true
g_pBombFixer = pPlayer
g_flFixCountDown = flCurTime + float(FIXING_TIME)
g_flNextFix = flCurTime + 0.2
StartDefuse(pPlayer, pWeaponBox, FIXING_TIME)
}
else if(value == 0.0)
{
FinishDefuse(pPlayer)
g_pBombFixer = 0
}
}
#endif
return HAM_IGNORED
}
StartDefuse(const pPlayer, const pWeaponBox, const iTime)
{
#if defined BOMB_USE_SAMPLE
emit_sound(pWeaponBox, CHAN_WEAPON, BOMB_USE_SAMPLE, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
#endif
#if defined CANT_ATTACK
set_member(pPlayer, m_bIsDefusing, true)
#endif
#if defined CANT_RUN
set_entvar(pPlayer, var_maxspeed, 1.0)
#endif
rg_send_bartime(pPlayer, iTime)
set_member(pPlayer, m_bShieldDrawn, true)
ForwardToggle(true)
}
FinishDefuse(const pPlayer)
{
g_bStartDefuse = g_bStartFix = false
g_flDefuseCountDown = g_flNextDefuse = g_flFixCountDown = g_flNextFix = 0.0
ForwardToggle(false)
if(is_user_connected(pPlayer))
{
rg_send_bartime(pPlayer, 0) // reset bartime
#if defined CANT_RUN
rg_reset_maxspeed(pPlayer)
#endif
#if defined CANT_ATTACK
set_member(pPlayer, m_bIsDefusing, false)
#endif
set_member(pPlayer, m_bShieldDrawn, false)
}
}
ForwardToggle(const bool:Enable)
{
if(Enable)
{
EnableHamForward(g_hBombThink)
#if defined CANT_RUN
EnableHookChain(g_hResetMaxSpeed)
#endif
}
else
{
DisableHamForward(g_hBombThink)
#if defined CANT_RUN
DisableHookChain(g_hResetMaxSpeed)
#endif
}
}
PrintChatAll()
{
new iPlayers[32], szDefuserName[32], szTempMsg[140], iCount, pReceiver
get_players(iPlayers, iCount, "ace", "CT")
get_user_name(g_pBombDefuser, szDefuserName, charsmax(szDefuserName))
switch(random_num(1, 7))
{
case 1: formatex(szTempMsg, charsmax(szTempMsg), "^3%s^1^4: ^1Можно больше не кемперить на бомблейсе...", szDefuserName)
case 2: formatex(szTempMsg, charsmax(szTempMsg), "^3%s^1^4: ^1Дам совет: Держите себя подольше от бомблейса ^4:)", szDefuserName)
case 3: formatex(szTempMsg, charsmax(szTempMsg), "^4* ^3%s ^1оставил подарок террористам.", szDefuserName)
case 4: formatex(szTempMsg, charsmax(szTempMsg), "^3%s^1^4: ^1Уряя я ломал бомбу ^4:D", szDefuserName)
case 5: formatex(szTempMsg, charsmax(szTempMsg), "^4* ^1Похоже ^3%s ^1хотел пошутить над террористами.", szDefuserName)
case 6: formatex(szTempMsg, charsmax(szTempMsg), "^4* ^1Ваш тиммейт ^3%s ^1сломал бомбу ^4хД", szDefuserName)
case 7: formatex(szTempMsg, charsmax(szTempMsg), "^4* ^1Осторожно! ^3%s ^1только что ломал бомбу.", szDefuserName)
}
for(--iCount; iCount >= 0; iCount--)
{
pReceiver = iPlayers[iCount]
#if !defined TEST_PRINT_CHAT
if(g_pBombDefuser == pReceiver)
continue
#endif
client_print_color(pReceiver, print_team_default, "%s", szTempMsg)
}
}
stock SendFakeAmmo(const pPlayer)
{
static gmsgAmmoPickup; static const AMMO_C4 = 14
if(gmsgAmmoPickup || (gmsgAmmoPickup = get_user_msgid("AmmoPickup")))
{
set_msg_block(gmsgAmmoPickup, BLOCK_ONCE)
message_begin(MSG_ONE, gmsgAmmoPickup, .player = pPlayer)
write_byte(AMMO_C4)
write_byte(2) // amount
message_end()
}
}
stock BotPlantBomb(value)
{
if(!bot_deathmatch)
return
if((value == 1 && random_float(0.0, 5.00) < 1.77) || value == 0) {
set_pcvar_num(bot_deathmatch, value)
}
}
// by VEN
stock get_loguser_index()
{
new loguser[80], name[32]
read_logargv(0, loguser, charsmax(loguser))
parse_loguser(loguser, name, charsmax(name))
return get_user_index(name)
}
Добавил вот что:
Код:
else if(flCurTime >= g_flDefuseCountDown && get_entvar(g_pBombDefuser, var_deadflag) == DEAD_NO && (get_user_flags(g_pBombDefuser) & ADMIN_VOTE))
Подскажите пожалуйста, куда еще нужно прописать условие для полноценной работы.
Спасибо!
Вложения
-
14.5 KB Просмотры: 7