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