@@ -46,6 +46,9 @@ public plugin_precache() {
46
46
register_dictionary (" common.txt" );
47
47
register_dictionary (" time.txt" );
48
48
49
+ g_aReasons = ArrayCreate (gag_s);
50
+ g_aGagTimes = ArrayCreate ();
51
+
49
52
bind_pcvar_num (get_cvar_pointer (" ca_log_type" ), ca_log_type);
50
53
hook_cvar_change (get_cvar_pointer (" ca_log_level" ), " Hook_CVar_LogLevel" );
51
54
GetLogsFilePath (g_sLogsFile, .sDir = LOG_DIR_NAME);
@@ -57,9 +60,6 @@ public plugin_precache() {
57
60
58
61
bind_pcvar_num (create_cvar (" ca_gag_menu_type" , " 1" ), ca_gag_menu_type);
59
62
60
- g_aReasons = ArrayCreate (gag_s);
61
- g_aGagTimes = ArrayCreate ();
62
-
63
63
register_srvcmd (" ca_gag_add_reason" , " SrvCmd_AddReason" );
64
64
register_srvcmd (" ca_gag_show_templates" , " SrvCmd_ShowTemplates" ); // debug
65
65
register_srvcmd (" ca_gag_reload_config" , " SrvCmd_ReloadConfig" );
@@ -83,6 +83,9 @@ public plugin_init() {
83
83
new sLogLevel[MAX_LOGLEVEL_LEN];
84
84
get_cvar_string (" ca_log_level" , sLogLevel, charsmax (sLogLevel));
85
85
ca_log_level = ParseLogLevel (sLogLevel);
86
+
87
+ _LoadConfig ();
88
+ _ParseTimes ();
86
89
87
90
CA_Log (_Info, " [CA]: Gag initialized!" )
88
91
}
@@ -91,11 +94,6 @@ public Hook_CVar_LogLevel(pcvar, const old_value[], const new_value[]) {
91
94
ca_log_level = ParseLogLevel (new_value);
92
95
}
93
96
94
- public OnConfigsExecuted () {
95
- _LoadConfig ();
96
- _ParseTimes ();
97
- }
98
-
99
97
public plugin_natives () {
100
98
register_library (" ChatAdditions_GAG_API" );
101
99
set_native_filter (" native_filter" );
@@ -520,13 +518,11 @@ public Menu_Handler_SelectReason(id, menu, item) {
520
518
new aReason[gag_s];
521
519
ArrayGetArray (g_aReasons, iReason, aReason);
522
520
521
+ // Get predefined reason params
523
522
copy (g_aGags_AdminEditor[id][_Reason], charsmax (g_aGags_AdminEditor[][_Reason]), aReason[_Reason]);
524
-
525
- // IF NEED OFC
523
+ g_aGags_AdminEditor[id][_bitFlags] = aReason[_bitFlags];
526
524
g_aGags_AdminEditor[id][_Time] = aReason[_Time];
527
525
528
- // CA_Log("aReason[_Time]=%i, aReason[_Reason]=%s", aReason[_Time], aReason[_Reason])
529
-
530
526
if (ca_gag_menu_type == _MenuType_Custom) {
531
527
Menu_Show_GagProperties (id);
532
528
} else if (ca_gag_menu_type == _MenuType_Sequential) {
@@ -701,7 +697,7 @@ Get_GagStringReason(const id, const target) {
701
697
public SrvCmd_AddReason () {
702
698
enum any: args_s { arg0, arg1, arg2, arg3 };
703
699
704
- new szArgs[args_s][32 ];
700
+ new szArgs[args_s][256 ];
705
701
for (new iArg = arg0; iArg < sizeof szArgs; iArg++ )
706
702
read_argv (iArg, szArgs[iArg], charsmax (szArgs[]));
707
703
@@ -721,7 +717,7 @@ public SrvCmd_AddReason() {
721
717
ArrayPushArray (g_aReasons, aReason);
722
718
g_iArraySize_Reasons = ArraySize (g_aReasons);
723
719
724
- CA_Log (_Warnings , " ADD: Reason[#%i ]: '%s ' (Flags:'%s ', Time:'%i s.')" ,\
720
+ CA_Log (_Debug , " ADD: Reason[#%i ]: '%s ' (Flags:'%s ', Time:'%i s.')" ,\
725
721
g_iArraySize_Reasons, aReason[_Reason], bits_to_flags (aReason[_bitFlags]), aReason[_Time]\
726
722
)
727
723
}
@@ -735,7 +731,7 @@ public SrvCmd_ShowTemplates() {
735
731
new aReason[gag_s];
736
732
ArrayGetArray (g_aReasons, i, aReason);
737
733
738
- CA_Log (_Warnings , " Reason[#%i ]: '%s ' (Flags:'%s ', Time:'%i ')" ,\
734
+ CA_Log (_Info , " Reason[#%i ]: '%s ' (Flags:'%s ', Time:'%i ')" ,\
739
735
i, aReason[_Reason], bits_to_flags (aReason[_bitFlags]), aReason[_Time]\
740
736
)
741
737
}
@@ -761,7 +757,12 @@ public Hook_CVar_Times(pcvar, const old_value[], const new_value[]) {
761
757
}
762
758
763
759
static _LoadConfig () {
764
- ArrayClear (g_aReasons);
760
+ if (! g_aReasons) {
761
+ ArrayCreate (g_aReasons);
762
+ } else if (ArraySize (g_aReasons) > 0 ) {
763
+ ArrayClear (g_aReasons);
764
+ }
765
+
765
766
new sConfigsDir[PLATFORM_MAX_PATH];
766
767
get_configsdir (sConfigsDir, charsmax (sConfigsDir));
767
768
server_cmd (" exec %s /ChatAdditions/gag_reasons.cfg" , sConfigsDir);
0 commit comments