Ошибка в плагине Reklama

Сообщения
23
Реакции
2
Предупреждения
5
Ошибка
L 05/12/2020 - 17:50:09: Invalid index 25 (count: 25)
L 05/12/2020 - 17:50:09: [AMXX] Displaying debug trace (plugin "reklama.amxx", version "16.03.2020")
L 05/12/2020 - 17:50:09: [AMXX] Run time error 10: native error (native "ArrayGetArray")
L 05/12/2020 - 17:50:09: [AMXX] [0] reklama.sma::hook_Say (line 403)
ОС
Linux
Amx Mod X
AMX Mod X 1.9.0.5263 (http://www.amxmodx.org)
Authors:
<TAB>David "BAILOPAN" Anderson, Pavol "PM OnoTo" Marko
<TAB>Felix "SniperBeamer" Geyer, Jonny "Got His Gun" Bergstrom
<TAB>Lukasz "SidLuke" Wlasinski, Christian "Basic-Master" Hammacher
<TAB>Borja "faluco" Ferrer, Scott "DS" Ehlert
Compiled: Oct 27 2019 16:23:31
Built from: https://github.com/alliedmodders/amxmodx/commit/15a14a0
Build ID: 5263:15a14a0
Core mode: JIT+ASM32
Билд
Protocol version 48
Exe version 1.1.2.7/Stdio (cstrike)
ReHLDS version: 3.7.0.695-dev
Build date: 15:54:29 Apr 6 2020 (2186)
Build from: https://github.com/dreamstalker/rehlds/commit/7513e71
ReGamedll
ReGameDLL version: 5.16.0.460-dev
Build date: 10:11:49 May 2 2020
Build from: https://github.com/s1lentq/ReGameDLL_CS/commit/4f72525
Версия Metamod
Metamod-r v1.3.0.128, API (5:13)
Metamod-r build: 17:47:54 Aug 24 2018
Metamod-r from: https://github.com/theAsmodai/metamod-r/commit/0cf2f70
Список метамодулей
Currently loaded plugins:
description stat pend file vers src load unload
[ 1] Reunion RUN - reunion_mm_i386.so v0.1.0.92c ini Start Never
[ 2] VoiceTranscoder RUN - VoiceTranscoder.so v2017RC5 ini ANY ANY
[ 3] SafeNameAndChat RUN - SafeNameAndChat.so v1.1 ini ANY ANY
[ 4] ReAuthCheck RUN - reauthcheck_mm_i386.so v0.1.6 ini Start Never
[ 5] Rechecker RUN - rechecker_mm_i386.so v2.5 ini Chlvl ANY
[ 6] WHBlocker RUN - whblocker_mm_i386.so v1.5.697 ini Chlvl ANY
[ 7] ReSemiclip RUN - resemiclip_mm_i386.so v2.3.9 ini Chlvl ANY
[ 8] ReSRDetector RUN - resrdetector_mm_i386.so v0.1.0 ini Chlvl ANY
[ 9] AMX Mod X RUN - amxmodx_mm_i386.so v1.9.0.5263 ini Start ANY
[10] ReAPI RUN - reapi_amxx_i386.so v5.12.0.192-dev pl9 ANY Never
[11] Fun RUN - fun_amxx_i386.so v1.9.0.5263 pl9 ANY ANY
[12] Engine RUN - engine_amxx_i386.so v1.9.0.5263 pl9 ANY ANY
[13] FakeMeta RUN - fakemeta_amxx_i386.so v1.9.0.5263 pl9 ANY ANY
[14] CStrike RUN - cstrike_amxx_i386.so v1.9.0.5263 pl9 ANY ANY
[15] CSX Extended RUN - csx_amxx_i386.so v1.5 pl9 ANY ANY
[16] Ham Sandwich RUN - hamsandwich_amxx_i386.so v1.9.0.5263 pl9 ANY ANY
[17] ReAimDetector RUN - reaimdetector_amxx_i386.so v0.2.2 pl9 ANY Never
[18] AuthEmu RUN - authemu_amxx_i386.so v4.2.12.311-dev+m pl9 ANY Never
[19] MySQL RUN - mysql_amxx_i386.so v1.9.0.5263 pl9 ANY ANY
19 plugins, 19 running
Список плагинов
Currently loaded plugins:
name version author file status
[ 1] GameCMS_API 5.4.5 zhorzh78 gamecms_api_5.4 running
[ 2] ReAimDetector API 0.2.2 ReHLDS Team reaimdetector.a running
[ 3] Anticheat 3.1.6 ctr52 anticheat.amxx running
[ 4] FreshBans 1.4.3b kanagava fresh_bans_143_ running
[ 5] [183] Skill ELO 19.09.06 SKAJIbnEJIb skill_elo.amxx running
[ 6] [183] CsStats MySQL 19.08.27 SKAJIbnEJIb csstats_mysql.a running
[ 7] [183] StatsX RBS 19.08.28 SKAJIbnEJIb & AM statsx_rbs.amxx running
[ 8] Stats Configuration 18.05.15 SKAJIbnEJIb & AM statscfg_rbs.am running
[ 9] GameCMS_GagManager 2.2.3 zhorzh78 gamecms_gagmana running
[ 10] From Rock to Ban 1.02 Safety1st++ rock2gag.amxx running
[ 11] [190] Ultimate Weapons 19.11.29 SKAJIbnEJIb ultimate_weapon running
[ 12] [190] VIP RBS 19.12.09 SKAJIbnEJIb vip_rbs.amxx running
[ 13] [183] Top Award RBS 19.08.28 SKAJIbnEJIb topaward_rbs.am running
[ 14] [183] Damager RBS 19.08.30 SKAJIbnEJIb damager_rbs.amx running
[ 15] GameCMS_VipTest 3.8 zhorzh78 gamecms_viptest running
[ 16] Level System by CSStat 1.5.9 Radius level_system.am running
[ 17] Reklama 16.03.2020 mx?! reklama.amxx debug
[ 18] Admin Votes 1.9.0.5263 AMXX Dev Team adminvote.amxx running
[ 19] Admin Chat 1.9.0.5263 AMXX Dev Team adminchat.amxx running
[ 20] Players Menu 1.7 neugomon players_menu.am running
[ 21] Menus Front-End 1.5 neugomon menufront_end.a running
[ 22] [183] AC Spectator ESP 17.08.09 SKAJIbnEJIb & Ko ac_esp.amxx running
[ 23] [190] Screen Player 20.03.20 SKAJIbnEJIb screen_player.a running
[ 24] Warmup 1.2.2 Radius warmup.amxx running
[ 25] SF Bets 0.1.5 serfreeman1337 sf_bets.amxx running
[ 26] [Reapi] Block Advert 1.4 neygomon block_all_avder running
[ 27] reapi| Reset Score 1.0 Leo_[BH] rs_leo_reapi.am running
[ 28] KiLL Assist poka_4to_b [email protected] Kill_assist_rea running
[ 29] Money 0.1 Mini1 money.amxx running
[ 30] [reAPI] Flash Control 1.1 neugomon flash_control.a running
[ 31] Ping Checker 26.0.1 RC1 h1k3 ping_checker.am running
[ 32] AFK Control 1.4.1 [Rnd neygomon afk_control.amx running
[ 33] Player Votes 1.1 neugomon player_votes.am running
[ 34] Items Restrict 1.1 s1lent items_restrict. running
[ 35] [ReAPI] Best player of 1.1.2 [email protected] best_player_of_ running
[ 36] HeadShot Blood 1.1 tuty hs_blood.amxx running
[ 37] Kills Counter 0.3 serfreeman1337 kills_counter.a running
[ 38] Block Spawn For Reconn 0.1 Bos93 block_spawn.amx running
[ 39] Auto Team Balance Adva 1.5.1 Radius auto_team_balan running
[ 40] AWP Restrictions 1.5.1 Radius awp_restriction running
[ 41] [ReAPI] Block 'Fire in 0.0.1 sergrib reapi_block_FIT running
[ 42] Demo Recorder 2.4.1 [email protected] demo_recorder.a running
[ 43] Smoke: HealthNade 0.0.4b wopox1337 Smoke_HealthNad running
[ 44] [183] Parachute RBS 17.12.12 [email protected]/JTP10181 parachute_rbs.a running
[ 45] [ReAPI] Colored Flash 1.0 ReHLDS Team colored_flash_t running
[ 46] Mode 2x2 2.5re s1lent mode.amxx running
[ 47] Multiple Game Names 1.0 mforce Multiple_Game_N running
[ 48] Auto-Give Privileges 1.0 SerGrib nightvip.amxx stopped
[ 49] First Killer Bonus 0.0.1f wopox1337 FirstKillerBonu running
[ 50] Plugins Controller 1.0 neygomon plugins_control stopped
[ 51] C4 Timer on roundtime 0.3.3a neygomon c4timer.amxx running
[ 52] [Reapi] Custom Models 1.6.1 neygomon custom_models.a running
[ 53] Hide HUD/Menu on Vote 1.2.2 d3m37r4 hide_hud_and_me running
[ 54] Lite NightMode 1.1 neygomon lite_nightmode. running
[ 55] Music Connect 1.1 Leo_[BH] music_connect.a running
[ 56] HS Sound 1.0 M1 TEAM headshot.amxx running
[ 57] DHUD_Adverts_Deads 1.3.1 pUzzlik dhud_message_de running
[ 58] Map Manager: Core 3.0.7 Mistrick map_manager_cor running
[ 59] Map Manager: Scheduler 0.1.5 Mistrick map_manager_sch running
[ 60] Admin Mapmenu 0.5.3 d3m37r4 admin_mapmenu.a running
[ 61] Map Manager: Rtv 0.1.1 Mistrick map_manager_rtv running
[ 62] Map Manager: Nominatio 0.1.2 Mistrick map_manager_nom running
[ 63] Map Manager: BlockList 0.0.3 Mistrick map_manager_blo running
[ 64] Map Manager: Online so 0.0.2 Mistrick map_manager_onl running
[ 65] Map Manager: Effects 0.0.9 Mistrick map_manager_eff running
[ 66] Map Manager: Informer 0.0.5 Mistrick map_manager_inf running
[ 67] Map Manager: Advanced 0.0.5 Mistrick map_manager_adv running
[ 68] [190] Chat RBS 19.12.23 SKAJIbnEJIb chat_rbs.amxx running
68 plugins, 66 running
Автор плагина
BlackSignature
Версия плагина
16.03.2020
Исходный код
/*
Plugin: 'Reklama'

Plugin author: http://t.me/blacksignature / https://dev-cs.ru/members/1111/

Plugin thread: https://dev-cs.ru/resources/435/

Description:
This plugin allows you to:
* Advertise - display predefined chat messages to all with a specified frequency.
* Autorespond - reply to certain player chat messages with predefined chat messages.

Supported features:
* ML keys and wildcard patterns (see 'Setup' section in plugin thread)
* Colored messages
* Mode-based (by cvar value) message output
* Random start position
* Random delay between message output
* Multiple messages at once (multi-output)
* Sounds
* 'On-the-fly' Config reloading
* Players can disable messages for themselves

Credits:
* wopox1337 -> https://dev-cs.ru/members/4/
* fantom -> https://dev-cs.ru/members/16/
* Thx to all who helps me with ideas and bugreports

Requirements:
* Amx Mod X 1.9 - build 5241, or higher

How to use:
1) Install this plugin
2) Tweak 'reklama.ini' config
3) Run plugin
4) Visit 'configs/plugins' to tweak config
5) Change map to reload config
6) Enjoy!

NOTE: It's recomended to place this plugin in 'plugins.ini' above your chat manager

Change history:
29.03.2018:
* Initial public release
06.04.2018:
Added:
* Cvar 'reklama_freq'
Removed:
* Command 'reklama_mode'
* Initialization delay
Fixed:
* Minor bugfixes
29.11.2018:
Added:
* Cvar 'reklama_for_all'
* Cvar 'reklama_mode'
* Ability to disable messages ('say /reklama')
* Option 'CHAT_PREFIX'
Changed:
* Config structure -> added argument 'mode'
29.11.2018 v2:
Added:
* Autoresponder
30.11.2018:
Added:
* Option 'CMD_BLOCK_AUTORESPOND'
* Option 'RANDOM_FREQ'
* Option 'USE_SOUND'
Changed:
* client_cmd() -> func_SendAudio()
* Sound 'ambience/warn1' replaced with 'buttons/button2'
Removed;
* Option 'USE_PRECACHE'
30.11.2018 v2:
Fixed:
* Critical bugfix. Thx zhorzh78 [ https://dev-cs.ru/members/326/ ]
09.07.2019:
Added:
* Wildcard patterns support
* ML-keys support for config messages
Changed:
* Divider '|' for autoresponder pattern, with you can set multiple patterns for one message
* Config format -> added argument 'compare'
* Changed config description
* Config description moved to separate file
* Dictionary was updated (only key 'REKLAMA_KEY_1')
Removed:
* Old AMXX versions support. From now plugin requires AMXX 190+
16.03.2020:
Fixed:
* Autoresponder compatibility with various chat managers based on 'say' hooking
*/

new const PLUGIN_DATE[] = "16.03.2020"

/* ---------------------- SETTINGS START ---------------------- */

// Create cvar config in 'amxmodx/configs/plugins', and execute it?
#define AUTO_CFG

// Hide messages that triggers autoresponder?
// NOTE: It's recomended to place plugin in 'plugins.ini' above your chat manager
#define BLOCK_TRIGGER_MSG

// Allow players to disable messages?
#define CMD_NAME "say /reklama"

// Whether to disable the autoresponder when player personally disable messages
#define CMD_BLOCK_AUTORESPOND

// Prune vault records oldier than this value (in days)
#define OBSOLETE_DAYS 30

// Chat prefix
new const CHAT_PREFIX[] = "" // without prefix
//new const CHAT_PREFIX[] = "^4* "
//new const CHAT_PREFIX[] = "^1[^3Инфо^1] "
//new const CHAT_PREFIX[] = "^1[^4Reklama^1] "

// Use prefix for adverts?
//#define SHOW_PREFIX_WITH_ADS

// Random start position. Useful when you have large config.
// NOTE: Don't forget to set type '2' or '3' for those messages, with you do not want to start
#define RANDOM_START

// Config file name (in 'amxmodx/configs')
new const ADS_FILE_NAME[] = "reklama.ini"

// Lang file name (in 'amxmodx/data/lang')
new const LANG_NAME[] = "reklama.txt"

// Vault name (in 'amxmodx/data/vault')
stock const VAULT_NAME[] = "reklama"

/* --- SOUND SETTINGS --- */

// Sound support ability
#define USE_SOUND

// Sounds
stock const g_szSounds[][] = {
/* 0 */ "buttons/blip1.wav",
/* 1 */ "buttons/blip2.wav",
/* 2 */ "events/tutor_msg.wav",
/* 3 */ "buttons/button2.wav",
/* 4 */ "buttons/bell1.wav",
/* 5 */ "buttons/button3.wav",
/* 6 */ "buttons/button7.wav",
/* 7 */ "buttons/button9.wav",
/* 8 */ "plats/elevbell1.wav",
/* 9 */ "plats/train_use1.wav",
/* 10 */ "x/x_shoot1.wav"
}

/* ---------------------- SETTINGS END ---------------------- */

#include <amxmodx>
#include <amxmisc>
#include <time>

#if defined CMD_NAME
#include <nvault>
#endif

#define chx charsmax
#define chx_len(%0) charsmax(%0) - iLen

#define CheckPatternBit(%0) (g_eMsgData[MSG_PATTERN_BITSUM] & (1<<%0))
#define SetPatternBit(%0) (g_eMsgData[MSG_PATTERN_BITSUM] |= (1<<%0))

#define MODE_AUTO false
#define MODE_MANUAL true

#define MSG_LEN 191
#define TEMPLATE_LEN 191

new const PLUGIN_PREFIX[] = "[Reklama]"

new const SOUND__BLIP1[] = "sound/buttons/blip1.wav"

const TASKID_TIMER = 1337

enum _:CVAR_ENUM {
Float:CVAR__FREQ_MIN,
Float:CVAR__FREQ_MAX,
CVAR__FOR_ALL,
CVAR__MODE,
CVAR__SOUND_FOR_ALL
}

enum _:MSG_STRUCT {
MSG_BODY[MSG_LEN],
MSG_COLOR_ID,
bool:IS_MULTI_MSG,
MSG_SOUND_ID,
bool:NOT_FOR_START,
MSG_MODE,
bool:AUTORESPOND_ONLY,
bool:MSG_IS_LANG_KEY,
MSG_PATTERN_BITSUM
}

enum _:AR_STRUCT {
AR_MODE,
POINTER,
TEMPLATE[TEMPLATE_LEN]
}

enum {
AR_MODE__EX_INSENS,
AR_MODE__EX_SENS,
AR_MODE__MATCH_INSENS,
AR_MODE__MATCH_SENS
}

enum _:PATTERNS_ENUM {
PATTERN__HOSTNAME,
PATTERN__MAXPLAYERS,
PATTERN__NUMPLAYERS,
PATTERN__SERVER_IP,
PATTERN__MAPNAME,
PATTERN__SV_CONTACT,
PATTERN__TIMELEFT,
PATTERN__PLAYER_NAME,
PATTERN__PLAYER_STEAMID,
PATTERN__PLAYER_IP
}

new const PATTERNS[PATTERNS_ENUM][] = {
"#hostname#",
"#maxplayers#",
"#numplayers#",
"#server_ip#",
"#mapname#",
"#contact#",
"#timeleft#",
"#name#",
"#steamid#",
"#ip#"
}

new g_eCvar[CVAR_ENUM]
new Array:g_aMsgArray
new Array:g_aAuReArray
new g_eMsgData[MSG_STRUCT]
new g_AuReData[AR_STRUCT]
new g_iMsgCount
new g_iAuReCount
new g_iCurPos
new g_iFirstSkipPos
new g_szFilePath[PLATFORM_MAX_PATH]
new g_szBuffer[MAX_AUTHID_LENGTH] // don't decrease it's size!
new g_szMsg[MSG_LEN]

stock g_bDisabled[MAX_PLAYERS + 1]
stock g_hVault = INVALID_HANDLE
stock g_iMsgIdSendAudio

/* -------------------- */

public plugin_precache() {
register_plugin("Reklama", PLUGIN_DATE, "mx?!")

register_clcmd("say", "hook_Say")
register_clcmd("say_team", "hook_Say")

#if defined CMD_NAME
register_clcmd(CMD_NAME, "clcmd_ToggleState")
#endif

#if defined USE_SOUND
for(new i; i < sizeof(g_szSounds); i++) {
precache_sound(g_szSounds[i])
}
#endif
}

/* -------------------- */

public plugin_init() {
register_dictionary(LANG_NAME)

/* --- */

func_RegCvars()

/* --- */

#if defined USE_SOUND
g_iMsgIdSendAudio = get_user_msgid("SendAudio")
#endif
}

/* -------------------- */

public plugin_cfg() {
g_aAuReArray = ArrayCreate(AR_STRUCT, 1)
g_aMsgArray = ArrayCreate(MSG_STRUCT)

/* --- */

func_LoadMessages(MODE_AUTO)

/* --- */

// Status: Total message count, current position
register_srvcmd("reklama_status", "srvcmd_CmdShowStatus")
// Print specified message (example: reklama_show 5)
register_srvcmd("reklama_show", "srvcmd_CmdShowCustomMessage")
// Reload messages config
register_srvcmd("reklama_reload", "srvcmd_CmdReloadFile")

/* --- */

#if defined CMD_NAME
g_hVault = nvault_open(VAULT_NAME)

#if defined OBSOLETE_DAYS
if(g_hVault != INVALID_HANDLE) {
nvault_prune(g_hVault, 0, get_systime() - (OBSOLETE_DAYS * SECONDS_IN_DAY))
}
#endif
#endif
}

/* -------------------- */

public hook_Say(id) {
#if defined CMD_BLOCK_AUTORESPOND
if(!g_iAuReCount || g_bDisabled[id]) {
#else
if(!g_iAuReCount) {
#endif
return PLUGIN_CONTINUE
}

new szMessage[MSG_LEN]

read_args(szMessage, chx(szMessage))
remove_quotes(szMessage)
trim(szMessage)

for(new i; i < g_iAuReCount; i++) {
ArrayGetArray(g_aAuReArray, i, g_AuReData)

switch(g_AuReData[AR_MODE]) {
case AR_MODE__EX_INSENS: {
if(containi(szMessage, g_AuReData[TEMPLATE]) == -1) {
continue
}
}
case AR_MODE__EX_SENS: {
if(contain(szMessage, g_AuReData[TEMPLATE]) == -1) {
continue
}
}
case AR_MODE__MATCH_INSENS: {
new iPos = containi(szMessage, g_AuReData[TEMPLATE])

if(iPos == -1) {
continue
}

if(iPos && szMessage[iPos - 1] != ' ') {
continue
}

iPos = strlen(g_AuReData[TEMPLATE]) + iPos // calculate end pos of pattern

if(szMessage[iPos] && szMessage[iPos] != ' ') {
continue
}
}
case AR_MODE__MATCH_SENS: {
new iPos = contain(szMessage, g_AuReData[TEMPLATE])

if(iPos == -1) {
continue
}

if(iPos && szMessage[iPos - 1] != ' ') {
continue
}

iPos = strlen(g_AuReData[TEMPLATE]) + iPos // calculate end pos of pattern

if(szMessage[iPos] && szMessage[iPos] != ' ') {
continue
}
}
}

ArrayGetArray(g_aMsgArray, g_AuReData[POINTER], g_eMsgData)

if(g_eMsgData[MSG_MODE] && g_eCvar[CVAR__MODE] != g_eMsgData[MSG_MODE]) {
return PLUGIN_CONTINUE
}

func_ShowToSingle(id)

while(g_eMsgData[IS_MULTI_MSG]) {
ArrayGetArray(g_aMsgArray, ++g_AuReData[POINTER], g_eMsgData)
func_ShowToSingle(id)
}

#if defined BLOCK_TRIGGER_MSG
return PLUGIN_HANDLED
#else
return PLUGIN_CONTINUE
#endif
}

return PLUGIN_CONTINUE
}

/* -------------------- */

stock func_ShowToSingle(pPlayer) {
if(g_eMsgData[MSG_IS_LANG_KEY]) {
func_ReplaceML(pPlayer)
func_ReplacePatterns(pPlayer)
}
else {
copy(g_szMsg, chx(g_szMsg), g_eMsgData[MSG_BODY])

if(g_eMsgData[MSG_PATTERN_BITSUM]) {
func_ReplacePatterns(pPlayer)
}
}

#if defined SHOW_PREFIX_WITH_ADS
client_print_color(pPlayer, g_eMsgData[MSG_COLOR_ID], "%s^1%s", CHAT_PREFIX, g_szMsg)
#else
client_print_color(pPlayer, g_eMsgData[MSG_COLOR_ID], "^1%s", g_szMsg)
#endif

#if defined USE_SOUND
if(g_eMsgData[MSG_SOUND_ID] != -1) {
func_SendAudio(pPlayer, g_szSounds[ g_eMsgData[MSG_SOUND_ID] ])
}
#endif
}

/* -------------------- */

#if defined CMD_NAME
public clcmd_ToggleState(pPlayer) {
g_bDisabled[pPlayer] = !g_bDisabled[pPlayer]
#if defined USE_SOUND
func_SendAudio(pPlayer, SOUND__BLIP1)
#endif

client_print_color( pPlayer, print_team_red, "%s^1%L %s%L", CHAT_PREFIX, pPlayer, "REKLAMA_STATE",
g_bDisabled[pPlayer] ? "^3" : "^4", pPlayer, g_bDisabled[pPlayer] ? "REKLAMA_OFF" : "REKLAMA_ON" );

if(g_hVault == INVALID_HANDLE) {
return PLUGIN_HANDLED
}

get_user_authid(pPlayer, g_szBuffer, chx(g_szBuffer))

if(g_bDisabled[pPlayer]) {
nvault_set(g_hVault, g_szBuffer, "1")
}
else {
nvault_remove(g_hVault, g_szBuffer)
}

return PLUGIN_HANDLED
}
#endif

/* -------------------- */

public func_LoadMessages(bool:bMode) {
if(bMode == MODE_AUTO) {
new iLen = get_localinfo("amxx_configsdir", g_szFilePath, chx(g_szFilePath))
formatex(g_szFilePath[iLen], chx_len(g_szFilePath), "/%s", ADS_FILE_NAME)
}

if(!file_exists(g_szFilePath)) {
set_fail_state("Error, can't find '%s'", ADS_FILE_NAME)
}

new hFile = fopen(g_szFilePath, "r")

if(!hFile) {
set_fail_state("Cannot read '%s' (wrong chmod?)", ADS_FILE_NAME)
}

new szString[MSG_LEN * 2], szMode[3], szType[3], szSound[3],
szColor[2], szAuRe[2], szAuReMode[2], szTemplate[TEMPLATE_LEN];

while(!feof(hFile)) {
fgets(hFile, szString, chx(szString))

if(!isdigit(szString[0])) {
continue
}

g_AuReData[TEMPLATE][0] = EOS

parse( szString, szMode, chx(szMode), szType, chx(szType), szSound, chx(szSound), szColor, chx(szColor),
szAuRe, chx(szAuRe), szAuReMode, chx(szAuReMode), g_AuReData[TEMPLATE], TEMPLATE_LEN - 1, g_eMsgData[MSG_BODY], MSG_LEN - 1 );

if(g_AuReData[TEMPLATE][0]) {
g_AuReData[AR_MODE] = str_to_num(szAuReMode)
g_AuReData[POINTER] = g_iMsgCount

if(contain(g_AuReData[TEMPLATE], "|") != -1) {
copy(szTemplate, chx(szTemplate), g_AuReData[TEMPLATE])

while(strtok2(szTemplate, g_AuReData[TEMPLATE], TEMPLATE_LEN - 1, szTemplate, chx(szTemplate), .token = '|', .trim = 0) != -1) {
ArrayPushArray(g_aAuReArray, g_AuReData)
g_iAuReCount++
}

// Push remaining part (after last iteration) too
ArrayPushArray(g_aAuReArray, g_AuReData)
g_iAuReCount++
}
else {
ArrayPushArray(g_aAuReArray, g_AuReData)
g_iAuReCount++
}
}

if(equal(g_eMsgData[MSG_BODY], "REKLAMA_KEY", 11)) {
g_eMsgData[MSG_IS_LANG_KEY] = true
g_eMsgData[MSG_PATTERN_BITSUM] = -1 // (1<<0) .. (1<<31)
}
else {
g_eMsgData[MSG_IS_LANG_KEY] = false

replace_string(g_eMsgData[MSG_BODY], MSG_LEN - 1, "!n", "^1")
replace_string(g_eMsgData[MSG_BODY], MSG_LEN - 1, "!t", "^3")
replace_string(g_eMsgData[MSG_BODY], MSG_LEN - 1, "!g", "^4")

g_eMsgData[MSG_PATTERN_BITSUM] = 0
func_FindPatterns()
}

g_eMsgData[MSG_MODE] = str_to_num(szMode)

#if defined RANDOM_START
switch(szType[0]) {
case '0': {
g_eMsgData[IS_MULTI_MSG] = false
g_eMsgData[NOT_FOR_START] = false
}
case '1': {
g_eMsgData[IS_MULTI_MSG] = true
g_eMsgData[NOT_FOR_START] = false
}
case '2': {
g_eMsgData[IS_MULTI_MSG] = true
g_eMsgData[NOT_FOR_START] = true
}
case '3': {
g_eMsgData[IS_MULTI_MSG] = false
g_eMsgData[NOT_FOR_START] = true
}
}
#else
g_eMsgData[IS_MULTI_MSG] = (szType[0] == '1' || szType[0] == '2') ? true : false
#endif

g_eMsgData[MSG_SOUND_ID] = str_to_num(szSound) - 1

switch(szColor[0]) {
case 'W': g_eMsgData[MSG_COLOR_ID] = print_team_grey
case 'R': g_eMsgData[MSG_COLOR_ID] = print_team_red
case 'B': g_eMsgData[MSG_COLOR_ID] = print_team_blue
default: g_eMsgData[MSG_COLOR_ID] = print_team_default
}

g_eMsgData[AUTORESPOND_ONLY] = (szAuRe[0] == '0') ? false : true

ArrayPushArray(g_aMsgArray, g_eMsgData)
g_iMsgCount++
}

fclose(hFile)

if(g_iMsgCount) {
#if defined RANDOM_START
new iTryCount

while(g_iMsgCount) {
if(++iTryCount == g_iMsgCount) { // wrong cfg, or just bad luck?
g_iCurPos = 0
break
}

g_iCurPos = random_num(0, g_iMsgCount - 1)
ArrayGetArray(g_aMsgArray, g_iCurPos, g_eMsgData)

if(g_eMsgData[NOT_FOR_START]) {
continue
}

break
}
#endif
func_SetTask()
}

if(bMode == MODE_AUTO) {
server_print("%s %i messages to show", PLUGIN_PREFIX, g_iMsgCount)
}
}

/* -------------------- */

public func_PrintMessage(iTaskID) {
if(g_iCurPos == g_iMsgCount) {
g_iCurPos = 0
}

ArrayGetArray(g_aMsgArray, g_iCurPos++, g_eMsgData)

if(g_eMsgData[AUTORESPOND_ONLY] && iTaskID) {
func_PrintMessage(iTaskID)
return
}

// Protection against infinite recursion
if(g_eCvar[CVAR__MODE] && g_eMsgData[MSG_MODE] && g_eMsgData[MSG_MODE] != g_eCvar[CVAR__MODE] && iTaskID) {
if(!g_iFirstSkipPos) {
g_iFirstSkipPos = g_iCurPos
}
else if(g_iFirstSkipPos == g_iCurPos) {
g_iFirstSkipPos = 0
func_SetTask()
return
}

func_PrintMessage(iTaskID)
return
}

g_iFirstSkipPos = 0

new pPlayers[MAX_PLAYERS], iPlCount, pPlayer

get_players_ex( pPlayers, iPlCount, g_eCvar[CVAR__FOR_ALL] ?
GetPlayers_ExcludeBots|GetPlayers_ExcludeHLTV
:
GetPlayers_ExcludeBots|GetPlayers_ExcludeHLTV|GetPlayers_ExcludeAlive
);

if(!g_eMsgData[MSG_IS_LANG_KEY] && !g_eMsgData[MSG_PATTERN_BITSUM]) {
copy(g_szMsg, chx(g_szMsg), g_eMsgData[MSG_BODY])
}

for(new i; i < iPlCount; i++) {
pPlayer = pPlayers[i]

#if defined CMD_NAME
if(g_bDisabled[pPlayer]) {
continue
}
#endif

if(g_eMsgData[MSG_IS_LANG_KEY]) {
func_ReplaceML(pPlayer)
func_ReplacePatterns(pPlayer)
}
else if(g_eMsgData[MSG_PATTERN_BITSUM]) {
copy(g_szMsg, chx(g_szMsg), g_eMsgData[MSG_BODY])
func_ReplacePatterns(pPlayer)
}

#if defined SHOW_PREFIX_WITH_ADS
client_print_color(pPlayer, g_eMsgData[MSG_COLOR_ID], "%s^1%s", CHAT_PREFIX, g_szMsg)
#else
client_print_color(pPlayer, g_eMsgData[MSG_COLOR_ID], "^1%s", g_szMsg)
#endif

#if defined USE_SOUND
if(g_eMsgData[MSG_SOUND_ID] != -1) {
if(!g_eCvar[CVAR__SOUND_FOR_ALL] && is_user_alive(pPlayer)) {
continue
}

func_SendAudio(pPlayer, g_szSounds[ g_eMsgData[MSG_SOUND_ID] ])
}
#endif
}

if(g_eMsgData[IS_MULTI_MSG]) {
func_PrintMessage(iTaskID)
return
}

func_SetTask()
}

/* -------------------- */

func_SetTask() {
set_task(random_float(g_eCvar[CVAR__FREQ_MIN], g_eCvar[CVAR__FREQ_MAX]), "func_PrintMessage", TASKID_TIMER)
}

/* -------------------- */

public srvcmd_CmdShowStatus() {
server_print("%s Total messages: %i | Last printed: #%i", PLUGIN_PREFIX, g_iMsgCount, g_iCurPos)
return PLUGIN_HANDLED
}

/* -------------------- */

public srvcmd_CmdShowCustomMessage() {
new iMsgID = read_argv_int(1)

if(!(g_iMsgCount + 1 > iMsgID > 0)) { /* if(1 > iMsgID || iMsgID > g_iMsgCount) */
server_print("%s Error! Wrong message ID #%i (Total: %i)", PLUGIN_PREFIX, iMsgID, g_iMsgCount)
}
else {
remove_task(TASKID_TIMER)
g_iCurPos = iMsgID - 1
func_PrintMessage(0)
server_print("%s Message #%i (Total: %i) printed!", PLUGIN_PREFIX, iMsgID, g_iMsgCount)
}

return PLUGIN_HANDLED
}

/* -------------------- */

public srvcmd_CmdReloadFile() {
remove_task(TASKID_TIMER)
ArrayClear(g_aMsgArray)
ArrayClear(g_aAuReArray)
g_iAuReCount = 0
new iOldMsgCount = g_iMsgCount
g_iMsgCount = 0
g_iCurPos = 0
g_iFirstSkipPos = 0
func_LoadMessages(MODE_MANUAL)
server_print("%s Message count before/after reading: %i/%i", PLUGIN_PREFIX, iOldMsgCount, g_iMsgCount)

return PLUGIN_HANDLED
}

/* -------------------- */

stock func_ReplacePatterns(pPlayer) {
if(CheckPatternBit(PATTERN__HOSTNAME)) {
get_user_name(0, g_szBuffer, chx(g_szBuffer))
replace_stringex(g_szMsg, chx(g_szMsg), PATTERNS[PATTERN__HOSTNAME], g_szBuffer)
}

if(CheckPatternBit(PATTERN__MAXPLAYERS)) {
replace_stringex(g_szMsg, chx(g_szMsg), PATTERNS[PATTERN__MAXPLAYERS], fmt("%i", MaxClients))
}

if(CheckPatternBit(PATTERN__NUMPLAYERS)) {
replace_stringex(g_szMsg, chx(g_szMsg), PATTERNS[PATTERN__NUMPLAYERS], fmt("%i", get_playersnum()))
}

if(CheckPatternBit(PATTERN__SERVER_IP)) {
get_user_ip(0, g_szBuffer, chx(g_szBuffer), .without_port = 0)
replace_stringex(g_szMsg, chx(g_szMsg), PATTERNS[PATTERN__SERVER_IP], g_szBuffer)
}

if(CheckPatternBit(PATTERN__MAPNAME)) {
get_mapname(g_szBuffer, chx(g_szBuffer))
replace_stringex(g_szMsg, chx(g_szMsg), PATTERNS[PATTERN__MAPNAME], g_szBuffer)
}

if(CheckPatternBit(PATTERN__SV_CONTACT)) {
get_cvar_string("sv_contact", g_szBuffer, chx(g_szBuffer))
replace_stringex(g_szMsg, chx(g_szMsg), PATTERNS[PATTERN__SV_CONTACT], g_szBuffer)
}

if(CheckPatternBit(PATTERN__TIMELEFT)) {
new iTimeleft = get_timeleft()

replace_stringex( g_szMsg, chx(g_szMsg), PATTERNS[PATTERN__TIMELEFT],
fmt("%02d:%02d", iTimeleft / SECONDS_IN_MINUTE, iTimeleft % SECONDS_IN_MINUTE) );
}

if(CheckPatternBit(PATTERN__PLAYER_NAME)) {
get_user_name(pPlayer, g_szBuffer, chx(g_szBuffer))
replace_stringex(g_szMsg, chx(g_szMsg), PATTERNS[PATTERN__PLAYER_NAME], g_szBuffer)
}

if(CheckPatternBit(PATTERN__PLAYER_STEAMID)) {
get_user_authid(pPlayer, g_szBuffer, chx(g_szBuffer))
replace_stringex(g_szMsg, chx(g_szMsg), PATTERNS[PATTERN__PLAYER_STEAMID], g_szBuffer)
}

if(CheckPatternBit(PATTERN__PLAYER_IP)) {
get_user_ip(pPlayer, g_szBuffer, chx(g_szBuffer), .without_port = 1)
replace_stringex(g_szMsg, chx(g_szMsg), PATTERNS[PATTERN__PLAYER_IP], g_szBuffer)
}
}

/* -------------------- */

stock func_FindPatterns() {
for(new i; i < PATTERNS_ENUM; i++) {
if(contain(g_eMsgData[MSG_BODY], PATTERNS[i]) != -1) {
SetPatternBit(i)
}
}
}

/* -------------------- */

stock func_ReplaceML(pPlayer) {
formatex(g_szMsg, chx(g_szMsg), "%L", pPlayer, g_eMsgData[MSG_BODY])
}

/* -------------------- */

public plugin_end() {
if(g_aMsgArray) {
ArrayDestroy(g_aMsgArray)
}

if(g_aAuReArray) {
ArrayDestroy(g_aAuReArray)
}

#if defined CMD_NAME
if(g_hVault != INVALID_HANDLE) {
nvault_close(g_hVault)
}
#endif
}

/* -------------------- */

#if defined CMD_NAME
public client_authorized(pPlayer, const szAuthID[]) {
if(g_hVault == INVALID_HANDLE) {
g_bDisabled[pPlayer] = false
return
}

g_bDisabled[pPlayer] = bool:nvault_get(g_hVault, szAuthID)

#if defined OBSOLETE_DAYS
if(g_bDisabled[pPlayer]) {
nvault_touch(g_hVault, szAuthID)
}
#endif
}
#endif

/* -------------------- */

func_RegCvars() {
bind_pcvar_float( create_cvar( "reklama_freq_min", "60",
.description = "Minimal interval between automatic messages" ),
g_eCvar[CVAR__FREQ_MIN] );

bind_pcvar_float( create_cvar( "reklama_freq_max", "60",
.description = "Maximal interval between automatic messages" ),
g_eCvar[CVAR__FREQ_MAX] );

bind_pcvar_num( create_cvar( "reklama_for_all", "1",
.description = "If 0, alive players do not see the automatic messages" ),
g_eCvar[CVAR__FOR_ALL] );

bind_pcvar_num( create_cvar( "reklama_mode", "0",
.description = "Display mode:^n\
0 - Display all messages^n\
1 - Only those that have 'mode 0' or those that correspond to the current value of this cvar" ),
g_eCvar[CVAR__MODE] );

bind_pcvar_num( create_cvar( "reklama_sound_for_all", "1",
.description = "Sound mode:^n\
0 - Play only for dead players (autorespond sounds will be played anyway)^n\
1 - Play sounds for all players" ),
g_eCvar[CVAR__SOUND_FOR_ALL] );

#if defined AUTO_CFG
AutoExecConfig()
#endif
}

/* -------------------- */

stock func_SendAudio(pPlayer, const szSample[]) {
message_begin(MSG_ONE_UNRELIABLE, g_iMsgIdSendAudio, .player = pPlayer)
write_byte(pPlayer)
write_string(szSample)
write_short(PITCH_NORM)
message_end()
}
Ошибка в плагине Reklama
 
В этой теме было размещено решение! Перейти к решению.
Сообщения
633
Реакции
1,142
Помог
32 раз(а)
Dizzy, конфиг плагина (можно под именной спойлер), и желательно инфу как затриггерить ошибку, если известно
 
Сообщения
23
Реакции
2
Предупреждения
5
BlackSignature,
// This file was auto-generated by AMX Mod X (v1.9.0.5263)
// Cvars for plugin "Reklama" by "mx?!" (reklama.amxx, v16.03.2020)


// Minimal interval between automatic messages
// -
// Default: "60"
reklama_freq_min "30"

// Maximal interval between automatic messages
// -
// Default: "60"
reklama_freq_max "30"

// If 0, alive players do not see the automatic messages
// -
// Default: "1"
reklama_for_all "1"

// Display mode:
// 0 - Display all messages
// 1 - Only those that have 'mode 0' or those that correspond to the current value of this cvar
// -
// Default: "0"
reklama_mode "0"

// Sound mode:
// 0 - Play only for dead players (autorespond sounds will be played anyway)
// 1 - Play sounds for all players
// -
// Default: "1"
reklama_sound_for_all "1"
 
Сообщения
23
Реакции
2
Предупреждения
5
Скрытое содержимое могут видеть только пользователь группы : Администратор, Модератор, Разработчик, Скриптер
 
Сообщения
23
Реакции
2
Предупреждения
5
Автоответчик

L 05/14/2020 - 18:21:28: Invalid index 26 (count: 26)
L 05/14/2020 - 18:21:28: [AMXX] Displaying debug trace (plugin "reklama.amxx", version "16.03.2020")
L 05/14/2020 - 18:21:28: [AMXX] Run time error 10: native error (native "ArrayGetArray")
L 05/14/2020 - 18:21:28: [AMXX] [0] reklama.sma::hook_Say (line 403)
ZiiRx : /vipka
 
Сообщения
633
Реакции
1,142
Помог
32 раз(а)
Dizzy, как будет время, я посмотрю. сейчас некогда
 
Сообщения
633
Реакции
1,142
Помог
32 раз(а)
Dizzy, добрался до проблемы, наконец.
Смотрим reklama_syntax_RU.txt
Тип:
0 - однострочное сообщение
1 - вызвать следующую строку
2 - вызвать следующую строку + не для старта (режим случайной стартовой позиции, см. RANDOM_START в исходнике)
3 - не для старта (режим случайной стартовой позиции, см. RANDOM_START в исходнике)
А последняя строка в конфиге 2 юзает
Код:
0 2 0 D 1 0 "/vipka" "!g* !tVIP !gGOLD !n100р!t/!n500тг !g| !tVIP !gPremium !n150р!t/!n800тг"
Плагин пытается вывести следующую строку, а её нету. Нужно 3 для неё поставить.
 
Последнее редактирование:

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу