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 1324574439509 dodana przez Portek, 22.12.2011 18:20
Typ:


1324574439509
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.
961.
962.
963.
964.
965.
966.
967.
968.
969.
970.
971.
972.
973.
974.
975.
976.
977.
978.
979.
980.
981.
982.
983.
984.
985.
986.
987.
988.
989.
990.
991.
992.
993.
994.
995.
996.
997.
998.
999.
1000.
1001.
1002.
1003.
1004.
1005.
1006.
1007.
1008.
1009.
1010.
1011.
1012.
1013.
1014.
1015.
1016.
1017.
1018.
1019.
1020.
1021.
1022.
1023.
1024.
1025.
1026.
1027.
1028.
1029.
1030.
1031.
1032.
1033.
1034.
1035.
1036.
1037.
1038.
1039.
1040.
1041.
1042.
1043.
1044.
1045.
1046.
1047.
1048.
1049.
1050.
1051.
1052.
1053.
1054.
1055.
1056.
1057.
1058.
1059.
1060.
1061.
1062.
1063.
1064.
1065.
1066.
1067.
1068.
1069.
1070.
1071.
1072.
1073.
1074.
1075.
1076.
1077.
1078.
1079.
1080.
1081.
1082.
1083.
1084.
1085.
1086.
1087.
1088.
1089.
1090.
1091.
1092.
1093.
1094.
1095.
1096.
1097.
1098.
1099.
1100.
1101.
1102.
1103.
1104.
1105.
1106.
1107.
1108.
1109.
1110.
1111.
1112.
1113.
1114.
1115.
1116.
1117.
1118.
1119.
1120.
1121.
1122.
1123.
1124.
1125.
1126.
1127.
1128.
1129.
1130.
1131.
1132.
1133.
1134.
1135.
1136.
1137.
1138.
1139.
1140.
1141.
1142.
1143.
1144.
1145.
1146.
1147.
1148.
1149.
1150.
1151.
1152.
1153.
1154.
1155.
1156.
1157.
1158.
1159.
1160.
1161.
1162.
1163.
1164.
1165.
1166.
1167.
1168.
1169.
1170.
1171.
1172.
1173.
1174.
1175.
1176.
1177.
1178.
1179.
1180.
1181.
1182.
1183.
1184.
1185.
1186.
1187.
1188.
1189.
1190.
1191.
1192.
1193.
1194.
1195.
1196.
1197.
1198.
1199.
1200.
1201.
1202.
1203.
1204.
1205.
1206.
1207.
1208.
1209.
1210.
1211.
1212.
1213.
1214.
1215.
1216.
1217.
1218.
1219.
1220.
1221.
1222.
1223.
1224.
1225.
1226.
1227.
1228.
1229.
1230.
1231.
1232.
1233.
1234.
1235.
1236.
1237.
1238.
1239.
1240.
1241.
1242.
1243.
1244.
1245.
1246.
1247.
1248.
1249.
1250.
1251.
1252.
1253.
1254.
1255.
1256.
1257.
1258.
1259.
1260.
1261.
1262.
1263.
1264.
1265.
1266.
1267.
1268.
1269.
1270.
1271.
1272.
1273.
1274.
1275.
1276.
1277.
1278.
1279.
1280.
1281.
1282.
1283.
1284.
1285.
1286.
1287.
1288.
1289.
1290.
1291.
1292.
1293.
1294.
1295.
1296.
1297.
1298.
1299.
1300.
1301.
1302.
1303.
1304.
1305.
1306.
1307.
1308.
1309.
1310.
1311.
1312.
1313.
1314.
1315.
1316.
1317.
1318.
1319.
1320.
1321.
1322.
1323.
1324.
1325.
1326.
1327.
1328.
1329.
1330.
1331.
1332.
1333.
1334.
1335.
1336.
1337.
1338.
1339.
1340.
1341.
1342.
1343.
1344.
1345.
1346.
1347.
1348.
1349.
1350.
1351.
1352.
1353.
1354.
1355.
1356.
1357.
1358.
1359.
1360.
1361.
1362.
1363.
1364.
1365.
1366.
1367.
1368.
1369.
1370.
1371.
1372.
1373.
1374.
1375.
1376.
1377.
1378.
1379.
1380.
1381.
1382.
1383.
1384.
1385.
1386.
1387.
1388.
1389.
1390.
1391.
1392.
1393.
1394.
1395.
1396.
1397.
1398.
1399.
1400.
1401.
1402.
1403.
1404.
1405.
1406.
1407.
1408.
1409.
1410.
1411.
1412.
1413.
1414.
1415.
1416.
1417.
1418.
1419.
1420.
1421.
1422.
1423.
1424.
1425.
1426.
1427.
1428.
1429.
1430.
1431.
1432.
1433.
1434.
1435.
1436.
1437.
1438.
1439.
1440.
1441.
1442.
1443.
1444.
1445.
1446.
1447.
1448.
1449.
1450.
1451.
1452.
1453.
1454.
1455.
1456.
1457.
1458.
1459.
1460.
1461.
1462.
1463.
1464.
1465.
1466.
1467.
1468.
1469.
1470.
1471.
1472.
1473.
1474.
1475.
1476.
1477.
1478.
1479.
1480.
1481.
1482.
1483.
1484.
1485.
1486.
1487.
1488.
1489.
1490.
1491.
1492.
1493.
1494.
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <sqlx>
 
#define PLUGIN "SRN"
#define VERSION "1.1 Beta"
#define AUTHOR "Pavulon"
 
#define maxplayers 20
#define ADMIN_ACCESS ADMIN_IMMUNITY
#define SECRET "**********"
 
//0 - automatycznie, 1 - steamid, 2 - ip
#define AUTH 0
 
 
new gMsgidSayText
new const gName[] = "name"
new Handle:sql_handle
 
new wishw8ings
 
new datas[maxplayers+1][3][65]
new actname[maxplayers+1][65]
new UserMenu[maxplayers+1]
 
new bool: sql_online
 
new Array:RegNick
new Array:RegPass
 
new pHost, pUser, pPass, pDb, pRes, pSpam, pMax
 
public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
 
	register_cvar("srn_version", VERSION, FCVAR_SERVER|FCVAR_SPONLY)
	set_cvar_string("srn_version", VERSION)
 
	pHost = register_cvar("srn_sql_host", "localhost")
	pUser = register_cvar("srn_sql_user", "user")
	pPass = register_cvar("srn_sql_pass", "password")
	pDb = register_cvar("srn_sql_db", "database")
	pRes = register_cvar("srn_res_time", "2592000")
	pSpam = register_cvar("srn_spam_delay", "15")
	pMax = register_cvar("srn_maxres", "1")
 
	register_clcmd("say /rezerwacja", "menu_rezerwacji")
 
	register_clcmd("menu_administracji", "menu_administracji")
	register_clcmd("ustaw_nick", "dodawanie_rezerwacji")
	register_clcmd("ustaw_pass", "dodawanie_rezerwacji")
	register_clcmd("edytuj_nick", "edytowanie_rezerwacji")
	register_clcmd("edytuj_pass", "edytowanie_rezerwacji")
	register_clcmd("prosbe_odrzuc", "zarzadzanie_prosbami")
	register_clcmd("prosbe_akceptuj", "zarzadzanie_prosbami")
	register_concmd("amx_resreload", "resreload", ADMIN_ACCESS)
 
 
	register_forward(FM_ClientUserInfoChanged, "forward_client_userinfochanged")
 
	register_dictionary("srn.txt")
 
	RegNick = ArrayCreate(35, 1)
	RegPass = ArrayCreate(35, 1)
 
	gMsgidSayText = get_user_msgid("SayText")
 
	new configsDir[64]
	get_configsdir(configsDir, 63)
	server_cmd("exec %s/srn.cfg", configsDir) 
 
	set_task(1.0, "sql_init")
	set_task(60.0, "sql_state", _, _, _, "b")
}
 
public menu_rezerwacji(id)
{
	if (!sql_online)
	{
		col_mess(id, id, "%L", LANG_PLAYER, "SRN_NOT_CONNECTED")
		return PLUGIN_HANDLED
	}
	new tmptxt[64]
	formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_TITLE")
	new MenuStart = menu_create(tmptxt, "cbMenuStart")
	new MenuStartCb = menu_makecallback("mcbMenuStart")
	formatex(tmptxt, 63, "%L %L",LANG_PLAYER,"SRN_MENU_ADD", LANG_PLAYER,"SRN_MENU_RES")
	menu_additem(MenuStart, tmptxt, "", ADMIN_ALL, MenuStartCb)
	formatex(tmptxt, 63, "%L %L",LANG_PLAYER,"SRN_MENU_EDIT", LANG_PLAYER,"SRN_MENU_RES")
	menu_additem(MenuStart, tmptxt, "", ADMIN_ALL, MenuStartCb)
	formatex(tmptxt, 63, "%L %L",LANG_PLAYER,"SRN_MENU_DEL", LANG_PLAYER,"SRN_MENU_RES")
	menu_additem(MenuStart, tmptxt, "", ADMIN_ALL, MenuStartCb)
	formatex(tmptxt, 63, "%L %L",LANG_PLAYER,"SRN_MENU_SHOW", LANG_PLAYER,"SRN_MENU_RES")
	menu_additem(MenuStart, tmptxt, "", ADMIN_ALL, MenuStartCb)
	menu_addblank(MenuStart, 0)
	formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_INFO")
	menu_additem(MenuStart, tmptxt, "", ADMIN_ALL, MenuStartCb)
	if (get_user_flags(id)&ADMIN_ACCESS)
	{
		menu_addblank(MenuStart, 0)
		formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_ADMIN")
		menu_additem(MenuStart, tmptxt, "", ADMIN_ALL, MenuStartCb)
	}
	formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_EXIT")
	menu_setprop(MenuStart, MPROP_EXITNAME, tmptxt)
	menu_display(id, MenuStart, 0)
	return PLUGIN_HANDLED
}
 
public mcbMenuStart(id, menu, item)
{
	if(item==5 && (!(get_user_flags(id)&ADMIN_ACCESS)))
		return ITEM_DISABLED
	return ITEM_ENABLED
}
 
public cbMenuStart(id, menu, item)
{
	new query[256], auth_id[36], data[1]
 
	if (0 <= item <= 3)
	{
		#if AUTH == 0 || AUTH == 1
			get_user_authid(id, auth_id, 35)
		#endif
		#if AUTH == 0
			if (!valid_steam(auth_id))
		#endif
		#if AUTH == 0 || AUTH == 2
			get_user_ip(id, auth_id, 35, 1)
		#endif
 
		format(query, 255,"SELECT `id`, `nick`, `password` FROM srn_reservations WHERE `auth_id`='%s'", auth_id)	
		data[0] = id
	}
 
	switch(item)
	{
		case 0:
		{
			SQL_ThreadQuery(sql_handle, "dodaj_rezerwacje0", query, data, 1)	
		}
		case 1:
		{
			SQL_ThreadQuery(sql_handle, "edytuj_rezerwacje0", query, data, 1)	
		}
		case 2:
		{
			SQL_ThreadQuery(sql_handle, "usun_rezerwacje0", query, data, 1)	
		}
		case 3:
		{
			SQL_ThreadQuery(sql_handle, "pokaz_rezerwacje0", query, data, 1)
		}
		case 4:
		{
			new tmptxt[64]
			formatex(tmptxt, 63, "%L^n%L:",LANG_PLAYER, "SRN_MENU_TITLE", LANG_PLAYER,"SRN_MENU_INFO")
			new Menu = menu_create(tmptxt,"cbInfo"); 
			menu_additem(Menu, "****************************")
			formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_USAGE1", (get_pcvar_float(pRes)/(60*60*24)))
			menu_additem(Menu, tmptxt)
			formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_USAGE2")
			menu_additem(Menu, tmptxt)
			formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_USAGE3")
			menu_additem(Menu, tmptxt)
			formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_USAGE4")
			menu_additem(Menu, tmptxt)
			menu_additem(Menu, "****************************")
			menu_setprop(Menu, MPROP_EXITNAME, "Wyjscie")
			menu_display(id, Menu, 0)
			menu_destroy(Menu)
		}
		case 5:
		{
			client_cmd(id, "menu_administracji")
		}
		case MENU_EXIT:
		{
			menu_destroy(menu)
			return PLUGIN_HANDLED
		}
	}
	menu_destroy(menu)
	return PLUGIN_HANDLED
}
 
public cbInfo() {}
 
public menu_administracji(id)
{
	if (!sql_online)
	{
		col_mess(id, id, "%L", LANG_PLAYER, "SRN_NOT_CONNECTED")
		return PLUGIN_HANDLED
	}
	if (!(get_user_flags(id)&ADMIN_ACCESS))
	{
		console_print(id, "%L", LANG_PLAYER, "SRN_NO_ACCESS")
		return PLUGIN_HANDLED
	}
	new tmptxt[64]
	formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_TITLE")
	new MenuAdmin = menu_create(tmptxt, "cbMenuAdmin")
	new MenuAdminCb = menu_makecallback("mcbMenuStart")
 
	formatex(tmptxt, 63, "%L %L",LANG_PLAYER,"SRN_MENU_RELOAD", LANG_PLAYER,"SRN_MENU_RES")
	menu_additem(MenuAdmin, tmptxt, "", ADMIN_ACCESS, MenuAdminCb)
 
	formatex(tmptxt, 63, "%L %L",LANG_PLAYER,"SRN_MENU_DEL", LANG_PLAYER,"SRN_MENU_RES")
	menu_additem(MenuAdmin, tmptxt, "", ADMIN_ACCESS, MenuAdminCb)
 
	formatex(tmptxt, 63, "%L", LANG_PLAYER,"SRN_MENU_WISH_MANAGE")
	menu_additem(MenuAdmin, tmptxt, "", ADMIN_ACCESS, MenuAdminCb)
 
	formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_EXIT")
	menu_setprop(MenuAdmin, MPROP_EXITNAME, tmptxt)
	menu_display(id, MenuAdmin, 0)
	return PLUGIN_HANDLED
}
 
public mcbMenuAdmin(id, menu, item)
{
	return ITEM_ENABLED
}
 
public cbMenuAdmin(id, menu, item)
{
	new data[2]
	data[0] = id
	switch(item)
	{
		case 0:
		{
			client_cmd(id, "amx_resreload")
		}
		case 1:
		{
			new query[256]
			format(query, 255,"SELECT `id`, `nick`, `auth_id` FROM srn_reservations ORDER BY `date` DESC")
			SQL_ThreadQuery(sql_handle, "zarzadzaj_rezerwacjami0", query, data, 2)	
		}
		case 2:
		{
			new query[256]
			format(query, 255,"SELECT `id`, `nick`, `auth_id`, `password` FROM srn_res_wish ORDER BY `date` DESC")
			SQL_ThreadQuery(sql_handle, "zarzadzaj_prosbami0", query, data, 2)	
		}
		case MENU_EXIT:
		{
			menu_destroy(menu)
			return PLUGIN_HANDLED
		}
	}
	menu_destroy(menu)
	return PLUGIN_HANDLED
}
 
public zarzadzaj_rezerwacjami0(failstate, Handle:query, error[], errnum, data[], size)
{
	new id = data[0]
	new tmptxt[70]
	formatex(tmptxt, 63, "%L^n%L %L:",LANG_PLAYER, "SRN_MENU_TITLE",LANG_PLAYER,"SRN_MENU_DEL", LANG_PLAYER,"SRN_MENU_RES")
	new Menu = menu_create(tmptxt,"cbAdminUsunRezerwacje")
	new sql_id[8]
	new sql_name[33]
	new sql_steam[36]
 
	if (failstate)
	{
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 1)
	}
	else
	{	
		sql_online = true
		new row = 1
		new count_names = SQL_NumResults(query)
 
		if (!count_names)
		{
			col_mess(id, id, "%L", LANG_PLAYER, "SRN_NO_RES")
			menu_destroy(Menu)
			UserMenu[id] = 0
		} else 
			while (row++ <= count_names)
			{
				SQL_ReadResult(query, 0, sql_id, 5)
				SQL_ReadResult(query, 1, sql_name, 32)
				SQL_ReadResult(query, 2, sql_steam, 35)
				strtolower(sql_name)
				formatex(tmptxt, 69, "%s: %s", sql_steam, sql_name)
				format(sql_id, 69, "%s", sql_id)
				menu_additem(Menu, tmptxt, sql_id)
				SQL_NextRow(query)
			}
	}
	formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_CANCEL")
	menu_setprop(Menu, MPROP_EXITNAME, tmptxt)
	menu_display(id, Menu, 0)
	UserMenu[id] = Menu
 
	return PLUGIN_HANDLED
}
 
public zarzadzaj_prosbami0(failstate, Handle:query, error[], errnum, data[], size)
{
	new id = data[0]
 
	if (failstate)
	{
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 2)
	}
	else
	{	
		sql_online = true
		new row = 1
		new count_names = SQL_NumResults(query)
 
		if (!count_names)
		{
			col_mess(id, id, "%L", LANG_PLAYER, "SRN_NO_RES")
			UserMenu[id] = 0
		} else {
			new sql_id[50]
			new sql_name[33]
			new sql_steam[36]
			new sql_pass[35]
 
			new tmptxt[70]
			formatex(tmptxt, 63, "%L^n%L:",LANG_PLAYER, "SRN_MENU_TITLE", LANG_PLAYER,"SRN_MENU_WISH_MANAGE")
			new Menu = menu_create(tmptxt,"cbAdminListaProsb")
 
			while (row++ <= count_names)
			{
				SQL_ReadResult(query, 0, sql_id, 5)
				SQL_ReadResult(query, 1, sql_name, 32)
				SQL_ReadResult(query, 2, sql_steam, 35)
				SQL_ReadResult(query, 3, sql_pass, 34)
				strtolower(sql_name)
				formatex(tmptxt, 69, "%s: %s", sql_steam, sql_name)
				format(sql_id, 49, "%s:%s", sql_id, sql_pass)
				menu_additem(Menu, tmptxt, sql_id)
				SQL_NextRow(query)
			}
			formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_CANCEL")
			menu_setprop(Menu, MPROP_EXITNAME, tmptxt)
			menu_display(id, Menu, 0)
			UserMenu[id] = Menu
		}
	}
 
	return PLUGIN_HANDLED
}
 
public cbAdminListaProsb(id, menu, item)
{
	new sql_nick[70], sql_pass[70]
	new acc, callback
 
	if (item != MENU_EXIT)
	{
		menu_item_getinfo(menu, item, acc, sql_pass, 69, sql_nick, 69, callback)
 
		if (!strlen(sql_nick))
		{
			menu_destroy(menu)
			menu_cancel(id)
			UserMenu[id] = 0
			return PLUGIN_HANDLED
		}
 
		new tmptxt[64]
		formatex(tmptxt, 63, "%L^n%L:",LANG_PLAYER, "SRN_MENU_TITLE", LANG_PLAYER,"SRN_MENU_WISH_MANAGE")
		new Menu = menu_create(tmptxt, "cbAdminDodajusunProsby")
		new MenuCb = menu_makecallback("mcbAdminDodajusunProsby")
		menu_additem(Menu, sql_nick, sql_pass, ADMIN_ALL, MenuCb)
		menu_addblank(Menu, 0)
		formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_ACCEPT")
		menu_additem(Menu, tmptxt, "", ADMIN_ALL, MenuCb)
		menu_addblank(Menu, 0)
		formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_DEL")
		menu_additem(Menu, tmptxt, "", ADMIN_ALL, MenuCb)
		formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_CANCEL")
		menu_setprop(Menu, MPROP_EXITNAME, tmptxt)
		menu_destroy(menu)
		menu_cancel(id)
		menu_display(id, Menu, 0)
		UserMenu[id] = Menu
		return PLUGIN_HANDLED
	}
 
	return PLUGIN_HANDLED
}
 
public cbAdminDodajusunProsby(id, menu, item)
{
	switch(item)
	{
		case 1:
		{
			client_cmd(id, "prosbe_akceptuj")
		}
		case 2:
		{
			client_cmd(id, "prosbe_odrzuc")
		}
		case MENU_EXIT:
		{
			menu_destroy(menu)
			UserMenu[id] = 0	
		}
	}
}
 
public mcbAdminDodajusunProsby(id, menu, item)
{
	if(item==0)
		return ITEM_DISABLED
	return ITEM_ENABLED
}
 
public zarzadzanie_prosbami(id)
{
	new command[32]
	read_argv(0, command, 33)
 
	new info[50], name[70]
 
	new acc, callback
 
	menu_item_getinfo(UserMenu[id], 0, acc, info, 49, name, 69, callback)
	new sql_name[35], sql_steam[36], sql_id[6], sql_pass[35]
	strtok(info, sql_id, 5, sql_pass, 34, ':')
	split(name, sql_steam, 35, sql_name, 32, ": ")
 
	new query[256]
	if (contain(command, "_odrzuc")!=-1)
	{
		format(query, 255, "DELETE FROM srn_res_wish WHERE `id` = '%s'", sql_id)
		new data[1]
		data[0] = id
		SQL_ThreadQuery(sql_handle, "OdrzucProsbe", query, data, 1)
	} else if (contain(command, "_akceptuj")!=-1)
	{
		new authid[36]
		#if AUTH == 0 || AUTH == 1
			get_user_authid(id, authid, 35)
		#endif
		#if AUTH == 0
			if (!valid_steam(authid))
		#endif
		#if AUTH == 0 || AUTH == 2
			get_user_ip(id, authid, 35, 1)
		#endif
		format(query, 255, "INSERT INTO srn_reservations VALUES (NULL, '%d', '%s', '%s', '%s', '%s')", get_systime(), sql_steam, sql_name, sql_pass, authid)
		sql_name[32] = 0
		sql_name[33] = str_to_num(sql_id)
		sql_name[34] = id
 
		SQL_ThreadQuery(sql_handle, "AkceptujProsbe", query, sql_name, 35)
	}
 
	menu_destroy(UserMenu[id])
	menu_cancel(id)
	UserMenu[id] = 0
 
	return PLUGIN_HANDLED
}
 
public OdrzucProsbe(failstate, Handle:query, error[], errnum, data[], size)
{
	if (failstate)
	{
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 3)
	} else {
		if (data[0])
			col_mess(data[0], data[0], "%L", LANG_PLAYER, "SRN_MENU_WISH_CANC")
	}
 
	return PLUGIN_HANDLED
}
 
public AkceptujProsbe(failstate, Handle:query, error[], errnum, data[], size)
{
	if (failstate)
	{
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 4)
	} else {
		if (data[34])
			col_mess(data[34], data[34], "%L", LANG_PLAYER, "SRN_MENU_WISH_ACC")
 
		new query2[256]
		format(query2, 255, "DELETE FROM srn_res_wish WHERE `id` = '%d'", data[33])
		new data[1]
		data[0] = 0
		SQL_ThreadQuery(sql_handle, "OdrzucProsbe", query2, data, 1)
	}
 
	return PLUGIN_HANDLED
}
 
public cbAdminUsunRezerwacje(id, menu, item)
{
	new sql_nick[35], sql_id[6], tmptxt[70]
	new acc, callback
 
	if (item != MENU_EXIT)
	{
		new sql_steam[36]
		menu_item_getinfo(menu, item, acc, sql_id, 5, tmptxt, 69, callback)
		replace(tmptxt, 65, "| ", "|")
		strtok(tmptxt, sql_steam, 35, sql_nick, 32, ':')
 
		new query2[256], auth_id[36]
		#if AUTH == 0 || AUTH == 1
			get_user_authid(id, auth_id, 35)
		#endif
		#if AUTH == 0
			if (!valid_steam(auth_id))
		#endif
		#if AUTH == 0 || AUTH == 2
			get_user_ip(id, auth_id, 35, 1)
		#endif
		format(query2,255,"INSERT INTO srn_history VALUES (NULL, '%d', '%s', '%s', '%s')", get_systime(0), sql_steam, sql_nick, auth_id)
 
		if (strlen(sql_nick))
		{
			sql_nick[32] = 0
			sql_nick[33] = str_to_num(sql_id)
			sql_nick[34] = id
			SQL_ThreadQuery(sql_handle, "UsunZHistorii", query2, sql_nick, 35)
		}
	}
 
	menu_destroy(menu)
	UserMenu[id] = 0
}
 
public dodaj_rezerwacje0(failstate, Handle:query, error[], errnum, data[], size)
{
	new id = data[0]
 
	if (failstate)
	{
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 5)
	}
	else
	{
		sql_online = true
		if (SQL_NumResults(query) >= get_pcvar_num(pMax))
		{
			col_mess(id, id, "%L", LANG_PLAYER, "SRN_RES_LIMIT", get_pcvar_num(pMax))
			UserMenu[id] = 0
			return PLUGIN_HANDLED
		}
		new tmptxt[64]
		formatex(tmptxt, 63, "%L^n%L:",LANG_PLAYER, "SRN_MENU_TITLE", LANG_PLAYER,"SRN_MENU_ADD")
		new Menu = menu_create(tmptxt,"cbDodajRezerwacje"); 
		new MenuCb = menu_makecallback("mcbDodajRezerwacje")
		formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_SETNICK")
		menu_additem(Menu, tmptxt, "", ADMIN_ALL, MenuCb)
		menu_additem(Menu, "","",ADMIN_ALL, MenuCb)
		formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_SETPASS")
		menu_additem(Menu, tmptxt, "", ADMIN_ALL, MenuCb)
		menu_additem(Menu, "","",ADMIN_ALL, MenuCb)
		formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_ACCEPT")
		menu_additem(Menu, tmptxt,"",ADMIN_ALL, MenuCb)
		formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_CANCEL")
		menu_setprop(Menu, MPROP_EXITNAME, tmptxt)
		menu_display(id, Menu, 0)
		UserMenu[id] = Menu
	}
 
	return PLUGIN_HANDLED
}
 
public cbDodajRezerwacje(id, menu, item)
{
	new data[2]
	new acc, callback
 
	switch(item)
	{
		case 0:
		{
			client_cmd(id, "messagemode ^"ustaw_nick^"")
			menu_display(id, menu, 0)
			return
		}
		case 2:
		{
			client_cmd(id, "messagemode ^"ustaw_pass^"")
			menu_display(id, menu, 0)
			return
		}
		case 4:
		{
			menu_item_getinfo(menu, 1, acc, data, 1, datas[id][0], 32, callback)
			menu_item_getinfo(menu, 3, acc, data, 1, datas[id][1], 32, callback)
 
			if (strlen(datas[id][0])>3 && strlen(datas[id][1])>3)
			{
				col_mess(id, id, "%L", LANG_PLAYER, "SRN_PLZ_WRITE")
				col_mess(id, id, "!tsetinfo ^"_res^" ^"%s^"", datas[id][1])
				client_cmd(id, "setinfo ^"_res^" ^"%s^"", datas[id][1])
 
				new query[256], data[1]
				data[0] = id
				#if AUTH == 0 || AUTH == 1
					get_user_authid(id, datas[id][2], 35)
				#endif
				#if AUTH == 0
					if (!valid_steam(datas[id][2]))
				#endif
				#if AUTH == 0 || AUTH == 2
					get_user_ip(id, datas[id][2], 35, 1)
				#endif
 
				new md5_pass[34]
				md5(datas[id][1], md5_pass)
				copy(datas[id][1], 34, md5_pass)
 
				format(query, 255,"SELECT `id` FROM srn_res_wish WHERE `auth_id`='%s'", datas[id][2])
				SQL_ThreadQuery(sql_handle, "WstawRezerwacje", query, data, 1)
			} else {
				col_mess(id, id, "%L", LANG_PLAYER, "SRN_TOO_SHORT")
				menu_display(id, menu, 0)
				return
			}
		}
	}
 
	menu_destroy(menu)
	UserMenu[id] = 0
}
 
public mcbDodajRezerwacje(id, menu, item)
{
	if(1 == item || item == 3)
		return ITEM_DISABLED
	return ITEM_ENABLED
}
 
public dodawanie_rezerwacji(id)
{
	new command[32]
	read_argv(0, command, 33)
 
	new nick[33], pass[35]
 
	new data[2], acc, callback
 
	if (contain(command, "_nick")!=-1)
	{
		read_argv(1, nick, 32)
		replace_all(nick, 32, "\", "")
		replace_all(nick, 32, "'", "`")
	} else {
		menu_item_getinfo(UserMenu[id], 1, acc, data, 1, nick, 32, callback)
	}
 
	if (contain(command, "_pass")!=-1)
	{
		read_argv(1, pass, 34)
		replace_all(pass, 34, "\", "")
		replace_all(pass, 34, "'", "`")
	} else {
		menu_item_getinfo(UserMenu[id], 3, acc, data, 1, pass, 34, callback)
	}
 
	new tmptxt[64]
	formatex(tmptxt, 63, "%L^n%L:",LANG_PLAYER, "SRN_MENU_TITLE", LANG_PLAYER,"SRN_MENU_ADD")
	new Menu = menu_create(tmptxt,"cbDodajRezerwacje"); 
	new MenuCb = menu_makecallback("mcbDodajRezerwacje")
	formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_SETNICK")
	menu_additem(Menu, tmptxt, "", ADMIN_ALL, MenuCb)
	menu_additem(Menu, nick,"",ADMIN_ALL, MenuCb)
	formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_SETPASS")
	menu_additem(Menu, tmptxt, "", ADMIN_ALL, MenuCb)
	menu_additem(Menu, pass,"",ADMIN_ALL, MenuCb)
	formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_ACCEPT")
	menu_additem(Menu, tmptxt,"",ADMIN_ALL, MenuCb)
	formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_CANCEL")
	menu_setprop(Menu, MPROP_EXITNAME, tmptxt)
	menu_destroy(UserMenu[id])
	menu_cancel(id)
 
	UserMenu[id] = Menu
	menu_display(id, UserMenu[id], 0)
 
	return PLUGIN_HANDLED
}
 
public edytuj_rezerwacje0(failstate, Handle:query, error[], errnum, data[], size)
{
	new id = data[0]
	new tmptxt[64]
	formatex(tmptxt, 63, "%L^n%L:",LANG_PLAYER, "SRN_MENU_TITLE", LANG_PLAYER,"SRN_MENU_EDIT")
	new Menu = menu_create(tmptxt,"cbEdytujRezerwacje")
	new sql_name[33], sql_pass[35], sql_id[6]
 
	if (failstate)
	{
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 6)
	}
	else
	{
		sql_online = true
		new row = 1
		new count_names = SQL_NumResults(query)
 
		if (!count_names)
		{
			col_mess(id, id, "%L", LANG_PLAYER, "SRN_NO_RES")
			menu_destroy(Menu)
			UserMenu[id] = 0
		} else 
			while (row++ <= count_names)
			{
				SQL_ReadResult(query, 0, sql_id, 5)
				SQL_ReadResult(query, 1, sql_name, 32)
				SQL_ReadResult(query, 2, sql_pass, 34)
				strtolower(sql_name)
				formatex(tmptxt, 63, "%s:%s",sql_id, sql_pass)
				menu_additem(Menu, sql_name, tmptxt)
				SQL_NextRow(query)
			}
	}
	formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_CANCEL")
	menu_setprop(Menu, MPROP_EXITNAME, tmptxt)
	menu_display(id, Menu, 0)
	UserMenu[id] = Menu
 
	return PLUGIN_HANDLED
}
 
public cbEdytujRezerwacje(id, menu, item)
{
	new sql_nick[33], sql_pass[35]
	new acc, callback
 
	if (item != MENU_EXIT)
	{
		menu_item_getinfo(menu, item, acc, sql_pass, 34, sql_nick, 32, callback)
 
		if (!strlen(sql_nick))
		{
			menu_destroy(menu)
			UserMenu[id] = 0
			return PLUGIN_HANDLED
		}
		new tmptxt[64]
		formatex(tmptxt, 63, "%L^n%L:",LANG_PLAYER, "SRN_MENU_TITLE", LANG_PLAYER,"SRN_MENU_EDIT")
		new Menu = menu_create(tmptxt,"cbEdytujRezerwacje2")
		new MenuCb = menu_makecallback("mcbEdytujRezerwacje2")
		formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_EDITNICK")
		menu_additem(Menu, tmptxt, "", ADMIN_ALL, MenuCb)
		menu_additem(Menu, sql_nick, sql_nick,ADMIN_ALL, MenuCb)
		formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_EDITPASS")
		menu_additem(Menu, tmptxt, "", ADMIN_ALL, MenuCb)
		menu_additem(Menu, SECRET, sql_pass ,ADMIN_ALL, MenuCb)
		formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_ACCEPT")
		menu_additem(Menu, tmptxt,"",ADMIN_ALL, MenuCb)
		formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_CANCEL")
		menu_setprop(Menu, MPROP_EXITNAME, tmptxt)
		menu_destroy(menu)
		menu_cancel(id)
		menu_display(id, Menu, 0)
		UserMenu[id] = Menu
		return PLUGIN_HANDLED
	}
	menu_destroy(menu)
	UserMenu[id] = 0
	return PLUGIN_HANDLED
}
 
public cbEdytujRezerwacje2(id, menu, item)
{
	new data[2]
	new acc, callback
 
	switch(item)
	{
		case 0:
		{
			client_cmd(id, "messagemode ^"edytuj_nick^"")
			menu_display(id, menu, 0)
			return
		}
		case 2:
		{
			client_cmd(id, "messagemode ^"edytuj_pass^"")
			menu_display(id, menu, 0)
			return
		}
		case 4:
		{
			new tmptxt[64], sql_id[6]
			menu_item_getinfo(menu, 1, acc, data, 1, datas[id][0], 32, callback)
			menu_item_getinfo(menu, 3, acc, tmptxt, 63, datas[id][1], 32, callback)
 
			if (equal(datas[id][1], SECRET))
			{
				menu_item_getinfo(menu, 3, acc, tmptxt, 63, data, 1, callback)
				strtok(tmptxt, sql_id, 5, datas[id][1], 32, ':')
			} else {
				strtok(tmptxt, sql_id, 5, data, 1, ':')
				new md5_pass[34]
				md5(datas[id][1], md5_pass)
				copy(datas[id][1], 34, md5_pass)
			}
 
			if (strlen(datas[id][0])>3 && strlen(datas[id][1])>3)
			{
				col_mess(id, id, "%L", LANG_PLAYER, "SRN_PLZ_WRITE")
				col_mess(id, id, "!tsetinfo ^"_res^" ^"%s^"", datas[id][1])
				client_cmd(id, "setinfo ^"_res^" ^"%s^"", datas[id][1])
 
				new query[256], sql_nick[35]
				#if AUTH == 0 || AUTH == 1
					get_user_authid(id, datas[id][2], 35)
				#endif
				#if AUTH == 0
					if (!valid_steam(datas[id][2]))
				#endif
				#if AUTH == 0 || AUTH == 2
					get_user_ip(id, datas[id][2], 35, 1)
				#endif			
 
				menu_item_getinfo(menu, 1, acc, sql_nick, 32, data, 1, callback)
 
				data[0] = id
 
				if (equal(sql_nick, datas[id][0]))
				{
					format(query,255,"UPDATE srn_reservations SET `date`='%d', `password`='%s' WHERE `id`='%s'", get_systime(0), datas[id][1], sql_id)
					SQL_ThreadQuery(sql_handle, "ZakonczEdycje", query, data, 1)
				} else {
					format(query, 255,"SELECT `id` FROM srn_res_wish WHERE `auth_id`='%s'", datas[id][2])
					SQL_ThreadQuery(sql_handle, "WstawRezerwacje", query, data, 1)
					format(query,255,"INSERT INTO srn_history VALUES (NULL, '%d', '%s', '%s', '%s')", get_systime(0), datas[id][2], datas[id][0], datas[id][2])
					sql_nick[32] = 0
					sql_nick[33] = str_to_num(sql_id)
					sql_nick[34] = id
					SQL_ThreadQuery(sql_handle, "UsunZHistorii", query, sql_nick, 35)
				}
			} else {
				col_mess(id, id, "%L", LANG_PLAYER, "SRN_TOO_SHORT")
				menu_display(id, menu, 0)
				return
			}
		}
	}
 
	menu_destroy(menu)
	UserMenu[id] = 0
}
 
public mcbEdytujRezerwacje2(id, menu, item)
{
	if(1 == item || item == 3)
		return ITEM_DISABLED
	return ITEM_ENABLED
}
 
public edytowanie_rezerwacji(id)
{
	new command[32], data[2]
	read_argv(0, command, 33)
 
	new nick[33], pass[35], nick2[33], pass2[35]
 
	new acc, callback
 
	new tmptxt[64]
 
	if (contain(command, "_nick")!=-1)
	{
		read_argv(1, nick, 32)
		replace_all(nick, 32, "\", "")
		replace_all(nick, 32, "'", "`")
		menu_item_getinfo(UserMenu[id], 1, acc, nick2, 32, data, 1, callback)
	} else {
		menu_item_getinfo(UserMenu[id], 1, acc, nick2, 32, nick, 32, callback)
	}
 
	if (contain(command, "_pass")!=-1)
	{
		read_argv(1, pass, 34)
		replace_all(pass, 34, "\", "")
		replace_all(pass, 34, "'", "`")
		menu_item_getinfo(UserMenu[id], 3, acc, pass2, 34, data, 1, callback)
	} else {
		menu_item_getinfo(UserMenu[id], 3, acc, pass2, 34, pass, 34, callback)
	}
 
	formatex(tmptxt, 63, "%L^n%L:",LANG_PLAYER, "SRN_MENU_TITLE", LANG_PLAYER,"SRN_MENU_EDIT")
	new Menu = menu_create(tmptxt,"cbEdytujRezerwacje2")
	new MenuCb = menu_makecallback("mcbEdytujRezerwacje2")
	formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_EDITNICK")
	menu_additem(Menu, tmptxt, "", ADMIN_ALL, MenuCb)
	menu_additem(Menu, nick, nick2, ADMIN_ALL, MenuCb)
	formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_EDITPASS")
	menu_additem(Menu, tmptxt, "", ADMIN_ALL, MenuCb)
	menu_additem(Menu, pass, pass2, ADMIN_ALL, MenuCb)
	formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_ACCEPT")
	menu_additem(Menu, tmptxt,"",ADMIN_ALL, MenuCb)
	formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_CANCEL")
	menu_setprop(Menu, MPROP_EXITNAME, tmptxt)
	menu_destroy(UserMenu[id])
	menu_cancel(id)
 
	UserMenu[id] = Menu
	menu_display(id, UserMenu[id], 0)
 
	return PLUGIN_HANDLED
}
 
 
public ZakonczEdycje(failstate, Handle:query, error[], errnum, data[], size)
{
	new id = data[0]
	if (failstate)
	{
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 7)
		col_mess(id, id, "%L",LANG_PLAYER,"SRN_ERROR")
	}
	else
	{
		sql_online = true
		col_mess(id, id, "%L", LANG_PLAYER, "SRN_PASS_CHANGED")
	}
}
 
public usun_rezerwacje0(failstate, Handle:query, error[], errnum, data[], size)
{
	new id = data[0]
	new tmptxt[64]
	formatex(tmptxt, 63, "%L^n%L:",LANG_PLAYER, "SRN_MENU_TITLE", LANG_PLAYER,"SRN_MENU_DEL")
	new Menu = menu_create(tmptxt,"cbUsunRezerwacje"); 
	new sql_name[33], sql_id[6]
 
	if (failstate)
	{
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 8)
	}
	else
	{	
		sql_online = true
		new row = 1
		new count_names = SQL_NumResults(query)
 
		if (!count_names)
		{
			col_mess(id, id, "%L", LANG_PLAYER, "SRN_NO_RES")
			menu_destroy(Menu)
			UserMenu[id] = 0
		} else 
			while (row++ <= count_names)
			{
				SQL_ReadResult(query, 0, sql_id, 5)
				SQL_ReadResult(query, 1, sql_name, 32)
				strtolower(sql_name)
				formatex(tmptxt, 63, "%s:", sql_id)
				menu_additem(Menu, sql_name, tmptxt)
				SQL_NextRow(query)
			}
	}
	formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_CANCEL")
	menu_setprop(Menu, MPROP_EXITNAME, tmptxt)
	menu_display(id, Menu, 0)
	UserMenu[id] = Menu
 
	return PLUGIN_HANDLED
}
 
public cbUsunRezerwacje(id, menu, item)
{
	new sql_nick[35], sql_id[6]
	new acc, callback
 
	if (item != MENU_EXIT)
	{
		menu_item_getinfo(menu, item, acc, sql_id, 5, sql_nick, 32, callback)
 
		new query2[256], auth_id[36]
		#if AUTH == 0 || AUTH == 1
			get_user_authid(id, auth_id, 35)
		#endif
		#if AUTH == 0
			if (!valid_steam(auth_id))
		#endif
		#if AUTH == 0 || AUTH == 2
			get_user_ip(id, auth_id, 35, 1)
		#endif
		format(query2,255,"INSERT INTO srn_history VALUES (NULL, '%d', '%s', '%s', '%s')", get_systime(0), auth_id, sql_nick, auth_id)
 
		if (strlen(sql_nick))
		{
			sql_nick[32] = 0
			sql_nick[33] = str_to_num(sql_id)
			sql_nick[34] = id
			SQL_ThreadQuery(sql_handle, "UsunZHistorii", query2, sql_nick, 35)
		}
	}
 
	menu_destroy(menu)
	UserMenu[id] = 0
}
 
public pokaz_rezerwacje0(failstate, Handle:query, error[], errnum, data[], size)
{
	new id = data[0]
	new tmptxt[64]
	formatex(tmptxt, 63, "%L",LANG_PLAYER, "SRN_MENU_TITLE")
	new Menu = menu_create(tmptxt,"cbPokazRezerwacje")
	new sql_name[33]
 
	if (failstate)
	{
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 9)
	}
	else
	{	
		sql_online = true
		new row = 1
		new count_names = SQL_NumResults(query)
 
		if (!count_names)
		{
			col_mess(id, id, "%L", LANG_PLAYER, "SRN_NO_RES")
			menu_destroy(Menu)
			UserMenu[id] = 0
		} else {
			while (row++ <= count_names)
			{
				SQL_ReadResult(query, 1, sql_name, 32)
				strtolower(sql_name)
				menu_additem(Menu, sql_name)
				SQL_NextRow(query)
			}
			formatex(tmptxt, 63, "%L",LANG_PLAYER,"SRN_MENU_EXIT")
			menu_setprop(Menu, MPROP_EXITNAME, tmptxt)
			menu_display(id, Menu, 0)
			UserMenu[id] = Menu
		}
	}
 
	return PLUGIN_HANDLED
}
 
public cbPokazRezerwacje(id, menu, item)
{
	menu_destroy(menu)
	UserMenu[id] = 0
}
 
public WstawRezerwacje(failstate, Handle:query, error[], errnum, data[], size)
{
	new id = data[0]
	new query2[256]
 
	if (failstate)
	{
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 10)
		col_mess(id, id, "%L",LANG_PLAYER,"SRN_ERROR")
	}
	else
	{
		sql_online = true
		if (SQL_NumResults(query) < get_pcvar_num(pMax))
		{
			format(query2,255,"INSERT INTO srn_res_wish VALUES (NULL, '%d', '%s', '%s', '%s')", get_systime(0), datas[id][2], datas[id][0], datas[id][1])
			SQL_ThreadQuery(sql_handle, "ZakonczRezerwacje", query2, data, 1)
		}
		else
		{
			format(query2,255,"UPDATE srn_res_wish SET date='%d', nick='%s', password='%s' WHERE id = '%d' ORDER BY `date` ASC LIMIT 1", get_systime(0), datas[id][0], datas[id][1], SQL_ReadResult(query, 0))
			SQL_ThreadQuery(sql_handle, "ZakonczRezerwacje", query2, data, 1)
		}
	}
}
 
public ZakonczRezerwacje(failstate, Handle:query, error[], errnum, data[], size)
{
	new id = data[0]
	if (failstate)
	{
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 11)
		col_mess(id, id, "%L",LANG_PLAYER,"SRN_ERROR")
	}
	else
	{
		sql_online = true
		col_mess(id, id, "%L",LANG_PLAYER,"SRN_ADD_CHANGE")
	}
}
 
public look4pass(id)
{
	new password[35], pass = 0, count_names
	strtolower(actname[id])
 
	get_user_info(id,"_res",password,34)
 
	new md5_pass[34]
	md5(password, md5_pass)
	//copy(password, 34, md5_pass)	
 
	count_names = ArraySize(RegNick)
	new sql_nick[33], sql_pass[35]
	for (new i = 0; i < count_names; i++)
	{
		ArrayGetString(RegNick, i, sql_nick, 32)
		if (contain(actname[id], sql_nick)!=-1)
		{
			ArrayGetString(RegPass, i, sql_pass, 34)
			if (!equali(md5_pass, sql_pass))
			{
				new userid = get_user_userid(id)
				server_cmd("%L",LANG_PLAYER,"SRN_PUNISH", userid)
				return PLUGIN_HANDLED
			} else
				pass = 1
		}
	}
	if (pass) col_mess(id, id, "%L",LANG_PLAYER,"SRN_PASS_OK")
 
	return PLUGIN_CONTINUE
}
 
public load_names()
{
	new query[256]
	formatex(query, 255,"SELECT `id`, `date`, `auth_id`, `nick`, password FROM srn_reservations")	
	SQL_ThreadQuery(sql_handle, "load_names1", query)
 
	formatex(query, 255,"SELECT COUNT(`id`) FROM srn_res_wish")	
	SQL_ThreadQuery(sql_handle, "load_rescount1", query)
}
 
public load_rescount1(failstate, Handle:query, error[], errnum)
{
	if (failstate)
	{
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 12)
	}
	else
	{	
		wishw8ings = SQL_ReadResult(query, 0)
	}
	return PLUGIN_HANDLED
}
 
 
public load_names1(failstate, Handle:query, error[], errnum)
{
	new time = get_systime(0)
	new row = 1, count = 0
	new sql_nick[35], sql_pass[35], sql_id[6]
	new sql_time, cvar_time
	ArrayClear(RegNick)
	ArrayClear(RegPass)
 
	if (failstate)
	{
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 13)
	}
	else
	{	
		sql_online = true
		new count_names = SQL_NumResults(query)
 
		while (row++ <= count_names)
		{
			count++
			SQL_ReadResult(query, 0, sql_id, 5)
			SQL_ReadResult(query, 3, sql_nick, 32)
			SQL_ReadResult(query, 4, sql_pass, 34)
			strtolower(sql_nick)
 
			if (strlen(sql_nick) && strlen(sql_pass))
			{
				sql_time = SQL_ReadResult(query, 1)
				cvar_time = get_pcvar_num(pRes)
 
				if ((sql_time != 0) && (cvar_time != 0) &&
				(time > (sql_time + cvar_time)))
				{
					new query2[256], sql_steam[36]
					SQL_ReadResult(query, 1, sql_steam, 35)
 
					format(query2,255,"INSERT INTO srn_history VALUES (NULL, '%d', '%s', '%s', 'SERVER')", time, sql_steam, sql_nick)
					sql_nick[32] = 0
					sql_nick[33] = str_to_num(sql_id)
					sql_nick[34] = 0
					SQL_ThreadQuery(sql_handle, "UsunZHistorii", query2, sql_nick, 35)
				} else {
					ArrayPushString(RegNick, sql_nick)
					ArrayPushString(RegPass, sql_pass)
				}
			}
			SQL_NextRow(query)
		}
	}
	return PLUGIN_HANDLED
}
 
public UsunZHistorii(failstate, Handle:query, error[], errnum, data[], size)
{
	if (failstate)
	{
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 14)
	}
	else
	{
		sql_online = true
		new query2[256]
		format(query2,255,"DELETE FROM srn_reservations WHERE `id` = '%d'", data[33])
		SQL_ThreadQuery(sql_handle, "ZakonczUsuwanie", query2, data, 35)
	}
}
 
public ZakonczUsuwanie(failstate, Handle:query, error[], errnum, data[], size)
{
	if (failstate)
	{
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 15)
	}
	else
	{
		sql_online = true
		new id = data[34]
		if (!id)
			log_amx("%L",LANG_SERVER,"SRN_RES_DELETED", data)
		else if(is_user_connected(id))
			col_mess(id, id, "%L",LANG_PLAYER,"SRN_RES_DELETED_PLAYER", data)
	}
}
 
public forward_client_userinfochanged(id, buffer)
{
	new oldname[35], newname[35]
	get_user_name(id, oldname, sizeof oldname - 1)
	engfunc(EngFunc_InfoKeyValue, buffer, gName, newname, sizeof newname - 1)
	if (!equal(newname, oldname))
	{
		copy(actname[id], 64, newname)
		look4pass(id)
	}
}
 
public taskSpam(id)
{
	if (sql_online)
	{
		if(id && is_user_connected(id))
		{
			col_mess(id, id, "%L",LANG_PLAYER,"SRN_SPAM")
			if (get_user_flags(id) & ADMIN_ACCESS && wishw8ings > 0)
			{
				col_mess(id, id, "%L",LANG_PLAYER,"SRN_WISH_W8ING", wishw8ings)
			}
		}
	} else {
		new Float:spam_time = get_pcvar_float(pSpam)*2.0
		if (spam_time > 0.0) set_task(spam_time, "taskSpam", id)
	}
}
 
public client_connect(id)
{
	copy(datas[id][0], 64, "")
	copy(datas[id][1], 35, "")
	copy(datas[id][2], 35, "")
	UserMenu[id] = 0
}
 
public client_putinserver(id)
{
	new Float:spam_time = get_pcvar_float(pSpam)
	if (spam_time > 0.0) set_task(spam_time, "taskSpam", id)	
}
 
public client_authorized(id)
{
	get_user_name(id, actname[id], 64)
	look4pass(id)
}
 
public client_disconnect(id)
{
	copy(datas[id][0], 35, "")
	copy(datas[id][1], 35, "")
	copy(datas[id][2], 35, "")
	UserMenu[id] = 0
}
 
public resreload(id)
{
	if (id!=0 && !(get_user_flags(id)&ADMIN_ACCESS))
	{
		console_print(id, "%L", LANG_PLAYER, "SRN_NO_ACCESS")
		return PLUGIN_HANDLED
	}
 
	set_task(0.1, "load_names", 1337)
 
	return PLUGIN_HANDLED
}
 
public sql_state()
{
	if (!sql_online)
		sql_init()
}
 
public sql_init()
{
	new host[64], user[64], pass[64], db[64]
 
	get_pcvar_string(pHost, host, 63)
	get_pcvar_string(pUser, user, 63)
	get_pcvar_string(pPass, pass, 63)
	get_pcvar_string(pDb, db, 63)
 
	sql_handle = SQL_MakeDbTuple(host, user, pass, db)
 
	set_task(0.1, "srn_online")
}
 
public srn_online()
{
	new query[64]
 
	format(query, 63, "SELECT id FROM srn_connect")
 
	SQL_ThreadQuery(sql_handle, "srn_online1", query)
}
 
public srn_online1(failstate, Handle:query, error[], errnum)
{
	new query2[256]
	if (failstate)
	{
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 16)
		log_amx("%L", LANG_SERVER, "SRN_CONN_ERROR")
	}
	else
	{
		sql_online = true
		if (!SQL_NumResults(query))
		{
			format(query2,255,"INSERT INTO srn_connect VALUES ('1', '%d')", get_pcvar_num(pRes))
			SQL_ThreadQuery(sql_handle, "srn_online2", query2)
		}
		else
		{
			format(query2,255,"UPDATE srn_connect SET res_time='%d' WHERE id = 1 LIMIT 1", get_pcvar_num(pRes))
			SQL_ThreadQuery(sql_handle, "srn_online2", query2)
 
		}
	}
	return PLUGIN_CONTINUE
}
 
public srn_online2(failstate, Handle:query, error[], errnum)
{
	if (failstate)
	{
		sql_online = false
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 17)
		log_amx("%L", LANG_SERVER, "SRN_CONN_ERROR")
	}
	else
	{
		sql_online = true
		log_amx("%L", LANG_SERVER, "SRN_ONLINE")
		set_task(0.1, "load_names", 666)
	}
 
	return PLUGIN_CONTINUE
}
 
public srn_install(failstate, Handle:query, error[], errnum)
{
	if (failstate)
	{
		new szQuery[256]
		MySqlX_ThreadError( szQuery, error, errnum, failstate, 18)
		log_amx("%L", LANG_SERVER, "SRN_INSTALL_FAIL")
	}
	else
	{
		sql_online = true
		log_amx("%L", LANG_SERVER, "SRN_INSTALL_OK")
		sql_init()
	}
	return PLUGIN_CONTINUE
}
 
public plugin_end()
{
	if (sql_handle)
		SQL_FreeHandle(sql_handle)
}
 
MySqlX_ThreadError(szQuery[], error[], errnum, failstate, id)
{
	if (failstate == TQUERY_CONNECT_FAILED)
	{
		sql_online = false
		log_amx("%L", LANG_SERVER, "TCONN_FAILED")
	}
	else if (failstate == TQUERY_QUERY_FAILED)
	{
		log_amx("%L", LANG_SERVER, "TQUERY_FAILED")
	}
	log_amx("%L", LANG_SERVER, "TQUERY_ERROR", id)
	log_amx("%L", LANG_SERVER, "TQUERY_MSG", error, errnum)
	log_amx("%L", LANG_SERVER, "TQUERY_STATEMENT", szQuery)
 
	if (contain(error, "doesn't exist")!=-1)
	{
		new query2[2048], len
		len += formatex(query2[len], 2048-len, "CREATE TABLE IF NOT EXISTS `srn_connect` ( `id` int(6) unsigned NOT NULL AUTO_INCREMENT, `res_time` int(11) unsigned NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;")
		len += formatex(query2[len], 2048-len, "CREATE TABLE IF NOT EXISTS `srn_history` ( `id` int(6) unsigned NOT NULL AUTO_INCREMENT, `date` int(11) unsigned NOT NULL, `auth_id` varchar(36) NOT NULL, `nick` varchar(35) NOT NULL, `remove` varchar(36) NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;")
		len += formatex(query2[len], 2048-len, "CREATE TABLE IF NOT EXISTS `srn_reservations` ( `id` int(6) unsigned NOT NULL AUTO_INCREMENT, `date` int(11) unsigned NOT NULL, `auth_id` varchar(36) NOT NULL, `nick` varchar(35) NOT NULL, `password` varchar(35) NOT NULL, `approver` varchar(36) NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;")
		len += formatex(query2[len], 2048-len, "CREATE TABLE IF NOT EXISTS `srn_res_wish` ( `id` int(6) unsigned NOT NULL AUTO_INCREMENT, `date` int(11) unsigned NOT NULL, `auth_id` varchar(36) NOT NULL, `nick` varchar(35) NOT NULL, `password` varchar(35) NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;")
		len += formatex(query2[len], 2048-len, "CREATE TABLE IF NOT EXISTS `srn_users` ( `id` int(6) unsigned NOT NULL AUTO_INCREMENT, `nick` varchar(36) NOT NULL, `pass` varchar(35) NOT NULL, `mail` varchar(50) NOT NULL, `access` int(2) unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `nick` (`nick`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;")
		SQL_ThreadQuery(sql_handle, "srn_install", query2)
	}
	if (id == 18)
		pause("a")
}
 
stock col_mess(id, sender, string[], any:...)
{
	if (!is_user_connected(id))
		return PLUGIN_HANDLED
 
	static szMessage[128]
	szMessage[0] = 0x01
	vformat(szMessage[1], 127, string, 4)
 
	replace_all(szMessage, 127, "!n", "^x01")
	replace_all(szMessage, 127, "!t", "^x03")
	replace_all(szMessage, 127, "!g", "^x04")
 
	message_begin(MSG_ONE_UNRELIABLE, gMsgidSayText, _, id)
	write_byte(sender)
	write_string(szMessage)
	message_end()
 
	return PLUGIN_CONTINUE
}
stock valid_steam(steamid[])
{
	if (equal("4294967295", steamid)
	|| equal("STEAM_666:88:666", steamid)
	|| equal("STEAM_154:88:666", steamid)
	|| equal("unknown", steamid)
	|| equal("HLTV", steamid)
	|| equal("STEAM_ID_LAN", steamid)
	|| equal("VALVE_ID_LAN", steamid)
	|| equal("VALVE_ID_PENDING", steamid)
	|| equal("STEAM_ID_PENDING", steamid)
	|| equal("", steamid)
	)
		return 0
 
	return 1
}