-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathamxxpro_discord.inc
266 lines (228 loc) · 10.2 KB
/
amxxpro_discord.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#if defined _amxxpro_discord_included
#endinput
#endif
#define _amxxpro_discord_included
enum
{
USERNAME,
AVATAR_URL,
CONTENT,
COLOR, // Discord_SetCellParam
TITLE_URL,
TITLE,
AUTHOR_NAME,
AUTHOR_AVATAR,
AUTHOR_URL,
FIELDS, // Discord_AddField
TIMESTAMP, // Discord_SetCellParam
FOOTER_TEXT,
FOOTER_IMAGE,
EMBED_THUMB,
EMBED_IMAGE
}
/**
* Starts a new message for webhook.
* WARNING! If you don't call EndMessage() in one tick with StartMessage(), message automatically has been cancelled!
*
* @return bool
*/
native bool:Discord_StartMessage();
/**
* Cancels a current Discord Message.
*
* @return void
*/
native Discord_CancelMessage();
/**
* Ends a message, sending into Discord WebHook.
*
* @param webHook WebHook name from configuration file.
*
* @return void
*/
native Discord_SendMessage(const webHook[]);
/**
* Setting string parameters
*
* @param param Parameter Number (enum)
* @param text Formatted text content
*
* @return void
*/
native Discord_SetStringParam(const param, const text[], ...);
/**
* Setting numeric parameters
*
* @param param Parameter Number (enum)
* @param value Numerical value
*
* @return void
*/
native Discord_SetCellParam(const param, const value);
/**
* Adds a field to an array
*
* @param title Name
* @param value Text
* @param inline if true, fields will be displayed in same line, but there can only be 3 max in same line or 2 max if you used thumbnail
*
* @return void
*/
native Discord_AddField(const title[], const value[], bool:inline = false);
/**
* Checks for a webhook in the configuration file.
*
* @param webHook Webhook title
*
* @return bool
*/
native bool:Discord_WebHookExists(const webHook[]);
new const file_api[] = "addons/amxmodx/configs/AmxxProPL/api.cfg";
new const file_cfg[] = "addons/amxmodx/configs/AmxxProPL/discord.cfg";
new const file_ini[] = "addons/amxmodx/configs/AmxxProPL/reasons.ini";
new linia_z_pliku[256], dlugosc_lini;
new Array:Powod;
StworzArray() Powod = ArrayCreate(64, 1);
WczytajPlik(){
new lineData[1][64];
for(new i = 0; read_file(file_ini, i, linia_z_pliku,charsmax(linia_z_pliku), dlugosc_lini); i++){
if(!linia_z_pliku[0] || !dlugosc_lini || linia_z_pliku[0] == ';')
continue;
parse(linia_z_pliku, lineData[0], charsmax(lineData[]));
ArrayPushString(Powod, lineData[0]);
}
return PLUGIN_CONTINUE;
}
public ConfigFileApi(){
if(file_exists(file_api)){
server_cmd("exec addons/amxmodx/configs/AmxxProPL/api.cfg");
log_amx("===================== » Discord « =====================")
log_amx(" Plik ^"%s^" zostal poprawnie wczytany.", file_api);
return PLUGIN_HANDLED;
}else{
log_amx("===================== » Discord « =====================")
log_amx(" Plik ^"%s^" zostal poprawnie utworzony.", file_api);
if(!dir_exists("addons/amxmodx/configs/AmxxProPL"))
mkdir("addons/amxmodx/configs/AmxxProPL");
if(!file_exists(file_api)){
write_file(file_api, "//===================== » API - Configuration « =====================", -1);
write_file(file_api, "// Autor: N1K1Cz", -1);
write_file(file_api, "// Strona: © AmxxPro.pl", -1);
write_file(file_api, "", -1);
write_file(file_api, "^"Discord^"", -1);
write_file(file_api, "{", -1);
write_file(file_api, "^"report^" ^"https://discord.com/api/webhooks/ID^"", -1);
write_file(file_api, "}", -1);
write_file(file_api, "", -1);
write_file(file_api, "//===================== » API - Configuration « =====================", -1);
}
server_cmd("exec %s", file_api);
}
return PLUGIN_CONTINUE;
}
public ConfigFileCfg(){
if(file_exists(file_cfg)){
server_cmd("exec %s", file_cfg);
log_amx(" Plik ^"%s^" zostal poprawnie wczytany.", file_cfg);
return PLUGIN_HANDLED;
}else{
log_amx(" Plik ^"%s^" zostal poprawnie utworzony.", file_cfg);
if(!dir_exists("addons/amxmodx/configs/AmxxProPL"))
mkdir("addons/amxmodx/configs/AmxxProPL");
if(!file_exists(file_cfg)){
write_file(file_cfg, "//===================== » Discord - Configuration « =====================", -1);
write_file(file_cfg, "// Autor pluginu: N1K1Cz", -1);
write_file(file_cfg, "// Strona: © AmxxPro.pl", -1);
write_file(file_cfg, "", -1);
write_file(file_cfg, "//Glowny prefix pluginu ( [» AmxxPro.pl «] - Domyślnie )", -1);
write_file(file_cfg, "amxxpro_discord_prefix ^"[» AmxxPro.pl «]^"", -1);
write_file(file_cfg, "", -1);
write_file(file_cfg, "//Co ile czasu mozna wysylac zgloszenie? ( 300 - Domyślnie )", -1);
write_file(file_cfg, "amxxpro_discord_interval ^"300^"", -1);
write_file(file_cfg, "", -1);
write_file(file_cfg, "//Jaką flage musi posiadać admin, żeby być wykrywanym jako admin? ( d - Domyślnie )", -1);
write_file(file_cfg, "amxxpro_discord_report_flag ^"d^"", -1);
write_file(file_cfg, "", -1);
write_file(file_cfg, "//Możliwość zgłaszania adminów? ( 1 - Tak | 0 - Nie )", -1);
write_file(file_cfg, "amxxpro_discord_report_admin ^"1^"", -1);
write_file(file_cfg, "", -1);
write_file(file_cfg, "//Pokazywać # przy adminie w menu zgłoszeń? ( 1 - Tak | 0 - Nie )", -1);
write_file(file_cfg, "amxxpro_discord_show_admin ^"1^"", -1);
write_file(file_cfg, "", -1);
write_file(file_cfg, "//Pokazywać czas zgłoszenia? ( 1 - Tak | 0 - Nie )", -1);
write_file(file_cfg, "amxxpro_discord_show_time ^"1^"", -1);
write_file(file_cfg, "", -1);
write_file(file_cfg, "//Pokazywać mape zgłoszenia? ( 1 - Tak | 0 - Nie )", -1);
write_file(file_cfg, "amxxpro_discord_show_map ^"1^"", -1);
write_file(file_cfg, "", -1);
write_file(file_cfg, "//Pokazywać powód zgłoszenia? ( 1 - Tak | 0 - Nie )", -1);
write_file(file_cfg, "amxxpro_discord_show_reason ^"1^"", -1);
write_file(file_cfg, "", -1);
write_file(file_cfg, "//Czy ma być włączony własny powód zgłoszenia? ( 1 - Tak | 0 - Nie )", -1);
write_file(file_cfg, "amxxpro_discord_my_reason ^"1^"", -1);
write_file(file_cfg, "", -1);
write_file(file_cfg, "//Pokazywać gracza, który zgłosił? ( 1 - Tak | 0 - Nie )", -1);
write_file(file_cfg, "amxxpro_discord_show_player ^"1^"", -1);
write_file(file_cfg, "", -1);
write_file(file_cfg, "//Powiadamiać adminów o zgłoszeniu na czacie? ( 1 - Tak | 0 - Nie )", -1);
write_file(file_cfg, "amxxpro_discord_show_ping ^"1^"", -1);
write_file(file_cfg, "", -1);
write_file(file_cfg, "//Pokazywać grafikę nad footerem? ( 1 - Tak | 0 - Nie )", -1);
write_file(file_cfg, "amxxpro_discord_show_footer_img ^"1^"", -1);
write_file(file_cfg, "", -1);
write_file(file_cfg, "//Pokazywać grafikę thumbnail? ( 1 - Tak | 0 - Nie )", -1);
write_file(file_cfg, "amxxpro_discord_show_thumbnail_img ^"1^"", -1);
write_file(file_cfg, "", -1);
write_file(file_cfg, "//ID Grup, które mają zostać oznaczone? ( @everyone - domyslnie )", -1);
write_file(file_cfg, "amxxpro_discord_id_ranga ^"@everyone^"", -1);
write_file(file_cfg, "", -1);
write_file(file_cfg, "//Nazwa BOT'a", -1);
write_file(file_cfg, "amxxpro_discord_bot_name ^"AmxxPro.pl - Report Player^"", -1);
write_file(file_cfg, "", -1);
write_file(file_cfg, "//Avatar BOT'a", -1);
write_file(file_cfg, "amxxpro_discord_bot_avatar ^"https://i.imgur.com/TPIL8dC.png^"", -1);
write_file(file_cfg, "", -1);
write_file(file_cfg, "//Tytuł BOT'a", -1);
write_file(file_cfg, "amxxpro_discord_bot_title ^"ReportBot - AmxxPro.PL^"", -1);
write_file(file_cfg, "", -1);
write_file(file_cfg, "//Grafika nad footerem", -1);
write_file(file_cfg, "amxxpro_discord_footer_img ^"https://i.imgur.com/xVuKyPn.png^"", -1);
write_file(file_cfg, "", -1);
write_file(file_cfg, "//Kolor EMBED ( d4af37 - domyslnie)", -1);
write_file(file_cfg, "amxxpro_discord_color ^"d4af37^"", -1);
write_file(file_cfg, "", -1);
write_file(file_cfg, "//Grafika thumbnail", -1);
write_file(file_cfg, "amxxpro_discord_thumbnail_img ^"https://i.imgur.com/TPIL8dC.png^"", -1);
write_file(file_cfg, "", -1);
write_file(file_cfg, "//===================== » Discord - Configuration « =====================", -1);
}
server_cmd("exec %s", file_cfg);
}
return PLUGIN_CONTINUE;
}
public ConfigFileIni(){
if(file_exists(file_ini)){
log_amx(" Plik ^"%s^" zostal poprawnie wczytany.", file_ini);
log_amx("===================== » Discord « =====================")
return PLUGIN_HANDLED;
}else{
log_amx(" Plik ^"%s^" zostal poprawnie utworzony.", file_ini);
log_amx("===================== » Discord « =====================")
if(!dir_exists("addons/amxmodx/configs/AmxxProPL"))
mkdir("addons/amxmodx/configs/AmxxProPL");
if(!file_exists(file_ini)){
write_file(file_ini, ";===================== » Reasons - Configuration « =====================", -1);
write_file(file_ini, "; Autor: N1K1Cz", -1);
write_file(file_ini, "; Strona: © AmxxPro.pl", -1);
write_file(file_ini, "", -1);
write_file(file_ini, "Cheater", -1);
write_file(file_ini, "Wyzywa", -1);
write_file(file_ini, "Naduzywa Mikro", -1);
write_file(file_ini, "Nie wykonuje cel mapy", -1);
write_file(file_ini, "", -1);
write_file(file_ini, ";===================== » Reasons - Configuration « =====================", -1);
}
WczytajPlik()
}
return PLUGIN_CONTINUE;
}