Skocz do zawartości

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Wklejka 10b76pn9zsy8 dodana przez City, 17.06.2013 12:57
Typ:



extreme_bancfg3.sma
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
193.
194.
195.
196.
197.
198.
199.
200.
201.
202.
203.
204.
205.
206.
207.
208.
209.
210.
211.
212.
213.
214.
215.
216.
217.
218.
219.
220.
221.
222.
223.
224.
225.
226.
227.
228.
229.
230.
231.
232.
233.
234.
235.
236.
237.
238.
239.
240.
241.
242.
243.
244.
245.
246.
247.
248.
249.
250.
251.
252.
253.
254.
255.
256.
257.
258.
259.
260.
261.
262.
263.
264.
265.
266.
267.
268.
269.
270.
271.
272.
273.
274.
275.
276.
277.
278.
279.
280.
281.
282.
283.
284.
285.
286.
287.
288.
289.
290.
291.
292.
293.
294.
295.
296.
297.
298.
299.
300.
301.
302.
303.
304.
305.
306.
307.
308.
309.
310.
311.
312.
313.
314.
315.
316.
317.
318.
319.
320.
321.
322.
323.
324.
325.
326.
327.
328.
329.
330.
331.
332.
333.
334.
335.
336.
337.
338.
339.
340.
341.
342.
343.
344.
345.
346.
347.
348.
349.
350.
351.
352.
353.
354.
355.
356.
357.
358.
359.
360.
361.
362.
363.
364.
365.
366.
367.
368.
369.
370.
371.
372.
373.
374.
375.
376.
377.
378.
379.
380.
381.
382.
383.
384.
385.
386.
387.
388.
389.
390.
391.
392.
393.
394.
395.
396.
397.
398.
399.
400.
401.
402.
403.
404.
405.
406.
407.
408.
409.
410.
411.
412.
413.
414.
415.
416.
417.
418.
419.
420.
421.
422.
423.
424.
425.
426.
427.
428.
429.
430.
431.
432.
433.
434.
435.
436.
437.
438.
439.
440.
441.
442.
443.
444.
445.
446.
447.
448.
449.
450.
451.
452.
453.
454.
455.
456.
457.
458.
459.
460.
461.
462.
463.
464.
465.
466.
467.
468.
469.
470.
471.
472.
473.
474.
475.
476.
477.
478.
479.
480.
481.
482.
483.
484.
485.
486.
487.
488.
489.
490.
491.
492.
493.
494.
495.
496.
497.
498.
499.
500.
501.
502.
503.
504.
505.
506.
507.
508.
509.
510.
511.
512.
513.
514.
515.
516.
517.
518.
519.
520.
521.
522.
523.
524.
525.
526.
527.
528.
529.
530.
531.
532.
533.
534.
535.
536.
537.
538.
539.
540.
541.
542.
543.
544.
545.
546.
547.
548.
549.
550.
551.
552.
553.
554.
555.
556.
557.
558.
559.
560.
561.
562.
563.
564.
565.
566.
567.
568.
569.
570.
571.
572.
573.
574.
575.
576.
577.
578.
579.
580.
581.
582.
583.
584.
585.
586.
587.
588.
589.
590.
591.
592.
593.
594.
595.
596.
597.
598.
599.
600.
601.
602.
603.
604.
605.
606.
607.
608.
609.
610.
611.
612.
613.
614.
615.
616.
617.
618.
619.
620.
621.
622.
623.
624.
625.
626.
627.
628.
629.
630.
631.
632.
633.
634.
635.
636.
637.
638.
639.
640.
641.
642.
643.
644.
645.
646.
647.
648.
649.
650.
651.
652.
653.
654.
655.
656.
657.
658.
659.
660.
661.
662.
663.
664.
665.
666.
667.
668.
669.
670.
671.
672.
673.
674.
675.
676.
677.
678.
679.
680.
681.
682.
683.
684.
685.
686.
687.
688.
689.
690.
691.
692.
693.
694.
695.
696.
697.
698.
699.
700.
701.
702.
703.
704.
705.
706.
707.
708.
709.
710.
711.
712.
713.
714.
715.
716.
717.
718.
719.
720.
721.
722.
723.
724.
725.
726.
727.
728.
729.
730.
731.
732.
733.
734.
735.
736.
737.
738.
739.
740.
741.
742.
743.
744.
745.
746.
747.
748.
749.
750.
751.
752.
753.
754.
755.
756.
757.
758.
759.
760.
761.
762.
763.
764.
765.
766.
767.
768.
769.
770.
771.
772.
773.
774.
775.
776.
777.
778.
779.
780.
781.
782.
783.
784.
785.
786.
787.
788.
789.
790.
791.
792.
793.
794.
795.
796.
797.
798.
799.
800.
801.
802.
803.
804.
805.
806.
807.
808.
809.
810.
811.
812.
813.
814.
815.
816.
817.
818.
819.
820.
821.
822.
823.
824.
825.
826.
827.
828.
829.
830.
831.
832.
833.
834.
835.
836.
837.
838.
839.
840.
841.
842.
843.
844.
845.
846.
847.
848.
849.
850.
851.
852.
853.
854.
855.
856.
857.
858.
859.
860.
861.
862.
863.
864.
865.
866.
867.
868.
869.
870.
871.
872.
873.
874.
875.
876.
877.
878.
879.
880.
881.
882.
883.
884.
885.
886.
887.
888.
889.
890.
891.
892.
893.
894.
895.
896.
897.
898.
899.
900.
901.
902.
903.
904.
905.
906.
907.
908.
909.
910.
911.
912.
913.
914.
915.
916.
917.
918.
919.
920.
921.
922.
923.
924.
925.
926.
927.
928.
929.
930.
931.
932.
933.
934.
935.
936.
937.
938.
939.
940.
941.
942.
943.
944.
945.
946.
947.
948.
949.
950.
951.
952.
953.
954.
955.
956.
957.
958.
959.
960.
/*
	This stuff is free, but some functions should stay invisible for many, many eyes. Really many.
	While you don`t know how it really works, it works. Yep. Its true.
 
	You need also:
		BanConfigUtil version >= 1.01
 
 
	Contact @ http://amxx.pl
 
*/
 
/*
 *	Compilation Options
 *
 *	If want use it delete // from next line and put exbancfg filename on top of plugins list (plugins.ini)
 */
 
 
//Replace standard ban menu
#define OVERRIDE_BANMENU
 
//add edition menu - slow thing, but could be usefull
#define EDIT_MENU
 
 
/*
 * Code
 */
 
#include <amxmodx>
#include <amxmisc>
#include <sqlx>
#include <banconfig_util>
 
 
#define PLUGIN "*ExtremeBanConfig"
#define VERSION "3.02"
#define AUTHOR "R3X&Miczu&Luk"
#define MAX_PLAYERS 32
 
#define TASKID_LOADING 453456
 
#define Keysunbancfg (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<9)
 
#define ADMIN_ACCESS ADMIN_BAN
 
 
//Config Files
#define CFG_FILE__TIMES "exban/bs_times.ini"
#define CFG_FILE__REASONS "exban/bs_reasons.ini"
 
//Buffer
new gszCfgFile[128];
new gszPrefix[32];
 
new bool:gbDebug;
 
new gszCfgid[33][CFGID_LEN];
new bool:gbIsSteam[33];
 
new gcvarMySQL;
new gcvarHUDMsg, gcvarSteamSup;
new gcvarSQLHost, gcvarSQLUser, gcvarSQLPass, gcvarSQLDB, gcvarSQLPrefix;
new Handle:gTuple;
 
//PlayerMenu
new g_Players[MAX_PLAYERS], g_playerCount;
new mcbPlayers;
new g_SelectedTime[MAX_PLAYERS+1];//buffer
new g_Target[MAX_PLAYERS+1];//buffer
new mTime, mReason;
 
#if defined EDIT_MENU
#define CLEAR_EDIT_STATE(%1) client_cmd(%1, "amx_bancfg_editmenu ^"^"")
 
new gszEditCfgid[33][CFGID_LEN];
new gszQuery[512];
 
new mBanned, mAllPlayers, mLast;
new giBanned[33], giAllPlayers[33], giLast[33];
new mGroupOfPlayers;
 
 
new giUnbanUser = 0;
new giUnbanLastSelected = -1;
#endif
 
public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR);
 
	gbDebug = (plugin_flags () & AMX_FLAG_DEBUG > 0);
	if(gbDebug)
		log_amx("------DEBUG SESSION------");
 
	register_dictionary("admincmd.txt");
	register_dictionary("adminhelp.txt");
	register_dictionary("common.txt");
 
	register_dictionary("extreme_ban3.txt");
 
	register_concmd("amx_bancfg_savesettings", "cmdSaveSettings", ADMIN_ACCESS, ": save ConfigFile on server");
	register_concmd("amx_bancfg", "cmdBanCfg", ADMIN_ACCESS, "<#userid,nick,cfgid> <czas> [powod] [kick]");
	register_concmd("amx_unbancfg", "cmdUnBanCfg", ADMIN_ACCESS, "<cfgid>");
	register_clcmd("amx_bancfg_pmenu","cmd_amx_banshot_pmenu", ADMIN_ACCESS, " : bancfg Menu");
	register_clcmd("amx_bancfg_menu","cmd_amx_banshot_menu", ADMIN_ACCESS, "<#userid, nick>");
 
 
#if defined OVERRIDE_BANMENU
	register_clcmd("amx_banmenu","cmd_amx_banshot_pmenu",ADMIN_ACCESS);
#endif
 
	register_clcmd("bancfg_custom_time","cmd_custom_time",ADMIN_ACCESS,"<time>");
	register_clcmd("bancfg_custom_reason","cmd_custom_reason",ADMIN_ACCESS,"<reason>");
#if defined EDIT_MENU
	register_clcmd("amx_unbancfg_menu","cmd_unbancfg_menu", ADMIN_ACCESS, " : unbancfg Menu");
 
	register_clcmd("amx_bancfg_editmenu", "cmd_amx_bancfg_editmenu", ADMIN_ACCESS, "<cfgid>");
#endif
 
 
	gcvarMySQL = register_cvar("amx_bancfg_use_mysql", "1");
 
	gcvarHUDMsg = register_cvar("amx_bancfg_show_hudmsg", "1");
	gcvarSteamSup = register_cvar("amx_bancfg_steam_support","0");
 
	gcvarSQLHost = register_cvar("amx_bancfg_mysql_hostname","127.0.0.1");
	gcvarSQLUser = register_cvar("amx_bancfg_mysql_user","root");
	gcvarSQLPass = register_cvar("amx_bancfg_mysql_password","root");
	gcvarSQLDB = register_cvar("amx_bancfg_mysql_dbname","bancfg");
	gcvarSQLPrefix = register_cvar("amx_bancfg_mysql_prefix","");
 
 
	mTime = menu_create("BCFG Time", "mh_Time");
	mReason = menu_create("BCFG Reason", "mh_Reason");
	mcbPlayers = menu_makecallback("mcb_Players");
 
 
#if defined EDIT_MENU
 
	register_menucmd(register_menuid("EditMenu"), Keysunbancfg, "PressedEditMenu");
	register_menucmd(register_menuid("unbancfg"), Keysunbancfg, "Pressedunbancfg");
#endif
}
public plugin_cfg(){
	//Menu
	new szCfgDir[64], szCfgFile[70];
	get_configsdir(szCfgDir,49);
 
	formatex(gszCfgFile, 127, "%s/exban/exban.cfg",szCfgDir);
 
	server_cmd("exec %s", gszCfgFile);
 
	new szHost[32], szUser[32], szPass[32], szDB[32]
	get_pcvar_string(gcvarSQLHost, szHost, 31);
	get_pcvar_string(gcvarSQLUser, szUser, 31);
	get_pcvar_string(gcvarSQLPass, szPass, 31);
	get_pcvar_string(gcvarSQLDB, szDB, 31);
	get_pcvar_string(gcvarSQLPrefix, gszPrefix, 31);
 
	new iMySQL = get_pcvar_num(gcvarMySQL);
 
	if( iMySQL == 0){
		SQL_SetAffinity("sqlite");
		gTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB);
	}else
		gTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB);
 
	if(iMySQL)
		bancfg_init(gTuple, gszPrefix);
	else
		bancfg_init(gTuple, gszPrefix);
 
 
	//Get Times and Reasons from files
	formatex(szCfgFile,69,"%s/%s",szCfgDir,CFG_FILE__TIMES);
 
	if(!file_exists(szCfgFile))
		return set_fail_state("NotFound ini file (with times)");
 
	new szTemp[REASON_LEN+1];
	new szOwn[32];
	formatex(szOwn, 31, "[%L]",LANG_SERVER, "WORD_OWN");
 
 
	new szLineB[REASON_LEN+1],iLenB;
	new iTime;
	for(new i=0;read_file(szCfgFile,i,szLineB,9,iLenB);i++){
		trim(szLineB);
		if(szLineB[0]){
			iTime = str_to_num(szLineB);
			if(iTime == 0)
				copy(szTemp,9,"Perm.");
			else{
				formatex(szTemp,13,"%d min",iTime);
			}
			menu_additem(mTime, szTemp, szLineB, ADMIN_ACCESS);
		}
	}
	menu_additem(mTime, szOwn, "Time", ADMIN_ACCESS);//Last item is Own
 
 
	formatex(szCfgFile,69,"%s/%s",szCfgDir,CFG_FILE__REASONS);
 
	if(!file_exists(szCfgFile))
		return set_fail_state("NotFound ini file (with reasons)");
 
	for(new i=0;read_file(szCfgFile,i,szLineB,REASON_LEN,iLenB);i++){
		trim(szLineB);
		if(szLineB[0]){
			menu_additem(mReason, szLineB, "Reason", ADMIN_ACCESS);
		}
	}
	menu_additem(mReason, szOwn, "Reason", ADMIN_ACCESS);//Last item is Own
 
#if defined EDIT_MENU
	prepareUnBanMenu();
#endif
 
	return PLUGIN_CONTINUE;
}
public client_putinserver(id){
	new szAuth[32];
	get_user_authid(id, szAuth, 31);
 
	gbIsSteam[id] = (contain(szAuth, "STEAM_0:") == 0); 
}
//Forwarded :D
public bancfg_authorized(id, const cfgid[], starttime, stoptime, const szAdmin[], const szReason[]){
	if(gbDebug){
		log_amx("Cfgid = %s",cfgid);
	}
	copy(gszCfgid[id], CFGID_LEN-1, cfgid);
 
	new iNow = get_systime();
	if(gbDebug){
		log_amx("%d << %d << %d",starttime, iNow, stoptime);
	}
	if(isUserBanned(starttime, stoptime)){
		kick(id, starttime, stoptime, szAdmin, szReason);
	}
}
public kick(id, starttime, stoptime, const szAdmin[], const szReason[]){
	server_cmd("kick #%d ^"%s^"", get_user_userid(id), szReason);
}
/*
Cmds
*/
 
public cmdSaveSettings(id, level, cid){
	if(!cmd_access(id, level, cid, 1))
		return PLUGIN_HANDLED;
	plugin_end();
	return PLUGIN_HANDLED;
}
public cmdBanCfg(id, level, cid){
	if(!cmd_access(id, level, cid, 3))
		return PLUGIN_HANDLED;
 
	new bool:validCmd = true;
	new bool:directCfgId = false;
 
	new szAdminName[35], szCfgId[35];
	read_argv(1, szAdminName, 32);
	new iTarget;
 
	if(strlen(szAdminName) == 32){
		directCfgId = true;
		copy(szCfgId, 34, szAdminName);
	}else{
		iTarget = cmd_target(id, szAdminName, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF);
 
		if(!is_user_connected(iTarget)){
			validCmd = false;
		}
	}
	if(validCmd){
		new szTime[32];
		read_argv(2, szTime, 31);
		new iTimeM = str_to_num(szTime);
		new iTime = iTimeM * 60;
 
 
		new szReason[REASON_LEN+1]="";
		if(read_argc() >= 4){
			read_argv(3, szReason, REASON_LEN);
		}
 
		new bool:bSteamSupport = (get_pcvar_num(gcvarSteamSup) != 0);
		new bool:bHud = (get_pcvar_num(gcvarHUDMsg) != 0);
 
		if(bSteamSupport && gbIsSteam[iTarget]){
			if(is_plugin_loaded ( "AMXBans" ) == -1){
				if(szReason[0]==0)
					client_cmd(id,"amx_ban #%d %d",get_user_userid(iTarget), iTime);
				else
					client_cmd(id,"amx_ban #%d %d ^"%s^"",get_user_userid(iTarget), iTime, szReason);
			}else{
				if(szReason[0]==0)
					client_cmd(id,"amx_ban %d #%d",iTime, get_user_userid(iTarget));
				else
					client_cmd(id,"amx_ban %d #%d ^"%s^"", iTime, get_user_userid(iTarget), szReason);
			}
		}else{
 
			new iNow = get_systime();
			new iEnd = (iTime)?(iNow+iTime):0;
			get_user_name(id, szAdminName, 31);
 
			//Hei! It is a key event of plugin, IMHO.
			bancfg_ban(id, directCfgId?szCfgId:gszCfgid[iTarget], iNow, iEnd, szAdminName, szReason);
 
			//If use cfgid as 1st argument, dont show global info
#if defined EDIT_MENU
			if(directCfgId){
				client_cmd(id, "amx_bancfg_editmenu %s", gszEditCfgid[id]);
				return PLUGIN_HANDLED;
			}
#endif
 
			if(read_argc() >= 5){
				kick(iTarget,iNow, iEnd, szAdminName, szReason);
			}
		}
 
		new szName[32];
		get_user_name(iTarget, szName, 31);
 
		// Display the message to all clients
		new msg[256];
		new len;
		new maxpl = get_maxplayers();
		iTime /= 60;
		for (new i = 1; i <= maxpl; i++)
		{
			if (is_user_connected(i) && !is_user_bot(i))
			{
				len = formatex(msg, charsmax(msg), "%L", i, "BAN");
				len += formatex(msg[len], charsmax(msg) - len, " %s ", szName);
				new szBanTime[64];
				if (iTimeM)
				{
					formatex(szTime, 31, "%d", iTime);
					formatex(szBanTime, 63, "%L", i, "FOR_MIN", szTime);
				}
				else
				{	
					formatex(szBanTime, 63, "%L", i, "PERM");
 
				}
				len +=formatex(msg[len], charsmax(msg) - len,"%s", szBanTime);
				if (strlen(szReason) > 0)
				{
					formatex(msg[len], charsmax(msg) - len, " (%L: %s)", i, "REASON", szReason);
				}
				if((!bSteamSupport) || (!gbIsSteam[iTarget]))
					show_activity_id(i, id,  szAdminName, msg);
 
				if(bHud)
					CreateHudMsg(i, iTarget, szAdminName,szReason, szBanTime);
			}
		}
 
 
 
		new szAuth[32];
		get_user_authid(iTarget, szAuth, 31);
 
		log_message("BanCfg2: ^"%s<%d><%s><>^" was kicked by ^"Console^" (reason ^"%s^")",
		szName, get_user_userid(iTarget), szAuth, szReason);
	}
 
 
	return PLUGIN_HANDLED;
}
public cmdUnBanCfg(id, level, cid){
	if(!cmd_access(id, level, cid, 2))
		return PLUGIN_HANDLED;
	new szCfgid[CFGID_LEN];
	read_argv(1, szCfgid, CFGID_LEN-1);
 
	bancfg_unban(id, szCfgid);
 
	return PLUGIN_HANDLED;
}
public bancfg_reporting(id, Float:fTime, Report:status){
	switch(status){
		case DONE:{
			console_print(id, "ReportState: OK");
		}
		case NOT_FOUND:{
			console_print(id,"ReportState: CfgId Not found");
		}
		case BAD_ADMINID:{}
	}
}
CreateHudMsg(target, id, const szAdminName[],const szReason[],const szTime[]){
	set_hudmessage(0, 255, 0, 0.1, 0.17,0,0.0,7.0,0.0,0.0, 1);
 
	new szName[32];
	get_user_name(id, szName, 31);
 
	show_hudmessage(target, "%L",id,"INFO_HUD",szName, szAdminName,szTime, szReason);
}
 
 
/*
Players Menu
*/
public cmd_amx_banshot_pmenu(id,level,cid){
	if (!cmd_access(id,level,cid,1))
		return PLUGIN_HANDLED;
 
#if defined EDIT_MENU
	CLEAR_EDIT_STATE(id);
#endif
 
	menu_display(id,buildPlayersMenu(level));
	return PLUGIN_HANDLED;
}
buildPlayersMenu(level){
	new mPlayers = menu_create("BCFG Main", "mh_Players"); // Menu Players
	new id,szUserName[50];
	get_players(g_Players, g_playerCount);
	for (new i=0; i<g_playerCount; i++){
		id = g_Players[i];
		get_user_name(id, szUserName,32);
		if(gbIsSteam[id])
			add(szUserName, 49," r(Steam)");
		else if(is_user_bot(id))
			add(szUserName, 49," r(Bot)");
		menu_additem(mPlayers, szUserName, "", level, mcbPlayers);
	}
	return mPlayers;
}
public mh_Players(id, menu, item){
	if(item<0)
		return;
	client_cmd(id,"amx_bancfg_menu #%d",get_user_userid(g_Players[item]));
}
public mcb_Players(id, menu, item) {
	if(is_user_bot(g_Players[item]) || get_user_flags(g_Players[item])&ADMIN_IMMUNITY)
		return ITEM_DISABLED;
	return ITEM_ENABLED;
}
/*
Times & Reasons  Menu
*/
public cmd_amx_banshot_menu(id,level,cid){
	if (!cmd_access(id,level,cid,2))
		return PLUGIN_HANDLED;
	new szArg1[35];
	read_argv(1,szArg1,34);
	new target_id=cmd_target(id,szArg1);
	g_Target[id]=target_id;
	if(target_id==0){
		return PLUGIN_HANDLED;
	}
	menu_display(id, mTime);
	return PLUGIN_HANDLED;
}
public mh_Time(id, menu, item){
	if(item<0)
		return;
	if((item+1)==menu_items(menu)){
		client_cmd(id,"messagemode bancfg_custom_time");
		return;
	}
	static szTemp[REASON_LEN+1];
	new iAccess, szName[1], callback;
	menu_item_getinfo(menu, item, iAccess, szTemp, REASON_LEN, szName, 0, callback);
 
	g_SelectedTime[id] = str_to_num(szTemp);
	menu_display(id, mReason);
}
public mh_Reason(id, menu, item){
	if(item<0)
		return;
	if((item+1)==menu_items(menu)){
		client_cmd(id,"messagemode bancfg_custom_reason");
		return;
	}
	static szTemp[REASON_LEN+1];
	new iAccess, szInfo[1], callback;
	menu_item_getinfo(menu, item, iAccess, szInfo, 0, szTemp, REASON_LEN, callback);
 
	banShot(id, szTemp);
}
public cmd_custom_time(id,level,cid){
	if (!cmd_access(id,level,cid,2))
		return PLUGIN_HANDLED;
#if defined EDIT_MENU
	if(g_Target[id]==0 && gszEditCfgid[id][0] == 0){
#else
	if(g_Target[id]==0){
#endif
		client_print(id,print_center,"%L", id, "INFO_CHOOSE_PLAYER");
		return PLUGIN_HANDLED;
	}
	new szArg1[10];
	read_argv(1,szArg1,9);
	g_SelectedTime[id]=str_to_num(szArg1);
	menu_display(id, mReason);
	return PLUGIN_HANDLED;
}
public cmd_custom_reason(id,level,cid){
	if (!cmd_access(id,level,cid,2))
		return PLUGIN_HANDLED;
#if defined EDIT_MENU
	if(g_Target[id]==0 && gszEditCfgid[id][0] == 0){
#else
	if(g_Target[id]==0){
#endif
		client_print(id,print_center,"%L", id, "INFO_CHOOSE_PLAYER");
		return PLUGIN_HANDLED;
	}
	new szArg1[REASON_LEN+1];
	read_argv(1,szArg1,REASON_LEN);
	banShot(id,szArg1);
	return PLUGIN_HANDLED;
}
public banShot(id,szReason[REASON_LEN+1]){
#if defined EDIT_MENU
	if(gbDebug){
		log_amx("Edit: %s", gszEditCfgid[id]);
	}
	if(gszEditCfgid[id][0]){
		client_cmd(id,"amx_bancfg %s %d ^"%s^"",gszEditCfgid[id], g_SelectedTime[id], szReason);	
	}
#endif
	client_cmd(id,"amx_bancfg #%d %d ^"%s^" 1",get_user_userid(g_Target[id]),g_SelectedTime[id], szReason);
	g_Target[id]=0;
}
 
/*
Save Config
*/
public plugin_end(){
	if(file_exists(gszCfgFile)){
		delete_file(gszCfgFile);
	}
 
	new szTemp[96];
 
	write_file(gszCfgFile, "//HUD Info^n//^t0-Off^n//^t1-On^n");
	formatex(szTemp, 95, "amx_bancfg_show_hudmsg ^"%d", get_pcvar_num(gcvarHUDMsg));
	write_file(gszCfgFile,szTemp);
 
 
	write_file(gszCfgFile, "^n//Support of Steam Players^n//^t0-Off^n//^t1-On");
	formatex(szTemp, 95, "amx_bancfg_steam_support ^"%d", get_pcvar_num(gcvarSteamSup));
	write_file(gszCfgFile,szTemp);
 
	write_file(gszCfgFile, "^n//MySQL Info");
 
	get_pcvar_string(gcvarSQLHost, szTemp, 95);
	format(szTemp, 95, "amx_bancfg_mysql_hostname ^"%s^"",szTemp);
	write_file(gszCfgFile,szTemp);
 
	get_pcvar_string(gcvarSQLUser, szTemp, 95);
	format(szTemp, 95, "amx_bancfg_mysql_user ^"%s^"",szTemp);
	write_file(gszCfgFile,szTemp);
 
	get_pcvar_string(gcvarSQLPass, szTemp, 95);
	format(szTemp, 95, "amx_bancfg_mysql_password ^"%s^"",szTemp);
	write_file(gszCfgFile,szTemp);
 
	get_pcvar_string(gcvarSQLDB, szTemp, 95);
	format(szTemp, 95, "amx_bancfg_mysql_dbname ^"%s^"",szTemp);
	write_file(gszCfgFile,szTemp);
 
 
	write_file(gszCfgFile, "^n//Table prefix");
 
	get_pcvar_string(gcvarSQLPrefix, szTemp, 95);
	format(szTemp, 95, "amx_bancfg_mysql_prefix ^"%s^"",szTemp);
	write_file(gszCfgFile,szTemp);
}
 
/*
*	----------------------------------------------
*		    EDIT MENU Code Section
*	----------------------------------------------
*/
 
#if defined EDIT_MENU
 
/*
UnBanMenu
*/
 
public cmd_unbancfg_menu(id, level, cid){
	if(!cmd_access(id, level, cid, 1))
		return PLUGIN_HANDLED;
 
	if(is_user_connected(giUnbanUser) && giUnbanUser!=id){
		new szName[32];
		get_user_name(giUnbanUser, szName, 31);
 
		client_print(id, print_console, "Z menu unbana aktualnie korzysta admin %s!",szName);
		client_print(id, print_chat, "Z menu unbana aktualnie korzysta admin %s!",szName);
		return PLUGIN_HANDLED;
	}
	giUnbanUser = id;
	show_menu(id, Keysunbancfg, "yUnban Config Menu^n^nw1. Zbanowani^n2. Lista graczy^n^n3. Ostatnio wydane^n^n0. Wyjscie^n", -1, "unbancfg") // Display menu
	return PLUGIN_HANDLED;
}
public cmd_amx_bancfg_editmenu(id, level, cid){
	if(!cmd_access(id, level, cid, 2))
		return PLUGIN_HANDLED;
	new szCfgid[2*CFGID_LEN];
	read_argv(1, szCfgid, CFGID_LEN-1);
 
	if(strlen(szCfgid) < 20){
		//console_print(id, "Clear State");
		copy(gszEditCfgid[id], CFGID_LEN, "");
		return PLUGIN_HANDLED;
	}
 
	SQL_PrepareString(szCfgid, szCfgid, 2*CFGID_LEN-1);
 
	startLoading(id);
 
	formatex(gszQuery, 511, "SELECT * FROM `%susers` WHERE cfgid = '%s'", gszPrefix, szCfgid);
 
	copy(gszEditCfgid[id], CFGID_LEN, szCfgid);
 
 
	new data[1];
	data[0] = id;
	SQL_ThreadQuery(gTuple, "handlePlayerEditMenu", gszQuery, data, 1);
 
 
	return PLUGIN_HANDLED;
}
prepareUnBanMenu(){
 
	mBanned = menu_create("*BCFG Banned","mh_Banned");
	mAllPlayers = menu_create("#BCFG Players","mh_AllPlayers");
	mLast= menu_create("$BCFG Last","mh_Last");
 
	prepareAllPlayersMenu();
 
}
/*prepareBannedMenu(){
 
}*/
prepareAllPlayersMenu(){
	new szLabel[10];
 
	formatex(szLabel, 9, "Other");
	menu_additem(mAllPlayers, szLabel,"", ADMIN_ACCESS);
 
	formatex(szLabel, 9, "Other");
	menu_additem(mBanned, szLabel,"", ADMIN_ACCESS);
 
	for(new i='A';i<='Z';i++){
		formatex(szLabel, 9, "%c",i);
		menu_additem(mAllPlayers, szLabel, "", ADMIN_ACCESS);
		menu_additem(mBanned, szLabel, "", ADMIN_ACCESS);
 
	}
 
}
prepareLastMenu(id){
	startLoading(id);
 
	formatex(gszQuery, 511, "SELECT * FROM `%susers` WHERE ( starttime > 1000 && (stoptime < 1000 || stoptime >= NOW())) ORDER BY starttime LIMIT 15", gszPrefix);
 
	new data[1];
	data[0] = id;
	SQL_ThreadQuery(gTuple, "handleLastMenu", gszQuery, data, 1);
}
public PressedEditMenu(id, key){
 
	switch(key){
		case 0:{
			bancfg_unban(id, gszEditCfgid[id]);
		}
		case 1:{
			menu_display(id, mTime);
			return;
		}
		case 9:{
		}
	}
	CLEAR_EDIT_STATE(id);
}
public Pressedunbancfg(id, key) {
	/* Menu:
	* Unban Config Menu
	* 
	* 1. Zbanowani
	* 2. Lista graczy
	* 
	* 3. Ostatnio wydane
	* 
	* 0. Wyjscie
	*/
 
	switch (key) {
		case 0: { // 1
			giBanned[id] = 0;
			menu_display(id, mBanned, giBanned[id]);
		}
		case 1: { // 2
			giAllPlayers[id] = 0;
			menu_display(id, mAllPlayers, giAllPlayers[id]);
		}
		case 2: { // 3
			prepareLastMenu(id);
		}
		case 9: { // 0
			giUnbanUser = 0;
			CLEAR_EDIT_STATE(id);
		}
	}
}
public mh_Banned(id, menu, item){
	new iTemp;
	player_menu_info ( id, iTemp, iTemp, giBanned[id]);
 
	switch(item){
		case MENU_EXIT:{
			client_cmd(id, "amx_unbancfg_menu");
			CLEAR_EDIT_STATE(id);
			return;
		}
		case MENU_BACK, MENU_MORE:{}
		default:{
			if(giUnbanLastSelected != item){
				createBannedMenu(id, item);
				startLoading(id);
			}
			else
				menu_display(id, mGroupOfPlayers);
 
		}
	}
}
public mh_AllPlayers(id, menu, item){
	new iTemp;
	player_menu_info ( id, iTemp, iTemp, giAllPlayers[id]);
 
	switch(item){
		case MENU_EXIT:{
			client_cmd(id, "amx_unbancfg_menu");
			CLEAR_EDIT_STATE(id);
			return;
		}
		case MENU_BACK, MENU_MORE:{}
		default:{
			if(giUnbanLastSelected != item){
				createPlayersMenu(id, item);
				startLoading(id);
			}
			else
				menu_display(id, mGroupOfPlayers);
 
		}
	}
 
 
}
startLoading(id){
	if(!task_exists(id+TASKID_LOADING)){
		new param[1];
		param[0] = 0;
		taskLoadingInfo(param, id+TASKID_LOADING);
	}
}
stopLoading(id){
	if(task_exists(id+TASKID_LOADING))
		remove_task(id+TASKID_LOADING);
}
public taskLoadingInfo(param[], id){
	id -= TASKID_LOADING;
 
	if(!is_user_alive(id))
		return;
 
	set_hudmessage(255, 255, 255, -1.0, 0.3, 0,0.0, 0.1);
 
	new szInfo[4];
	for(new i=0;i<3;i++){
		szInfo[i] = (i<param[0])?'.':' ';
	}
	szInfo[3] = 0;
 
	param[0]++;
	if(param[0] >= 4)
		param[0] = 0;
 
	show_hudmessage(id, "Loading%s",szInfo);
 
	set_task(0.1, "taskLoadingInfo",id+TASKID_LOADING, param, 1);
}
public mh_Last(id, menu, item){
	new iTemp;
	player_menu_info ( id, iTemp, iTemp, giLast[id]);
}
public mh_GroupOfPlayers(id, menu, item){
	if(item >= 0){
		new acc;
		new szCfgid[CFGID_LEN];
		menu_item_getinfo(menu, item, acc, szCfgid, CFGID_LEN-1,"", 0, acc);
		if(gbDebug){
			client_print(id, print_chat, "Edit %s", szCfgid);
		}
		client_cmd(id, "amx_bancfg_editmenu ^"%s^"",szCfgid);
	}else{
		menu_display(id, mAllPlayers, giAllPlayers[id]);
		CLEAR_EDIT_STATE(id);
	}
}
createBannedMenu(id, item){
	new szCond[64];
	if(item == 0)
		copy(szCond, 63, "UPPER(name) NOT BETWEEN 'A' AND 'Z'");
	else{
		item--;
		formatex(szCond, 63, "UPPER(name) LIKE '%c%%'", item+'A');
	}
	formatex(gszQuery, 511, "SELECT cfgid, name FROM `%susers` WHERE %s && (starttime>1000 && (starttime <= NOW()) && ((stoptime > NOW()) || stoptime < 1000))", gszPrefix, szCond);
 
	new data[2];
	data[0] = id;
	data[1] = item;
	SQL_ThreadQuery(gTuple, "handlePlayersInnerMenu", gszQuery, data, 2);
}
createPlayersMenu(id, item){
	new szCond[64];
	if(item == 0)
		copy(szCond, 63, "UPPER(name) NOT BETWEEN 'A' AND 'Z'");
	else{
		item--;
		formatex(szCond, 63, "UPPER(name) LIKE '%c%%'", item+'A');
	}
	formatex(gszQuery, 511, "SELECT cfgid, name FROM `%susers` WHERE %s && (!(starttime>1000 && (starttime <= NOW()) && ((stoptime > NOW()) || stoptime < 1000)))", gszPrefix, szCond);
 
	new data[2];
	data[0] = id;
	data[1] = item;
	SQL_ThreadQuery(gTuple, "handlePlayersInnerMenu", gszQuery, data, 2);
}
public handlePlayerEditMenu(failstate, Handle:query, error[], errnum, data[], size){
	new id = data[0];
	stopLoading(id);
 
	if(!is_user_connected(id))
		return;
	if(!failstate){
		if(SQL_NumRows(query)){
			new szStartTime[64], szStopTime[64];
			new szName[64], szIP[64];
			new szAdminName[64], szReason[REASON_LEN+1];
 
			SQL_ReadResult(query, 0, gszEditCfgid[id], CFGID_LEN);
 
			SQL_ReadResult(query, 1, szName, 63);
			SQL_ReadResult(query, 3, szIP, 63);
 
			SQL_ReadResult(query, 4, szStartTime, 63);
			SQL_ReadResult(query, 5, szStopTime, 63);
 
			SQL_ReadResult(query, 6, szAdminName, 63);
			SQL_ReadResult(query, 7, szReason, 63);
 
			new iStartTime = parse_time(szStartTime, TIMEFORMAT);
			new iStopTime = parse_time(szStopTime, TIMEFORMAT);
 
			new szMenu[256], iMax = sizeof szMenu, iLen=0;
 
 
			iLen += formatex(szMenu[iLen], iMax-iLen, "yEdit user Menu^n^n");
			iLen += formatex(szMenu[iLen], iMax-iLen, "rName:w %s^nrIP:w%s^n",szName, szIP);
 
			new iKeys = (1<<1)|(1<<9);
 
			//log_amx("%d %d", iStartTime ,iStopTime);
			if(isUserBanned(iStartTime ,iStopTime)){
				iLen += formatex(szMenu[iLen], iMax-iLen, "rStart Ban:w%s^n",szStartTime);
				iLen += formatex(szMenu[iLen], iMax-iLen, "rEnd Ban:w%s^n",szStopTime);
				iLen += formatex(szMenu[iLen], iMax-iLen, "rAdmin:w%s^n",szAdminName);
				iLen += formatex(szMenu[iLen], iMax-iLen, "rReason:w%s^n",szReason);
				iLen += formatex(szMenu[iLen], iMax-iLen, "^n1. UnBan^n");
				iLen += formatex(szMenu[iLen], iMax-iLen, "2. (Re)Ban^n");
				iKeys|= (1<<0);
			}else{
				iLen += formatex(szMenu[iLen], iMax-iLen, "^n2. Ban^n");	
			}
			iLen += formatex(szMenu[iLen], iMax-iLen, "^n0. Exit^n");
			show_menu(id, iKeys, szMenu,_,"EditMenu");
		}else{
			client_print(id, print_chat, "Nie odnaleziono gracza o tym Cfgid");
			client_print(id, print_console, "Nie odnaleziono gracza o tym Cfgid");
		}
	}
 
}
public handlePlayersInnerMenu(failstate, Handle:query, error[], errnum, data[], size){
	new id = data[0];
	new item = data[1];
	stopLoading(id);
 
	if(!is_user_connected(id))
		return;
	if(!failstate){
		if(SQL_AffectedRows(query)){
			giUnbanLastSelected = item;
			new szName[64], szCfgId[CFGID_LEN];
			if(mGroupOfPlayers)
				menu_destroy(mGroupOfPlayers);
			mGroupOfPlayers = menu_create("$BCFG Group","mh_GroupOfPlayers");
			while(SQL_MoreResults(query)){
				SQL_ReadResult(query, 0,szCfgId, CFGID_LEN-1);
				SQL_ReadResult(query, 1, szName, 63);
 
				menu_additem(mGroupOfPlayers, szName, szCfgId);
				SQL_NextRow(query);
			}
			menu_display(id, mGroupOfPlayers);
		}else{
			client_print(id, print_chat, "Not Found");
			menu_display(id, mAllPlayers, giAllPlayers[id]);
		}
 
	}
}
public handleLastMenu(failstate, Handle:query, error[], errnum, data[], size){
	new id = data[0];
	stopLoading(id);
 
	if(!is_user_connected(id))
		return;
 
	if(!failstate){
		if(SQL_AffectedRows(query)){
			new szName[64], szCfgId[CFGID_LEN];
			if(mLast)
				menu_destroy(mLast);
			mLast = menu_create("$BCFG Last","mh_GroupOfPlayers");//use GroupOfPayers callback
			while(SQL_MoreResults(query)){
				SQL_ReadResult(query, 0,szCfgId, CFGID_LEN-1);
				SQL_ReadResult(query, 1, szName, 63);
 
				menu_additem(mLast, szName, szCfgId);
				SQL_NextRow(query);
			}
			menu_display(id, mLast);
		}else{
			client_print(id, print_chat, "No bans in database");
			client_cmd(id, "amx_unbancfg_menu");
		}
 
	}
 
}
#endif
 

Dodanych wklejek: 4031
Powered By (Pav32) Pastebin © 2011