· 5 years ago · Mar 23, 2020, 12:34 AM
1#include <amxmodx>
2#include <amxmisc>
3#include <cstrike>
4#include <hamsandwich>
5#include <fakemeta>
6#include <fun>
7#include <engine>
8#include <fakemeta_util>
9#include <csx>
10#include <sqlx>
11
12
13
14#define HOSTNAME "NUME HOST"
15
16#define PREFIX "MIX SQL SYSTEM"
17
18// Flagul care are acces sa administreze mix-ul
19#define FLAG ADMIN_KICK
20
21#define MIX_HOST "185.244.130.127:3306"
22#define MIX_USER "u18_IaYrhI3wmk"
23#define MIX_PASSWORD "@vEE1Oc.87@v@VoqkiZy+0O6"
24#define MIX_DATABASE "s18_database"
25
26
27#define POINTS_KILL 1
28#define POINTS_DEATH -1
29#define POINTS_ACE 10
30#define POINTS_HS 1
31#define POINTS_MINI_ACE 5
32#define POINTS_MIX_PLAYED 20
33#define POINTS_MIX_LOST -10
34#define POINTS_MIX_WON 20
35#define POINTS_MIX_DRAW 5
36
37
38
39
40new Handle:g_hTuple;
41
42new const szTables[][] =
43{
44 "CREATE TABLE IF NOT EXISTS `mix_players` ( `player_id` varchar(32) NOT NULL, `player_name` varchar(64), `kills` int(16) NOT NULL, `deaths` int(16) NOT NULL, `headshots` int(16), `m_aces` int(16), `aces` int(16), `mix_played` int(16) NOT NULL, `mix_won` int(16) NOT NULL, `mix_lost` int(16) NOT NULL, `mix_draw` int(16) NOT NULL, `points` int(16) NOT NULL, `last_online` varchar(64), PRIMARY KEY (`player_id`) )",
45
46 "CREATE TABLE IF NOT EXISTS `mix_guns` ( `gun_id` int(32) NOT NULL, `kills` int(16), PRIMARY KEY (`gun_id`) )",
47
48 "CREATE TABLE IF NOT EXISTS `mix_games` ( `id` int(32) NOT NULL AUTO_INCREMENT, `map_name` varchar(64) NOT NULL, `date` varchar(64), `rez_ct` int(16), `rez_t` int(16), PRIMARY KEY (`id`) )"
49}
50
51new pKills[33], pDeaths[33], pHeadshots[33], pAces[33], pMiniAces[33], pMixPlayed[33], pMixLost[33], pMixDraw[33], pMixWon[33], pPoints[33], bool:pLoaded[33]
52
53#define isAdmin(%1) (get_user_flags(%1) & FLAG)
54
55new scoreT, scoreCT, serverPassword[64], tempCT, tempT, tempCount
56new bool:WarmUp = true, bool:KnifeRound, bool:passwordStatus, bool:canChat = true,bool:PrepareRound
57new Kills[33]
58
59new const BlockCmds[][] = {
60"amx_unban",
61"amx_rcon",
62"amx_cvar",
63"amxmodmenu"
64}
65
66new const Commands[][][] = {
67{"menu", "mainMenu"},
68{"mixmenu", "mainMenu"},
69{"live", "setLive"},
70{"rr", "restartRound"},
71{"restart", "restartRound"},
72{"wu", "warmUP"},
73{"warmup", "warmUP"},
74{"gg", "endGame"},
75{"stop", "endGame"},
76{"knife", "setKnife"},
77{"knf", "setKnife"},
78{"score", "getScore"},
79{"rez", "getScore"},
80{"pw", "infoPassword"},
81{"renkam", "setPrepare"}
82}
83
84public plugin_init()
85{
86 register_plugin("MIX Panel", "1.3", "InvIs")
87 new szFmt[64]
88 for(new i = 0; i < sizeof(BlockCmds); i++) {
89 register_concmd(BlockCmds[i], "BlockConsole")
90 }
91 for(new i = 0; i < sizeof(Commands); i++) {
92 format(szFmt, 63, "say .%s", Commands[i][0])
93 register_clcmd(szFmt, Commands[i][1])
94 format(szFmt, 63, "say /%s", Commands[i][0])
95 register_clcmd(szFmt, Commands[i][1])
96 format(szFmt, 63, "say !%s", Commands[i][0])
97 register_clcmd(szFmt, Commands[i][1])
98 format(szFmt, 63, "say_team .%s", Commands[i][0])
99 register_clcmd(szFmt, Commands[i][1])
100 format(szFmt, 63, "say_team /%s", Commands[i][0])
101 register_clcmd(szFmt, Commands[i][1])
102 format(szFmt, 63, "say_team !%s", Commands[i][0])
103 register_clcmd(szFmt, Commands[i][1])
104 }
105 register_clcmd("say .choose", "choosePlayers")
106 register_clcmd("say /choose", "choosePlayers")
107
108 register_clcmd("say .ban", "BanMenu")
109 register_clcmd("say .kick", "KickMenu")
110 register_clcmd("say .maps", "MapsMenu")
111 register_clcmd("say .leave", "LeaveMenu")
112 register_clcmd("say .chat", "ChatMenu")
113 register_clcmd("say .chaton", "ChatMenuNew")
114
115 register_clcmd("say .stats", "showStats");
116 register_clcmd("say .top", "showTOP");
117
118 register_clcmd("SetPassword", "_SetPassword")
119 register_clcmd("say", "hookSay")
120
121 server_cmd("sv_password ^"^"")
122
123 //register_event( "CurWeapon", "event_CurWeapon", "be","1=1" );
124 register_event("DeathMsg", "DeathEvent", "a");
125 RegisterHam(Ham_Spawn, "player", "PlayerSpawn", 1 );
126 register_logevent("RoundEnd", 2, "1=Round_End")
127 register_event("SendAudio", "t_win", "a", "2&%!MRAD_terwin")
128 register_event("SendAudio", "ct_win", "a", "2&%!MRAD_ctwin")
129 register_forward(FM_Voice_SetClientListening, "ClientListen");
130
131
132 server_cmd("hostname ^"%s^"", HOSTNAME);
133}
134public BanMenu(id)
135{
136 client_cmd(id, "amx_banmenu");
137}
138public KickMenu(id)
139{
140 client_cmd(id, "amx_kickmenu");
141}
142public MapsMenu(id)
143{
144 client_cmd(id, "amx_mapmenu");
145}
146public LeaveMenu(id)
147{
148 client_cmd(id, "amx_bandisconnectedmenu");
149}
150public ChatMenu(id)
151{
152 if(!isAdmin(id)) return PLUGIN_HANDLED
153
154 canChat = false;
155
156 client_printcolor(id, "/y[/c%s/y] Chat is off!", PREFIX)
157
158 return PLUGIN_HANDLED
159}
160public ChatMenuNew(id)
161{
162 if(!isAdmin(id)) return PLUGIN_HANDLED
163
164 canChat = true;
165
166 client_printcolor(id, "/y[/c%s/y] Chat is on!", PREFIX)
167
168 return PLUGIN_HANDLED
169}
170public showStats(id)
171{
172 new link[128], steamid[64];
173 get_user_authid(id, steamid, 63);
174 format(link, 127, "http://94.176.236.15/stats/serveryje/player.php?sid=%s", steamid);
175
176 show_motd(id, link, "Player statistics");
177}
178public showTOP(id)
179{
180 new link[128];
181 format(link, 127, "http://94.176.236.15/stats/serveryje/stats.php");
182
183 show_motd(id, link, "Player top 15 statistics");
184}
185public plugin_cfg()
186{
187 set_task(0.5, "MySQLx_Init");
188}
189
190public MySQLx_Init()
191{
192
193 g_hTuple = SQL_MakeDbTuple( MIX_HOST, MIX_USER, MIX_PASSWORD, MIX_DATABASE );
194
195 for ( new i = 0; i < sizeof szTables; i++ )
196 {
197 SQL_ThreadQuery( g_hTuple, "QuerySetData", szTables[i]);
198 }
199}
200
201public QuerySetData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime )
202{
203 if( iFailState == TQUERY_CONNECT_FAILED
204 || iFailState == TQUERY_QUERY_FAILED )
205 {
206 log_amx( "%s", szError );
207
208 return;
209 }
210}
211public ClientListen(pid /*receiver*/, id /*sender*/) {
212 if(pid == id) return 1;
213
214 if(is_user_connected(id)) {
215 new szTeam[2];
216 szTeam[0] = get_pdata_int(id, 114);
217 szTeam[1] = get_pdata_int(pid, 114);
218
219 if(szTeam[0] == szTeam[1] || WarmUp || KnifeRound || PrepareRound) {
220 engfunc(EngFunc_SetClientListening, pid, id, 1);
221 return 4;
222 }
223 engfunc(EngFunc_SetClientListening, pid, id, 0);
224 return 4;
225 }
226 return 1;
227}
228public client_connect(id)
229{
230 pKills[id] = 0;
231 pDeaths[id] = 0;
232 pHeadshots[id] = 0;
233 pAces[id] = 0;
234 pMiniAces[id] = 0;
235 pMixPlayed[id] = 0;
236 pMixLost[id] = 0;
237 pMixDraw[id] = 0;
238 pMixWon[id] = 0;
239 pPoints[id] = 0;
240 pLoaded[id] = false;
241 LoadPlayerData(id);
242}
243public InsertGame()
244{
245 new szQuery[3800];
246
247 //new year, month, day, hour, minute, second, current_date[128]
248 new map_name[64];
249
250 get_mapname(map_name, 63)
251
252 //date(year, month, day);
253 //time(hour, minute, second);
254
255 //format(current_date, 127, "%i-%i-%i %i:%i:%i", year, month, day, hour, minute, second);
256
257 formatex( szQuery, 3799, "REPLACE INTO `mix_games` (`map_name`, `date`, `rez_ct`, `rez_t`) VALUES ('%s', NOW(), '%d', '%d');", map_name, scoreCT, scoreT);
258 SQL_ThreadQuery( g_hTuple, "QuerySetData", szQuery);
259}
260public InsertWeaponKill(wpnindex)
261{
262 new szQuery[3800];
263
264 formatex( szQuery, 3799, "INSERT INTO `mix_guns` (`gun_id`, `kills`) VALUES (%d, 1) ON DUPLICATE KEY UPDATE `kills` = `kills` + 1;", wpnindex);
265
266 log_amx(szQuery)
267 SQL_ThreadQuery( g_hTuple, "QuerySetData", szQuery);
268}
269public SavePlayer(id)
270{
271 if(!pLoaded[id]) return PLUGIN_HANDLED;
272
273 if (pPoints[id] < 0)
274 pPoints[id] = 0;
275
276 new Name[64], steam[64];
277 get_user_name(id, Name, 63);
278
279 get_user_authid(id, steam, 63);
280
281 static szQuery[3800];
282 formatex( szQuery, 3799, "REPLACE INTO `mix_players` (`player_id`, `player_name`, `kills`, `deaths`, `headshots`, `aces`, `m_aces`, `mix_played`, `mix_lost`, `mix_won`, `mix_draw`, `points`, `last_online`) VALUES ('%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', NOW());", steam, GetSecureName(Name), pKills[id], pDeaths[id], pHeadshots[id], pAces[id], pMiniAces[id], pMixPlayed[id], pMixLost[id], pMixWon[id], pMixDraw[id], pPoints[id]);
283
284 #if AMXX_VERSION_NUM >= 183
285 SQL_SetCharset(g_hTuple,"utf8");
286 #endif
287
288 SQL_ThreadQuery( g_hTuple, "QuerySetData", szQuery);
289
290 return PLUGIN_CONTINUE;
291}
292public LoadPlayerData(id)
293{
294 new steam[64];
295 get_user_authid(id, steam, 63);
296
297 static szQuery[ 256 ], iData[ 1 ];
298 formatex( szQuery, 255, "SELECT * FROM `mix_players` WHERE ( `player_id` = '%s' );", steam );
299
300 iData[ 0 ] = id;
301 SQL_ThreadQuery( g_hTuple, "QuerySelectData", szQuery, iData, 1 );
302
303 return PLUGIN_CONTINUE;
304}
305public QuerySelectData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime )
306{
307 if( iFailState == TQUERY_CONNECT_FAILED
308 || iFailState == TQUERY_QUERY_FAILED )
309 {
310 log_amx( "%s", szError );
311
312 return;
313 }
314 else
315 {
316 new id = iData[ 0 ];
317 new data_kills = SQL_FieldNameToNum(hQuery, "kills");
318 new data_deaths = SQL_FieldNameToNum(hQuery, "deaths");
319 new data_headshots = SQL_FieldNameToNum(hQuery, "headshots");
320 new data_aces = SQL_FieldNameToNum(hQuery, "aces");
321 new data_mini_aces = SQL_FieldNameToNum(hQuery, "m_aces");
322 new data_mix_played = SQL_FieldNameToNum(hQuery, "mix_played");
323 new data_mix_lost = SQL_FieldNameToNum(hQuery, "mix_lost");
324 new data_mix_draw = SQL_FieldNameToNum(hQuery, "mix_draw");
325 new data_mix_won = SQL_FieldNameToNum(hQuery, "mix_won");
326 new data_points = SQL_FieldNameToNum(hQuery, "points");
327 while (SQL_MoreResults(hQuery))
328 {
329 pKills[id] = SQL_ReadResult(hQuery, data_kills);
330 pDeaths[id] = SQL_ReadResult(hQuery, data_deaths);
331 pHeadshots[id] = SQL_ReadResult(hQuery, data_headshots);
332 pAces[id] = SQL_ReadResult(hQuery, data_aces);
333 pMiniAces[id] = SQL_ReadResult(hQuery, data_mini_aces);
334 pMixPlayed[id] = SQL_ReadResult(hQuery, data_mix_played);
335 pMixLost[id] = SQL_ReadResult(hQuery, data_mix_lost);
336 pMixDraw[id] = SQL_ReadResult(hQuery, data_mix_draw);
337 pMixWon[id] = SQL_ReadResult(hQuery, data_mix_won);
338 pPoints[id] = SQL_ReadResult(hQuery, data_points);
339
340 SQL_NextRow(hQuery);
341 }
342
343 pLoaded[id] = true;
344 }
345}
346public client_disconnected(id)
347{
348 if(!WarmUp && !PrepareRound)
349 {
350 if(1 <= get_user_team(id) <= 2)
351 client_printcolor(0, "/y[/c%s/y] Player: /g%s /ypaliko left the game!", PREFIX, get_admin_name(id))
352 }
353}
354public t_win(id)
355{
356 if(!WarmUp && !KnifeRound && !PrepareRound) scoreT++
357 if(KnifeRound)
358 {
359 if(tempT)
360 {
361 showTeamMenu(tempT)
362 }
363 }
364}
365public ct_win(id)
366{
367 if(!WarmUp && !KnifeRound && !PrepareRound) scoreCT++
368 if(KnifeRound)
369 {
370 if(tempCT)
371 {
372 showTeamMenu(tempCT)
373 }
374 }
375}
376public PlayerSpawn(id)
377{
378 if(WarmUp && is_user_connected(id))
379 cs_set_user_money(id, 16000)
380 Kills[id] = 0
381
382 return PLUGIN_HANDLED;
383}
384public RoundEnd()
385{
386 if(WarmUp) server_cmd("hostname ^"%s [Apsilimas]^"", HOSTNAME);
387 else if(KnifeRound) server_cmd("hostname ^"%s [Knife Round]^"", HOSTNAME);
388 else if(PrepareRound) server_cmd("hostname ^"%s [Renkamos Komandos]^"", HOSTNAME);
389 else
390 {
391 if(scoreT == 16 || scoreCT == 16)
392 {
393 server_cmd("hostname ^"[Game is over - CT: %i | T: %i] %s^"", scoreCT, scoreT, HOSTNAME);
394 }
395 else if(scoreT == 15 || scoreCT == 15)
396 {
397 server_cmd("hostname ^"[Live (MB) - CT: %i | T: %i] %s^"", scoreCT, scoreT, HOSTNAME);
398 }
399 else
400 {
401 if(scoreCT+scoreT == 15)
402 {
403 server_cmd("hostname ^"[Live - CT: %i | T: %i] %s^"", scoreCT, scoreT, HOSTNAME);
404 }
405 else
406 {
407 server_cmd("hostname ^"[Live - CT: %i | T: %i] %s^"", scoreCT, scoreT, HOSTNAME);
408 }
409 }
410 }
411 if(!WarmUp && !KnifeRound && !PrepareRound) {
412 for(new i = 1; i <= 32; i++)
413 {
414 if(is_user_connected(i))
415 {
416 if(Kills[i] == 4)
417 {
418 client_printcolor(0, "/y[/c%s/y] Player: /g%s /yPadare /cMINI ACE", PREFIX, get_admin_name(i))
419 client_printcolor(0, "/y[/c%s/y] ĹPlayer: /g%s /yuĹľ MINI ACE /cgauna /g%i butt!", PREFIX, get_admin_name(i), POINTS_MINI_ACE)
420 if(!WarmUp && !PrepareRound)
421
422 pMiniAces[i]++;
423 pPoints[i] += POINTS_MINI_ACE
424 SavePlayer(i);
425 }
426 else if(Kills[i] == 5)
427 {
428 client_printcolor(0, "/y[/c%s/y] Player: /g%s /yPadare /cACE", PREFIX, get_admin_name(i))
429 client_printcolor(0, "/y[/c%s/y] Player: /g%s /yuĹľ ACE /cgauna /g%i butt!", PREFIX, get_admin_name(i), POINTS_ACE)
430
431 pAces[i]++;
432 pPoints[i] += POINTS_ACE
433 SavePlayer(i);
434 }
435 }
436 }
437 if(scoreCT + scoreT == 15)
438 {
439 new temp = scoreCT
440 scoreCT = scoreT
441 scoreT = temp
442 client_printcolor(0, "/y[/c%s/y] Changeable commands!", PREFIX)
443 changeTeams()
444 server_cmd("sv_restart 5")
445 }
446 client_printcolor(0, "/y[/c%s/y] CT's: /g%i /y|| T's: /g%i", PREFIX, scoreCT, scoreT)
447 if(scoreT == 15 && scoreCT == 15) {
448 client_printcolor(0, "/y[/c%s/y] /gŽthe play is over. / yNo team lost!", PREFIX)
449 client_printcolor(0, "/y[/c%s/y] /gPlayers in each team for a draw /cgauna: /g%i tašku!", PREFIX, POINTS_MIX_DRAW)
450 client_printcolor(0, "/y[/c%s/y] /gThe players in each team for the fact that the player played /cgauna: /g%i butt!", PREFIX, POINTS_MIX_PLAYED)
451 drawGame();
452 setEndGame()
453 }
454 else if(scoreT == 15) client_printcolor(0, "/y[/c%s/y] Counter-Terrorists MB", PREFIX)
455 else if(scoreCT == 15) client_printcolor(0, "/y[/c%s/y] Terrorists MB", PREFIX)
456 else if(scoreT == 16)
457 {
458 TeamWon(1);
459 client_printcolor(0, "/y[/c%s/y] /gGame complete. Won: /yTerrorists team!", PREFIX)
460 client_printcolor(0, "/y[/c%s/y] /gPlayers on the terrorist team for victory™ /cgauna: /g%i team!", PREFIX, POINTS_MIX_WON)
461 client_printcolor(0, "/y[/c%s/y] /gThe players on each team for being a player— „MIX“ /cgauna: /g%i team!", PREFIX, POINTS_MIX_PLAYED)
462 setEndGame()
463
464 }
465 else if(scoreCT == 16)
466 {
467 TeamWon(2);
468 client_printcolor(0, "/y[/c%s/y] /gGame complete. Won: /yCounter-Terrorists team!", PREFIX)
469 client_printcolor(0, "/y[/c%s/y] /gCounter-Terrorists players on the team for victory™ /cgauna: /g%i team!", PREFIX, POINTS_MIX_WON)
470 client_printcolor(0, "/y[/c%s/y] /gThe players on each team for being a player— „MIX“ /cgauna: /g%i team!", PREFIX, POINTS_MIX_PLAYED)
471 setEndGame()
472 }
473 }
474}
475public changeTeams()
476{
477 for(new i = 1; i <= 32; i++)
478 {
479 add_delay(i)
480 }
481}
482public changeTeam( id )
483{
484 if(is_user_connected(id))
485 {
486 switch( get_user_team( id ) )
487 {
488 case 2: cs_set_user_team( id, CS_TEAM_T );
489 case 1: cs_set_user_team( id, CS_TEAM_CT );
490 }
491 }
492}
493add_delay( id )
494{
495 switch( id )
496 {
497 case 1..5: set_task( 0.1, "changeTeam", id );
498 case 6..10: set_task( 0.2, "changeTeam", id );
499 case 11..15: set_task( 0.3, "changeTeam", id );
500 case 16..20: set_task( 0.4, "changeTeam", id );
501 case 21..25: set_task( 0.5, "changeTeam", id );
502 case 26..32: set_task( 0.6, "changeTeam", id );
503 }
504}
505public DeathEvent(victim, attacker, id)
506{
507 new attacker = read_data(1);
508 new victim = read_data(2);
509 new hs = read_data(3)
510
511 if(WarmUp) {
512 set_task(1.0, "RespawnPlayer", victim)
513 }
514 else if(1 <= victim <= 32 && 1 <= attacker <= 32)
515 {
516 Kills[attacker]++
517
518 if(!WarmUp && !PrepareRound)
519 {
520 pKills[attacker]++;
521 pPoints[attacker] += POINTS_KILL
522
523 if(hs)
524 {
525 pHeadshots[attacker]++;
526 pPoints[attacker] += POINTS_HS
527
528 }
529 pDeaths[victim]++;
530 pPoints[victim] += POINTS_DEATH
531
532 SavePlayer(victim);
533 SavePlayer(attacker);
534
535
536
537 new weapon_name[32]
538 read_data(4, weapon_name, 31)
539
540
541 if(containi(weapon_name, "ak47") != -1) InsertWeaponKill(CSW_AK47);
542 else if(containi(weapon_name, "m4a1") != -1) InsertWeaponKill(CSW_M4A1);
543 else if(containi(weapon_name, "deagle") != -1) InsertWeaponKill(CSW_DEAGLE);
544 else if(containi(weapon_name, "awp") != -1) InsertWeaponKill(CSW_AWP);
545 else if(containi(weapon_name, "usp") != -1) InsertWeaponKill(CSW_USP);
546 else if(containi(weapon_name, "glock") != -1) InsertWeaponKill(CSW_GLOCK18);
547 else if(containi(weapon_name, "he") != -1) InsertWeaponKill(CSW_HEGRENADE);
548 else if(containi(weapon_name, "knife") != -1) InsertWeaponKill(CSW_KNIFE);
549 else if(containi(weapon_name, "scout") != -1) InsertWeaponKill(CSW_SCOUT);
550 }
551
552 }
553}
554public RespawnPlayer(id)
555{
556 if(!is_user_alive(id) && is_user_connected(id) && 1 <= get_user_team(id) <= 2)
557 ExecuteHamB(Ham_CS_RoundRespawn, id)
558}
559public event_CurWeapon(id)
560{
561 if(KnifeRound && get_user_weapon(id) != CSW_KNIFE)
562 engclient_cmd(id, "weapon_knife")
563}
564public infoPassword(id)
565{
566 if(passwordStatus)
567 client_printcolor(id, "/y[/c%s/y] Server password: /g%s", PREFIX, serverPassword)
568 else
569 client_printcolor(id, "/y[/c%s/y] Server password is off!", PREFIX, serverPassword)
570 return PLUGIN_HANDLED
571}
572public hookSay(id)
573{
574 if(!canChat) {
575 client_printcolor(id, "/y[/c%s/y] Chat is currently off!", PREFIX)
576 client_printcolor(id, "/y[/c%s/y] Teams are available: /g.rez .stats .top", PREFIX)
577 return PLUGIN_HANDLED;
578 }
579 return PLUGIN_CONTINUE;
580}
581public BlockConsole(id) return PLUGIN_HANDLED
582public mainMenu(id)
583{
584 if(!isAdmin(id)) return PLUGIN_HANDLED
585 new menu = menu_create("\w[\yMIX\w] \rHome meniu", "onMainMenu")
586
587 new szMsg[64]
588
589 menu_additem(menu, "Valdymas")
590
591 format(szMsg, 63, "\wChat \d[%s\d]", canChat ? "\yto activate" : "\rIšjungti")
592 menu_additem(menu, szMsg)
593
594 if(serverPassword[0]) format(szMsg, 63, "\wSlaptaĹľodis \d[\y%s\d]", serverPassword)
595 else format(szMsg, 63, "\wSlaptaĹľodis \d[\rNÄ—ra\d]")
596 menu_additem(menu, szMsg)
597
598 menu_additem(menu, "Discarded player")
599 menu_additem(menu, "Challenge player")
600 menu_additem(menu, "Change the tab")
601 menu_additem(menu, "Offline player list")
602
603 menu_display(id, menu, 0)
604
605 return PLUGIN_HANDLED;
606}
607public onMainMenu(id, menu, item)
608{
609 switch(item)
610 {
611 case 0: actMix(id)
612 case 1:
613 {
614 canChat = !canChat
615 mainMenu(id)
616 return PLUGIN_HANDLED
617 }
618 case 2: optionsPassword(id)
619 case 3: client_cmd(id, "amx_kickmenu")
620 case 4: client_cmd(id, "amx_banmenu")
621 case 5: client_cmd(id, "amx_mapmenu")
622 case 6: client_cmd(id, "amx_bandisconnectedmenu")
623 }
624 menu_destroy(menu)
625 return PLUGIN_HANDLED
626}
627public optionsPassword(id)
628{
629 if(!isAdmin(id)) return PLUGIN_HANDLED
630 new szText[64]
631 if(strlen(serverPassword) > 0) format(szText, 63, "\w[\y%s\w] \rPassword \d(\y%s\d)", PREFIX, serverPassword)
632 else format(szText, 63, "\w[\y%s\w] \rPassword \d(\rNÄ—ra\d)", PREFIX)
633 new menu = menu_create(szText, "onOptionsPassword")
634
635 format(szText, 63, "\wSlaptažodis \d[%s\d]", passwordStatus ? "\yĮjungtas" : "\rIšjungtas")
636
637 menu_additem(menu, szText)
638 menu_additem(menu, "Keisti slaptaĹľodÄŻ")
639 menu_additem(menu, "Ištrinti slaptažodį")
640
641 menu_display(id, menu, 0)
642
643 return PLUGIN_HANDLED;
644}
645public onOptionsPassword(id, menu, item)
646{
647 switch(item)
648 {
649 case MENU_EXIT:
650 {
651 mainMenu(id)
652 return PLUGIN_HANDLED
653 }
654 case 0:
655 {
656 if(strlen(serverPassword) > 0) {
657 passwordStatus = !passwordStatus
658 if(passwordStatus) {
659 server_cmd("sv_password", serverPassword)
660 client_printcolor(0, "/y[/c%s/y] [/g%s/y] Server password: /g%s",PREFIX, get_admin_name(id), serverPassword)
661 }
662 else server_cmd("sv_password ^"^"")
663 }
664 else {
665 if(passwordStatus)
666 passwordStatus = false
667 client_printcolor(id, "/y[/c%s/y] No password set!", PREFIX)
668 //format(serverPassword, 63, "")
669 }
670
671 }
672 case 1: client_cmd(id, "messagemode SetPassword")
673 case 2: format(serverPassword, 63, "")
674 }
675 optionsPassword(id)
676 return PLUGIN_HANDLED
677}
678public _SetPassword(id) {
679 if(!isAdmin(id)) return
680 new szTemp[64]
681 read_args(szTemp, charsmax(szTemp))
682 remove_quotes(szTemp)
683 format(serverPassword, 63, szTemp)
684 optionsPassword(id)
685 if(passwordStatus)
686 {
687 server_cmd("sv_password %s", serverPassword)
688 client_printcolor(0, "/y[/c%s/y] [/g%s/y] Server password: /g%s",PREFIX, get_admin_name(id), szTemp)
689 }
690}
691public actMix(id)
692{
693 if(!isAdmin(id)) return PLUGIN_HANDLED
694 new menu = menu_create("\w[\yMIX\w] \rManagement", "onactMix")
695
696 menu_additem(menu, "Start Game")
697 menu_additem(menu, "Get ready")
698 menu_additem(menu, "Warming up")
699 menu_additem(menu, "Knife roundas")
700 menu_additem(menu, "Reload round")
701 menu_additem(menu, "Finish the game…")
702
703 menu_display(id, menu, 0)
704
705 return PLUGIN_HANDLED;
706}
707public onactMix(id, menu, item)
708{
709 switch(item)
710 {
711 case 0: setLive(id)
712 case 1: setPrepare(id)
713 case 2: warmUP(id)
714 case 3: setKnife(id)
715 case 4: restartRound(id)
716 case 5: endGame(id)
717 }
718 menu_destroy(menu)
719}
720public setPrepare(id)
721{
722 if(!isAdmin(id)) return PLUGIN_HANDLED
723 if(get_playersnum() >= 10) {
724 server_cmd("sv_restart 1")
725
726 KnifeRound = false;
727 PrepareRound = true;
728 WarmUp = false;
729 scoreCT = 0;
730 scoreT = 0;
731 tempCount = 0;
732 tempCT = 0;
733 tempT = 0;
734
735 for(new i = 1; i <= 32; i++)
736 {
737 if(is_user_connected(id) && (1 <= get_user_team(i) <= 2)) {
738 if(is_user_alive(i))
739 user_silentkill(i)
740 cs_set_user_team(i, CS_TEAM_SPECTATOR)
741 }
742 }
743
744 client_printcolor(0, "/y[/c%s/y] [/g%s/y] The preparation has begun! The administrator will select leaders soon!", PREFIX, get_admin_name(id))
745 showPrepareMenu(id)
746 }
747 else
748 client_printcolor(id, "/y[/c%s/y] Preparation can't be started because of a missing player!", PREFIX)
749 return PLUGIN_HANDLED
750}
751public showPrepareMenu(id)
752{
753 if(!isAdmin(id)) return PLUGIN_HANDLED
754 new menu = menu_create("\w[\yMIX\w] \rChoose who will go to CT", "onPrepareCT")
755
756 new players[32], num
757 get_players(players, num, "ch")
758 new ui[32]
759
760 for(new i; i < num; i++)
761 {
762 format(ui, 31, "%d",get_user_userid(players[i]))
763 menu_additem(menu, get_admin_name(players[i]), ui)
764 }
765
766 menu_display(id, menu, 0)
767
768 return PLUGIN_HANDLED;
769}
770public onPrepareCT(id, menu, item)
771{
772 new szData[6], szName[64];
773 new _access, item_callback;
774
775 menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
776
777 new userid = str_to_num( szData );
778 new player = find_player( "k", userid );
779
780 switch(item)
781 {
782 case MENU_EXIT: {
783 if(PrepareRound) showPrepareMenu(id)
784 return PLUGIN_HANDLED;
785 }
786 default: if(PrepareRound && is_user_connected(player)) cs_set_user_team(player, CS_TEAM_CT)
787 }
788 if(PrepareRound) {
789 tempCT = player;
790 client_printcolor(0, "/y[/c%s/y] CT leader will: /g%s", PREFIX, szName)
791 client_printcolor(0, "/y[/c%s/y] The administrator will immediately select the T leader!", PREFIX)
792 showPrepareMenuT(id)
793 }
794 return PLUGIN_HANDLED;
795}
796public showPrepareMenuT(id)
797{
798 if(!isAdmin(id)) return PLUGIN_HANDLED
799 new menu = menu_create("\w[\yMIX\w] \rChoose who will go to T", "onPrepareT")
800
801 new players[32], num
802 get_players(players, num, "ceh", "SPECTATOR")
803 new ui[32]
804
805 for(new i; i < num; i++)
806 {
807 format(ui, 31, "%d",get_user_userid(players[i]))
808 menu_additem(menu, get_admin_name(players[i]), ui)
809 }
810
811 menu_display(id, menu, 0)
812
813 return PLUGIN_HANDLED;
814}
815public onPrepareT(id, menu, item)
816{
817 new szData[6], szName[64];
818 new _access, item_callback;
819
820 menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
821
822 new userid = str_to_num( szData );
823 new player = find_player( "k", userid );
824
825 switch(item)
826 {
827 case MENU_EXIT: {
828 if(PrepareRound) showPrepareMenuT(id)
829 return PLUGIN_HANDLED;
830 }
831 default: if(PrepareRound && is_user_connected(player)) cs_set_user_team(player, CS_TEAM_T)
832 }
833 if(PrepareRound) {
834 tempT = player;
835 client_printcolor(0, "/y[/c%s/y] T leader will: /g%s", PREFIX, szName)
836 client_printcolor(0, "/y[/c%s/y] Leaders start choosing players!", PREFIX)
837 client_printcolor(0, "/y[/c%s/y] /gDemesio: /yIf the leaderboard menu disappears, enter the chat /c/choose", PREFIX)
838 ShowList(tempCT)
839 }
840 return PLUGIN_HANDLED;
841}
842public choosePlayers(id)
843{
844 /*new Where;*/
845 switch(tempCount)
846 {
847 // Ter
848 case 0,2,4,6: if(tempT == id) ShowList(id);
849 // CT
850 case 1,3,5,7: if(tempCT == id) ShowList(id);
851 }
852 return PLUGIN_HANDLED;
853}
854public showTeamMenu(id)
855{
856 new menu = menu_create("\w[\yMIX\w] \rSelect team", "onTeamChange")
857
858 menu_additem(menu, "Pasilikti")
859 menu_additem(menu, "Keistis komandomis")
860
861 menu_display(id, menu, 0)
862
863 return PLUGIN_HANDLED;
864}
865public onTeamChange(id, menu, item)
866{
867 switch(item)
868 {
869 case 0:
870 {
871 client_printcolor(0, "/y[/c%s/y] The solution: /gpasilikti", PREFIX)
872 setServerLive()
873 }
874 case 1:
875 {
876 client_printcolor(0, "/y[/c%s/y] The solution: /gkeistis komandomis", PREFIX)
877 changeTeams()
878 set_task(2.0, "setServerLive", 1)
879 }
880 }
881}
882public ShowList(id)
883{
884 new menu = menu_create("\w[\yMIX\w] \rChoose a teammate", "onShowList")
885
886 new players[32], num
887 get_players(players, num, "ceh", "SPECTATOR")
888 new ui[32]
889
890 for(new i; i < num; i++)
891 {
892 format(ui, 31, "%d",get_user_userid(players[i]))
893 menu_additem(menu, get_admin_name(players[i]), ui)
894 }
895 menu_display(id, menu, 0)
896
897 return PLUGIN_HANDLED;
898}
899public onShowList(id, menu, item)
900{
901 new szData[6], szName[64];
902 new _access, item_callback;
903
904 new Where;
905 switch(tempCount)
906 {
907 case 0,2,4,6: Where = 0
908 case 1,3,5,7: Where = 1
909 default: Where = -1
910 }
911
912 menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
913
914 new userid = str_to_num( szData );
915 new player = find_player( "k", userid );
916
917 switch(item)
918 {
919 case MENU_EXIT: {
920 if(PrepareRound) ShowList(id)
921 return PLUGIN_HANDLED;
922 }
923 default: if(PrepareRound && is_user_connected(player))
924 {
925 if(Where == 0) cs_set_user_team(player, CS_TEAM_CT)
926 else cs_set_user_team(player, CS_TEAM_T)
927
928 }
929 }
930 if(PrepareRound) {
931 tempCount++;
932 client_printcolor(0, "/y[/c%s/y] [/g%s /ychose /g%s", PREFIX, get_admin_name(id), szName)
933 if(tempCount < 8)
934 ShowList(Where == 1 ? tempCT : tempT)
935 else
936 {
937 KnifeRound = true;
938 PrepareRound = false;
939 WarmUp = false;
940 scoreCT = 0;
941 scoreT = 0;
942
943 server_cmd("mp_roundtime 1.8")
944 server_cmd("mp_buytime 0.30")
945 server_cmd("mp_startmoney 16000")
946 server_cmd("mp_freezetime 7")
947
948 server_cmd("sv_restart 1")
949
950 client_printcolor(0, "/y[/c%s/y] Team selection is complete! Knife round!", PREFIX)
951
952 setServerLive()
953 }
954 }
955 return PLUGIN_HANDLED;
956}
957public restartRound(id)
958{
959 if(!isAdmin(id)) return PLUGIN_HANDLED
960 server_cmd("sv_restart 1")
961 client_printcolor(0, "/y[/c%s/y] [/g%s/y] A crowded round!", PREFIX, get_admin_name(id))
962 return PLUGIN_HANDLED
963}
964public setServerLive()
965{
966 KnifeRound = false;
967 PrepareRound = false;
968 WarmUp = false;
969 scoreCT = 0;
970 scoreT = 0;
971
972 server_cmd("mp_roundtime 1.8")
973 server_cmd("mp_buytime 0.30")
974 server_cmd("mp_startmoney 800")
975 server_cmd("mp_freezetime 7")
976
977 server_cmd("sv_restart 1")
978
979 client_printcolor(0, "/y[/c%s/y] Game Started! Wish you a good game - Administration!", PREFIX)
980 return PLUGIN_HANDLED
981}
982public setLive(id)
983{
984 if(!isAdmin(id)) return PLUGIN_HANDLED
985
986 KnifeRound = false;
987 PrepareRound = false;
988 WarmUp = false;
989 scoreCT = 0;
990 scoreT = 0;
991
992 server_cmd("mp_roundtime 1.8")
993 server_cmd("mp_buytime 0.30")
994 server_cmd("mp_startmoney 800")
995 server_cmd("mp_freezetime 7")
996
997 server_cmd("sv_restart 1")
998
999 client_printcolor(0, "/y[/c%s /y] Jocul a început. Vă doresc un joc bun - Administrare!", PREFIX, get_admin_name(id))
1000 return PLUGIN_HANDLED
1001}
1002public warmUP(id)
1003{
1004 if(!isAdmin(id)) return PLUGIN_HANDLED
1005
1006 passwordStatus = false;
1007 KnifeRound = false;
1008 PrepareRound = false;
1009 WarmUp = true;
1010 scoreCT = 0;
1011 scoreT = 0;
1012
1013 server_cmd("mp_roundtime 600")
1014 server_cmd("mp_buytime -1")
1015 server_cmd("mp_startmoney 16000")
1016 server_cmd("mp_freezetime 0")
1017 server_cmd("sv_password ^"^"")
1018
1019 server_cmd("sv_restart 1")
1020
1021 client_printcolor(0, "/y[/c%s /y] [/ g% s / y] Începerea încălzirii!", PREFIX, get_admin_name(id))
1022 return PLUGIN_HANDLED
1023}
1024public setKnife(id)
1025{
1026 if(!isAdmin(id)) return PLUGIN_HANDLED
1027
1028 KnifeRound = true;
1029 PrepareRound = false;
1030 WarmUp = false;
1031 scoreCT = 0;
1032 scoreT = 0;
1033
1034 server_cmd("mp_roundtime 1.8")
1035 server_cmd("mp_buytime 0.30")
1036 server_cmd("mp_startmoney 800")
1037 server_cmd("mp_freezetime 7")
1038
1039 server_cmd("sv_restart 1")
1040
1041 client_printcolor(0, "/y[/c%s /y] [/g%s /y] Au început rundele de lame! Mult noroc!", PREFIX, get_admin_name(id))
1042 return PLUGIN_HANDLED
1043}
1044public drawGame()
1045{
1046 for(new i = 1; i <= 32; i++)
1047 {
1048 if(is_user_connected(i) && (1 <= get_user_team(i) <= 2))
1049 {
1050 pMixPlayed[i]++;
1051 pPoints[i] += POINTS_MIX_PLAYED
1052 pMixDraw[i]++;
1053 pPoints[i] += POINTS_MIX_DRAW
1054 SavePlayer(i);
1055 }
1056 }
1057}
1058public TeamWon(team)
1059{
1060 for(new i = 1; i <= 32; i++)
1061 {
1062 if(is_user_connected(i) && (1 <= get_user_team(i) <= 2))
1063 {
1064 pMixPlayed[i]++;
1065 pPoints[i] += POINTS_MIX_PLAYED
1066
1067 if(get_user_team(i) == team)
1068 {
1069 pMixWon[i]++;
1070 pPoints[i] += POINTS_MIX_WON
1071 }
1072 else
1073 {
1074 pMixLost[i]++;
1075 pPoints[i] += POINTS_MIX_LOST
1076 }
1077 SavePlayer(i);
1078 }
1079 }
1080}
1081public setEndGame()
1082{
1083 InsertGame();
1084
1085 passwordStatus = false;
1086 KnifeRound = false;
1087 PrepareRound = false;
1088 WarmUp = true;
1089 canChat = true;
1090 scoreCT = 0;
1091 scoreT = 0;
1092
1093 server_cmd("mp_roundtime 600")
1094 server_cmd("mp_startmoney 16000")
1095 server_cmd("mp_buytime -1")
1096 server_cmd("mp_freezetime 0")
1097 server_cmd("sv_password ^"^"")
1098
1099 server_cmd("sv_restart 1")
1100
1101 client_printcolor(0, "/y[/c%s/y] Warm-up is on! Wait for the map to change!", PREFIX)
1102 return PLUGIN_HANDLED
1103}
1104public endGame(id)
1105{
1106 if(!isAdmin(id)) return PLUGIN_HANDLED
1107
1108 passwordStatus = false;
1109 KnifeRound = false;
1110 PrepareRound = false;
1111 WarmUp = true;
1112 canChat = true;
1113 scoreCT = 0;
1114 scoreT = 0;
1115
1116 server_cmd("mp_roundtime 600")
1117 server_cmd("mp_startmoney 16000")
1118 server_cmd("mp_buytime -1")
1119 server_cmd("mp_freezetime 0")
1120 server_cmd("sv_password ^"^"")
1121
1122 server_cmd("sv_restart 1")
1123
1124 client_printcolor(0, "/y[/c%s/y] [/g%s/y] Game over! Warm-up is on!", PREFIX, get_admin_name(id))
1125 return PLUGIN_HANDLED
1126}
1127public getScore(id) {
1128 if(WarmUp || KnifeRound || PrepareRound)
1129 client_printcolor(id, "/y[/c%s/y] Game is not playing right now!", PREFIX)
1130 else client_printcolor(id, "/y[/c%s/y] CT's: /g%i /y|| T's: /g%i", PREFIX, scoreCT, scoreT)
1131 return PLUGIN_HANDLED
1132}
1133stock get_admin_name(id)
1134{
1135 new name[64]
1136 get_user_name(id, name, 63)
1137 return name
1138}
1139stock client_printcolor(const id, const input[], any:...)
1140{
1141 new count = 1, players[32];
1142 static msg[191];
1143 vformat(msg,190,input,3);
1144 replace_all(msg,190,"/g","^4");// green txt
1145 replace_all(msg,190,"/y","^1");// orange txt
1146 replace_all(msg,190,"/c","^3");// team txt
1147 replace_all(msg,190,"/w","^0");// team txt
1148 if (id) players[0] = id; else get_players(players,count,"ch");
1149 for (new i=0;i<count;i++)
1150 if (is_user_connected(players[i]))
1151 {
1152 message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
1153 write_byte(players[i]);
1154 write_string(msg);
1155 message_end();
1156 }
1157}
1158GetSecureName(const name[])
1159{
1160 static secureName[64];
1161 copy(secureName, charsmax(secureName), name);
1162
1163 replace_all(secureName, charsmax(secureName), "\", "\\");
1164 replace_all(secureName, charsmax(secureName), "'", "\'");
1165 replace_all(secureName, charsmax(secureName), "`", "\`");
1166
1167 return secureName;
1168}