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