Обратите внимание, если вы хотите заключить сделку с этим пользователем, он заблокирован
- Ошибка
-
flashbang_ban.sma(53) : error 017: undefined symbol "MAX_PLAYERS"
flashbang_ban.sma(54) : error 009: invalid array size (negative or zero)
flashbang_ban.sma(63) : error 017: undefined symbol "RG_ThrowFlashbang"
flashbang_ban.sma(63) : warning 215: expression has no effect
flashbang_ban.sma(63) : error 001: expected token: ";", but found ")"
flashbang_ban.sma(63) : error 029: invalid expression, assumed zero
flashbang_ban.sma(63) : fatal error 107: too many error messages on one line
- Компилятор
- WEB-компилятор
- Amx Mod X
- 1.9.0
- Исходный код
-
0.2 ->
* Добавлена опция ответного ослепления (квар 'flashban_reflect_flash')
* Исправлен неверный lang-ключ 'FLBAN__FLASHED_BY' (спасибо Fanfar: https://dev-cs.ru/members/2074/)
*/
new const PLUGIN_NAME[] = "Flashbang Ban"
new const PLUGIN_VERSION[] = "0.2"
new const PLUGIN_AUTHOR[] = "mx?!"
#include <amxmodx>
#include <reapi>
#define chx charsmax
#define AUTO_CFG // Создавать конфиг с кварами в 'configs/plugins', и запускать его ?
new const SOUND__BLIP1[] = "sound/buttons/blip1.wav"
new const SOUND__ERROR[] = "sound/buttons/button2.wav"
new const SOUND__TUTOR_MSG[] = "sound/events/tutor_msg.wav"
enum {
HAS_AUTH,
IS_CONNECTED
}
enum _:CVAR_ENUM {
CVAR__ENABLED,
CVAR__MAX_WARNS,
CVAR__BAN_ROUNDS,
CVAR__DEC_WARNS,
CVAR__ONLY_FULL,
CVAR__REFLECT,
CVAR__IMMUNE_FLAGS
}
enum _:RGB { any:R, any:G, any:B }
const FULL_BLIND = 255
new g_eCvar[CVAR_ENUM], g_szAuthID[24], g_iBan[MAX_PLAYERS + 1], g_iWarn[MAX_PLAYERS + 1]
new Trie:g_tTrie, g_szName[MAX_NAME_LENGTH], g_iPlayerFlags[MAX_PLAYERS + 1], g_MsgScreenFade
/* -------------------- */
public plugin_init() {
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
register_dictionary("flashbang_ban.txt")
RegisterHookChain(RG_PlayerBlind, "OnPlayerBlind_Pre")
RegisterHookChain(RG_ThrowFlashbang, "OnThrowFlashbang_Pre")
RegisterHookChain(RG_CBasePlayer_HasRestrictItem, "OnHasRestrictItem_Pre")
RegisterHookChain(RG_CSGameRules_RestartRound, "OnRestartRound_Pre")
bind_pcvar_num(create_cvar("flashban_enabled", "1", .description = "Working state"), g_eCvar[CVAR__ENABLED])
bind_pcvar_num(create_cvar("flashban_max_warns", "3", .description = "Warns limit to ban flash", .has_min = true, .min_val = 1.0), g_eCvar[CVAR__MAX_WARNS])
bind_pcvar_num(create_cvar("flashban_ban_rounds", "3", .description = "How many rounds flash will be banned", .has_min = true, .min_val = 1.0), g_eCvar[CVAR__BAN_ROUNDS])
bind_pcvar_num(create_cvar("flashban_dec_warns", "1", .description = "How many warns decreased every round", .has_min = true, .min_val = 1.0), g_eCvar[CVAR__DEC_WARNS])
bind_pcvar_num(create_cvar("flashban_only_full", "1", .description = "Increase warn only if fullflashed"), g_eCvar[CVAR__ONLY_FULL])
bind_pcvar_num(create_cvar("flashban_reflect_flash", "0", .description = "Reflect teamflash to flasher"), g_eCvar[CVAR__REFLECT])
new szVal[12], pCvar = create_cvar("flashban_immune_flags", " ", .description = "Immunity flags")
hook_cvar_change(pCvar, "func_CvarHook")
get_pcvar_string(pCvar, szVal, chx(szVal))
func_ReadFlags(szVal)
g_tTrie = TrieCreate()
g_MsgScreenFade = get_user_msgid("ScreenFade")
#if defined AUTO_CFG
AutoExecConfig()
#endif
}
/* -------------------- */
public func_CvarHook(pCvar, szOldVal[], szNewVal[]) {
func_ReadFlags(szNewVal)
}
/* -------------------- */
stock func_ReadFlags(szVal[]) {
g_eCvar[CVAR__IMMUNE_FLAGS] = read_flags(szVal)
}
/* -------------------- */
public OnPlayerBlind_Pre(iVictim, iInflictor, iAttacker, Float:fFadeTime, Float:fFadeHold, iAlpha, Float:fColor[RGB]) {
if(
!g_eCvar[CVAR__ENABLED]
||
iVictim == iAttacker
||
!CheckFlag(iAttacker, IS_CONNECTED)
||
!IsInSameTeam(iVictim, iAttacker)
) {
return
}
get_user_name(iAttacker, g_szName, chx(g_szName))
client_print_color(iVictim, print_team_default, "%L", iVictim, "FLBAN__CHAT_FLASHED_BY", g_szName)
console_print(iVictim, "%L", iVictim, "FLBAN__CON_FLASHED_BY", g_szName)
rg_send_audio(iVictim, SOUND__TUTOR_MSG)
/* --- */
rg_send_audio(iAttacker, SOUND__TUTOR_MSG)
get_user_name(iVictim, g_szName, chx(g_szName))
if(get_user_flags(iAttacker) & g_eCvar[CVAR__IMMUNE_FLAGS]) {
client_print_color( iAttacker, print_team_default, "%L", iAttacker,
iAlpha == FULL_BLIND ? "FLBAN__IMM_FLASHED_PLAYER_FULL" : "FLBAN__IMM_FLASHED_PLAYER_PART", g_szName );
return
}
if(!g_eCvar[CVAR__ONLY_FULL] || iAlpha == FULL_BLIND) {
g_iWarn[iAttacker]++
}
if(g_eCvar[CVAR__REFLECT] && IsNotFullyBlinded(iAttacker, iAlpha)) {
func_FlashPlayer(iAttacker, fFadeTime, fFadeHold, fColor, iAlpha)
}
client_print_color( iAttacker, print_team_default, "%L", iAttacker,
iAlpha == FULL_BLIND ? "FLBAN__FLASHED_PLAYER_FULL" : "FLBAN__FLASHED_PLAYER_PART",
g_szName, g_iWarn[iAttacker], g_eCvar[CVAR__MAX_WARNS] );
if(g_iWarn[iAttacker] < g_eCvar[CVAR__MAX_WARNS] || g_iBan[iAttacker]) {
return
}
client_print(iAttacker, print_center, "%L", iAttacker, "FLBAN__CENTER_FLASH_BANNED")
g_iBan[iAttacker] = g_eCvar[CVAR__BAN_ROUNDS]
}
/* -------------------- */
public OnThrowFlashbang_Pre(id) {
if(!g_iBan[id]) {
return HC_CONTINUE
}
func_BanInfo(id)
SetHookChainReturn(ATYPE_INTEGER, false)
return HC_SUPERCEDE
}
/* -------------------- */
public OnHasRestrictItem_Pre(id, ItemID:iItem, ItemRestType:iRestType) {
if(!g_iBan[id] || iRestType != ITEM_TYPE_BUYING || iItem != ITEM_FLASHBANG) {
return HC_CONTINUE
}
func_BanInfo(id)
SetHookChainReturn(ATYPE_INTEGER, true)
return HC_SUPERCEDE
}
/* -------------------- */
public OnRestartRound_Pre() {
if(!g_eCvar[CVAR__ENABLED]) {
return
}
new iPlayers[MAX_PLAYERS], iPlCount
get_players(iPlayers, iPlCount, "ch")
for(new i, iPlayer; i < iPlCount; i++) {
iPlayer = iPlayers[i]
if(g_iWarn[iPlayer]) {
g_iWarn[iPlayer] = max(0, g_iWarn[iPlayer] - g_eCvar[CVAR__DEC_WARNS])
}
if(!g_iBan[iPlayer]) {
continue
}
g_iBan[iPlayer]--
if(!g_iBan[iPlayer]) {
rg_send_audio(iPlayer, SOUND__BLIP1)
client_print_color(iPlayer, print_team_default, "%L", iPlayer, "FLBAN__BAN_EXPIRED")
}
}
}
/* -------------------- */
stock func_BanInfo(id) {
rg_send_audio(id, SOUND__ERROR)
client_print(id, print_center, "%L", id, "FLBAN__CENTER_FLASH_BANNED")
client_print_color(id, print_team_red, "%L", id, "FLBAN__INFO", g_iBan[id])
}
/* -------------------- */
public client_authorized(id) {
SetFlag(id, HAS_AUTH)
if(CheckFlag(id, IS_CONNECTED)) {
func_AgregatePlayer(id)
}
}
/* -------------------- */
public client_putinserver(id) {
SetFlag(id, IS_CONNECTED)
if(CheckFlag(id, HAS_AUTH)) {
func_AgregatePlayer(id)
}
}
/* -------------------- */
public func_AgregatePlayer(id) {
if(!g_eCvar[CVAR__ENABLED]) {
return
}
get_user_authid(id, g_szAuthID, chx(g_szAuthID))
if(TrieGetCell(g_tTrie, g_szAuthID, g_iBan[id])) {
TrieDeleteKey(g_tTrie, g_szAuthID)
}
}
/* -------------------- */
public client_disconnected(id) {
g_iPlayerFlags[id] = 0
g_iWarn[id] = 0
if(g_iBan[id]) {
get_user_authid(id, g_szAuthID, chx(g_szAuthID))
TrieSetCell(g_tTrie, g_szAuthID, g_iBan[id])
g_iBan[id] = 0
}
}
/* -------------------- */
stock func_FlashPlayer(id, Float:fOutTime, Float:fHoldTime, Float:fColor[RGB], iAlpha) {
message_begin(MSG_ONE_UNRELIABLE, g_MsgScreenFade, .player = id)
write_short(FixedUnsigned16(fOutTime)) // SCREENFADE__OUT_TIME (duration / fade time)
write_short(FixedUnsigned16(fHoldTime)) // SCREENFADE__HOLD_TIME (hold time)
write_short(0x0000) // fade in
write_byte(floatround(fColor[R]))
write_byte(floatround(fColor[G]))
write_byte(floatround(fColor[B]))
write_byte(iAlpha)
message_end()
new Float:fGameTime = get_gametime()
set_member(id, m_blindStartTime, fGameTime)
set_member(id, m_blindFadeTime, fOutTime)
set_member(id, m_blindHoldTime, fHoldTime)
set_member(id, m_blindUntilTime, fGameTime + fOutTime)
set_member(id, m_blindAlpha, iAlpha)
}
/* -------------------- */
stock FixedUnsigned16(Float:fVal, iScale = (1 << 12)) {
return clamp(floatround(fVal * iScale), 0, 0xFFFF)
}
/* -------------------- */
stock bool:IsNotFullyBlinded(id, iAlpha) {
return bool:(
get_member(id, m_blindAlpha) < iAlpha
||
Float:get_member(id, m_blindStartTime) + Float:get_member(id, m_blindHoldTime) < get_gametime()
);
}
/* -------------------- */
public plugin_end() {
TrieDestroy(g_tTrie)
}
/* -------------------- */
stock SetFlag(id, iFlag) (g_iPlayerFlags[id] |= (1 << iFlag))
stock ClearFlag(id, iFlag) (g_iPlayerFlags[id] &= ~(1 << iFlag))
stock CheckFlag(id, iFlag) return (g_iPlayerFlags[id] & (1 << iFlag))
stock bool:IsInSameTeam(iPlayer1, iPlayer2) return (get_member(iPlayer1, m_iTeam) == get_member(iPlayer2, m_iTeam))
Здравствуйте ребят) помогите компилировать, не получается что то
В этой теме было размещено решение! Перейти к решению.