HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*
  2.   Fordította: BBk
  3. */
  4.  
  5. #include <amxmodx>
  6. #include <amxmisc>
  7. #include <regex>
  8.  
  9. #define IP_PATTERN "((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
  10. #define STEAMID_PATTERN "STEAM_0:[01]:\d+"
  11. #define TIME_PATTERN "([0|1]\d|2[0-3])(:([0-5]\d)){2}\s+(0[1-9]|[1|2][0-9]|3[0|1])\/(0[1-9]|1[0-2])\/(\d{4})"
  12.  
  13. #define IsValidIP(%1) (regex_match_c(%1,ip_pattern,ret)>0)
  14. #define IsValidAUTHID(%1) (regex_match_c(%1,steamid_pattern,ret)>0)
  15. #define IsValidTIME(%1) (regex_match_c(%1,time_pattern,ret)>0)
  16.  
  17. enum _:BanInfo
  18. {
  19. bantype[8],
  20. target_authid[32],
  21. target_ip[16],
  22. target_name[64],
  23. bantime[32],
  24. unbantime[32],
  25. banner_authid[32],
  26. banner_ip[32],
  27. banner_name[64],
  28. reason[128]
  29. };
  30.  
  31. new bool:MODE_ADDBAN,bool:MODE_QUERY_CONTINUE,bool:MODE_LOADBAN,bool:MODE_UNBAN;
  32. new cvar_Flags,msgid,cvar_Contact,cvar_CheckInterval,cvar_vote_enable,cvar_vote_ratio,cvar_vote_delay,cvar_vote_time,cvar_vote_min,total,ids,TotalBans,Float:LastAuth;
  33. new ub_banlistfile[256],Flags[26],player[32],LastQuery[33][64],LastQueryType[33][8],bool:handle_unban_menu_call[33],bool:handle_ban_menu_call[33];
  34. new QueryPointer[33],QueryCount[33],auth_delay[33],STR_Menu_Ban_Duration[33][128],Float:Menu_Ban_Duration[33],Float:LastBanTime,Menu_Ban_Target[33];
  35. new Menu_Ban_Players[33][32],Menu_Ban_Total[33],Menu_Ban_BanType[33],Menu_Ban_pos[33],Menu_Unban_pos[33],Float:Menu_Unban_Time[33],Votes_Players[33][33],Float:LastVoted[33];
  36. new Regex:steamid_pattern,Regex:ip_pattern,Regex:time_pattern,ret,error[2];
  37. new Array:banlist_array;
  38.  
  39. public plugin_init()
  40. {
  41. register_plugin("Ultimate Bans","1.9","Souvik");
  42. register_cvar("ultimatebans_version","1.9",FCVAR_SERVER);
  43.  
  44. register_clcmd( "amx_banmenu", "CmdBANMENU", ADMIN_BAN, "(Ban Menu mutatasa)");
  45. register_clcmd( "amx_unbanmenu","CmdUNBANMENU", ADMIN_BAN, "(Unban Menu mutatasa)");
  46.  
  47. register_concmd("amx_ban", "CmdBAN", ADMIN_BAN, "<nev, #userid, authid, ip> <perc> [ok] <bantipus>");
  48. register_concmd("amx_addban", "CmdADDBAN", ADMIN_BAN, "<nev, authid, ip> <perc> [ok] <bantipus>");
  49. register_concmd("amx_unban", "CmdUNBAN", ADMIN_BAN, "<nev, authid, ip> <bantipus>");
  50. register_concmd("amx_queryban", "CmdQUERY", ADMIN_BAN, "<nev, authid, ip> <bantipus>");
  51. register_concmd("amx_querynext","CmdQUERYNEXT", ADMIN_BAN, "(QueryBan Eredmenyek Kovetkezo Oldalanak mutatasa)");
  52. register_concmd("amx_queryback","CmdQUERYBACK", ADMIN_BAN, "(QueryBan Eredmenyek Elozo Oldalanak mutatasa)");
  53. register_concmd("amx_banlist", "CmdBANLIST", ADMIN_BAN, "(Bannolt Jatekosok Lista mutatasa)");
  54.  
  55. register_srvcmd("amx_ban", "CmdBAN", -1, "<nev, #userid, authid, ip> <perc> [ok] <bantipus>");
  56. register_srvcmd("amx_addban", "CmdADDBAN", -1, "<nev, authid, ip> <perc> [ok] <bantipus>");
  57. register_srvcmd("amx_unban", "CmdUNBAN", -1, "<nev, authid, ip> <bantipus>");
  58. register_srvcmd("amx_queryban", "CmdQUERY", -1, "<nev, authid, ip> <bantipus>");
  59. register_srvcmd("amx_querynext","CmdQUERYNEXT", -1, "(QueryBan Eredmenyek Kovetkezo Oldalanak mutatasa)");
  60. register_srvcmd("amx_queryback","CmdQUERYBACK", -1, "(QueryBan Eredmenyek Elozo Oldalanak mutatasa)");
  61. register_srvcmd("amx_banlist", "CmdBANLIST", -1, "(Bannolt Jatekosok Lista mutatasa)");
  62. register_srvcmd("amx_reloadbans","CmdRELOAD", -1, "(Bannok Ujratoltese a Szerver ujrainditasa nelkul)");
  63. register_srvcmd("amx_resetbans","CmdRESET", -1, "(Bannok Visszaallitasa - Banlista torlese)");
  64.  
  65. steamid_pattern = regex_compile(STEAMID_PATTERN,ret,error,charsmax(error));
  66. ip_pattern = regex_compile(IP_PATTERN,ret,error,charsmax(error));
  67. time_pattern = regex_compile(TIME_PATTERN,ret,error,charsmax(error));
  68. cvar_CheckInterval = register_cvar("ub_checkinterval","60.0");
  69. cvar_Contact = register_cvar("ub_contact","N/A");
  70. cvar_Flags = register_cvar("ub_flags","a");
  71. cvar_vote_enable = register_cvar("ub_vote_enable","1");
  72. cvar_vote_ratio = register_cvar("ub_vote_ratio","0.40");
  73. cvar_vote_delay = register_cvar("ub_vote_delay","5.0");
  74. cvar_vote_time = register_cvar("ub_vote_time","60.0");
  75. cvar_vote_min = register_cvar("ub_vote_min","5");
  76. msgid = get_user_msgid("SayText");
  77. banlist_array = ArrayCreate(BanInfo);
  78.  
  79. register_menucmd(register_menuid("Ban Menu"),1023,"Menu_Ban_Keys");
  80. register_menucmd(register_menuid("Unban Menu"),1023,"Menu_Unban_Keys");
  81. register_menucmd(register_menuid("Voteban Menu"),1023,"Menu_Vote_Keys")
  82. register_clcmd("UB_SetDuration","Menu_SetDuration",ADMIN_BAN,"<ido> percben");
  83. register_clcmd("UB_SetReason","Menu_SetReason",ADMIN_BAN,"<ok>");
  84. register_clcmd("say /voteban","CmdVOTEMENU");
  85. register_clcmd("say_team /voteban","CmdVOTEMENU");
  86.  
  87. get_datadir(ub_banlistfile,charsmax(ub_banlistfile));
  88. add(ub_banlistfile,charsmax(ub_banlistfile),"/UB_Banlist.txt");
  89. if (!file_exists(ub_banlistfile))
  90. {
  91. server_print("[UltimateBans] A Banlista Fajl Elvesz. Fajl Letrehozas - %s",ub_banlistfile);
  92. new file = fopen(ub_banlistfile,"wt");fclose(file);
  93. CheckTimeUP();
  94. }
  95. else
  96. CmdLOAD();
  97. }
  98.  
  99. public client_connect(id)
  100. {
  101. for (new i=0;i<64;i++)
  102. LastQuery[id][i] = 0;
  103. for (new i=0;i<8;i++)
  104. LastQueryType[id][i] = 0;
  105. QueryPointer[id] = 1;
  106. Menu_Ban_Reset(id);
  107. Menu_Unban_pos[id] = 0;
  108. LastVoted[id] = 0.0;
  109. }
  110.  
  111. public client_disconnect(id)
  112. {
  113. auth_delay[id] = false;
  114. new ids;
  115. get_players(player,total);
  116. for(new i=0;i<total;i++)
  117. {
  118. ids = player[i];
  119. if (Votes_Players[id][ids])
  120. Votes_Players[id][ids] = 0;
  121. }
  122. }
  123.  
  124. public client_authorized(id)
  125. {
  126. static Float:handle_delay;
  127. if (MODE_LOADBAN)
  128. auth_delay[id] = true;
  129. else
  130. {
  131. if (get_gametime()<LastAuth+1.0)
  132. {
  133. handle_delay += 1.0;
  134. set_task(handle_delay,"OnConnect",id);
  135. }
  136. else
  137. {
  138. OnConnect(id);
  139. if (handle_delay>=2.0)
  140. handle_delay -= 2.0;
  141. else
  142. handle_delay = 0.0;
  143. }
  144. LastAuth = get_gametime();
  145. }
  146. }
  147.  
  148. public OnConnect(id)
  149. {
  150. static AuthID[32],IP[16],Name[64],Timeleft[64],DATA[BanInfo],func_buffer[256],Pos;
  151. get_user_authid(id,AuthID,charsmax(AuthID));
  152. get_user_ip(id,IP,charsmax(IP),1);
  153. get_user_name(id,Name,charsmax(Name));
  154. if (equali(Name,"<null>",6))
  155. server_cmd("kick #%d ^"Ervenytelen Nev^"",get_user_userid(id));
  156. Pos = CheckBan(AuthID,"STEAMID");
  157. if (Pos==-2)
  158. {
  159. Pos = CheckBan(IP,"IP");
  160. if (Pos==-2)
  161. {
  162. Pos = CheckBan(Name,"NAME");
  163. if (Pos==-2)
  164. return PLUGIN_CONTINUE
  165. }
  166. }
  167. if (Pos==-1)
  168. {
  169. server_cmd("kick #%d ^"Ki lettel TILTVA errol a szerverrol^"",get_user_userid(id));
  170. return PLUGIN_HANDLED
  171. }
  172. else
  173. {
  174. ArrayGetArray(banlist_array,Pos,DATA);
  175. static Hostname[64];
  176. get_user_name(0,Hostname,charsmax(Hostname));
  177. client_cmd(id,"echo [UltimateBans] -------------------------------");
  178. client_cmd(id,"echo [UltimateBans] --==|| BAN INFO ||==--");
  179. client_cmd(id,"echo [UltimateBans] -------------------------------");
  180. client_cmd(id,"echo [UltimateBans] Server - %s",Hostname);
  181. if (equali(DATA[unbantime],"<null>",6))
  182. {
  183. PrintBanInfo(DATA,id);
  184. set_task(0.5,"JoinKick",id,"<null>",6);
  185. return PLUGIN_HANDLED
  186. }
  187. if (get_ban_timeleft(DATA[unbantime],Timeleft,charsmax(Timeleft)))
  188. {
  189. PrintBanInfo(DATA,id,Timeleft);
  190. set_task(0.5,"JoinKick",id,Timeleft,charsmax(Timeleft));
  191. }
  192. else
  193. {
  194. if (!equali(DATA[target_name],"<null>",6))
  195. formatex(func_buffer,charsmax(func_buffer),"^x01[UltimateBans]^x04 Kitiltasi Ido/Elapsed for^x03 %s",DATA[target_name]);
  196. else
  197. {
  198. if ((equali(DATA[bantype],"STEAMID",7))&&(!equali(DATA[target_authid],"<null>",6)))
  199. formatex(func_buffer,charsmax(func_buffer),"^x01[UltimateBans]^x04 Kitiltasi Ido/Elapsed for^x03 %s",DATA[target_authid]);
  200. else
  201. formatex(func_buffer,charsmax(func_buffer),"^x01[UltimateBans]^x04 Kitiltasi Ido/Elapsed for^x03 %s",DATA[target_ip]);
  202. }
  203. ChatPrint(func_buffer);
  204. log_to_file("addons/amxmodx/logs/UB_Logs.log","<UNBAN> Kitiltasi Ido/Elapsed for < AuthID:^"%s^" , IP:^"%s^" , Nev:^"%s^" , BanTipus:^"%s^" >",DATA[target_authid],DATA[target_ip],DATA[target_name],DATA[bantype]);
  205. ArrayDeleteItem(banlist_array,Pos);
  206. TotalBans--;
  207. new file = fopen(ub_banlistfile,"wt");
  208. for(new i=0;i<TotalBans;i++)
  209. {
  210. ArrayGetArray(banlist_array,i,DATA);
  211. fprintf(file,"^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^"^n",DATA[bantype],DATA[target_authid],DATA[target_ip],DATA[target_name],DATA[bantime],DATA[unbantime],DATA[banner_authid],DATA[banner_ip],DATA[banner_name],DATA[reason]);
  212. }
  213. fclose(file);
  214. }
  215. return PLUGIN_HANDLED
  216. }
  217. return PLUGIN_HANDLED
  218. }
  219.  
  220. public client_infochanged(id)
  221. {
  222. static oldName[64],newName[64];
  223. get_user_name(id,oldName,charsmax(oldName));
  224. get_user_info(id,"NAME",newName,charsmax(newName));
  225. if (!equal(oldName,newName))
  226. {
  227. if ((equali(newName,"<null>",6))||(CheckBan(newName,"NAME")!=-2))
  228. {
  229. set_user_info(id,"NAME",oldName);
  230. client_print(id,print_chat,"[UltimateBans] Ervenytelen Nev");
  231. }
  232. }
  233. }
  234.  
  235. public CmdBAN(id,level,cid)
  236. {
  237. if (!cmd_access(id,level,cid,2,false))
  238. return PLUGIN_HANDLED
  239. // ------==|| Input Data Handling ||==------
  240. new ARG_Target[64],ARG_Duration[32],ARG_BanType[8],ARG_Reason[128]
  241. static ARG_Count,ARG_STR[256],len;
  242. copy(ARG_Reason,charsmax(ARG_Reason),"<null>");
  243. ARG_Count = 0;
  244. read_args(ARG_STR,charsmax(ARG_STR));
  245. trim(ARG_STR);
  246. parse(ARG_STR,ARG_Target,charsmax(ARG_Target),ARG_Duration,charsmax(ARG_Duration),ARG_Reason,charsmax(ARG_Reason),ARG_BanType,charsmax(ARG_BanType));
  247. if (strlen(ARG_Target))
  248. {
  249. ARG_Count=1;
  250. trim(ARG_Target);
  251. if (equali(ARG_Target,"<null>",6))
  252. {
  253. bad_input(id);
  254. MODE_ADDBAN = false;
  255. return PLUGIN_HANDLED
  256. }
  257. if (strlen(ARG_Duration))
  258. {
  259. ARG_Count=2;
  260. trim(ARG_Duration);
  261. if (strlen(ARG_Reason))
  262. {
  263. ARG_Count=3;
  264. trim(ARG_Reason);
  265. if (strlen(ARG_BanType))
  266. {
  267. ARG_Count=4;
  268. trim(ARG_BanType);
  269. }
  270. }
  271. else
  272. copy(ARG_Reason,charsmax(ARG_Reason),"<null>")
  273. }
  274. }
  275. if (ARG_Count<2)
  276. {
  277. if (id)
  278. client_cmd(id,"echo [UltimateBans] Nem megfelelo Adat/Argumentumok");
  279. else
  280. server_print("[UltimateBans] Nem megfelelo Adat/Argumentumok");
  281. MODE_ADDBAN = false
  282. return PLUGIN_HANDLED
  283. }
  284. // ------==|| Input Type Handling ||==------
  285. static tmpid,NUM_Target_Type,NUM_BanType;
  286. if ((ARG_STR[0]=='#')&&(!MODE_ADDBAN))
  287. {
  288. tmpid = str_to_num(ARG_Target[1]);
  289. NUM_Target_Type = 1;
  290. }
  291. else if (IsValidAUTHID(ARG_Target))
  292. NUM_Target_Type = 2;
  293. else if (IsValidIP(ARG_Target))
  294. NUM_Target_Type = 3;
  295. else
  296. NUM_Target_Type = 4;
  297. if (ARG_Count==4)
  298. {
  299. if (equali(ARG_BanType,"AUTO",4))
  300. NUM_BanType = 1;
  301. else if (equali(ARG_BanType,"STEAMID",7))
  302. {
  303. copy(ARG_BanType,charsmax(ARG_BanType),"STEAMID");
  304. NUM_BanType = 2;
  305. }
  306. else if (equali(ARG_BanType,"IP",2))
  307. {
  308. copy(ARG_BanType,charsmax(ARG_BanType),"IP");
  309. NUM_BanType = 3;
  310. }
  311. else if (equali(ARG_BanType,"NAME",4))
  312. {
  313. copy(ARG_BanType,charsmax(ARG_BanType),"NAME");
  314. NUM_BanType = 4;
  315. }
  316. else
  317. {
  318. bad_input(id);
  319. MODE_ADDBAN = false
  320. return PLUGIN_HANDLED
  321. }
  322. }
  323. else
  324. NUM_BanType = 1;
  325. // ------==|| Target ||==------
  326. static Target[33],ARG_TempTarget[64],Found,bool:MODE_RANGEBAN;
  327. MODE_RANGEBAN = false;
  328. Found = 0;
  329. get_players(player,total);
  330. if (!MODE_ADDBAN)
  331. {
  332. switch (NUM_Target_Type)
  333. {
  334. case 1:
  335. {
  336. for (new i=0;i<total;i++)
  337. {
  338. ids = player[i];
  339. if (get_user_userid(ids)!=tmpid)
  340. continue;
  341. Found = 1;
  342. get_user_authid(ids,ARG_TempTarget,charsmax(ARG_TempTarget));
  343. switch (NUM_BanType)
  344. {
  345. case 1:
  346. {
  347. if (IsValidAUTHID(ARG_TempTarget))
  348. {
  349. copy(ARG_BanType,charsmax(ARG_BanType),"STEAMID");
  350. NUM_BanType = 2;
  351. }
  352. else
  353. {
  354. get_user_ip(ids,ARG_TempTarget,charsmax(ARG_TempTarget),1);
  355. copy(ARG_BanType,charsmax(ARG_BanType),"IP");
  356. NUM_BanType = 3;
  357. }
  358. }
  359. case 2:
  360. {
  361. if (IsValidAUTHID(ARG_TempTarget))
  362. continue;
  363. if (id)
  364. client_cmd(id,"echo [UltimateBans] Az AuthID Nem Valos!!");
  365. else
  366. server_print("[UltimateBans] Az AuthID Nem Valos!!");
  367. return PLUGIN_HANDLED
  368. }
  369. }
  370. Target[0] = ids;
  371. break;
  372. }
  373. }
  374. case 2:
  375. {
  376. for (new i=0;i<total;i++)
  377. {
  378. ids = player[i]
  379. get_user_authid(ids,ARG_TempTarget,charsmax(ARG_TempTarget))
  380. if (equali(ARG_TempTarget,ARG_Target))
  381. Target[Found++] = ids;
  382. }
  383. if ((Found)&&(NUM_BanType==1))
  384. {
  385. copy(ARG_BanType,charsmax(ARG_BanType),"STEAMID");
  386. NUM_BanType = 2;
  387. }
  388. }
  389. case 3:
  390. {
  391. for (new i=0;i<total;i++)
  392. {
  393. ids = player[i]
  394. get_user_ip(ids,ARG_TempTarget,charsmax(ARG_TempTarget),1)
  395. new temp = CheckIP(ARG_Target,ARG_TempTarget);
  396. if (temp)
  397. {
  398. if (temp==2)
  399. MODE_RANGEBAN = true;
  400. Target[Found++] = ids;
  401. }
  402. }
  403. if ((Found)&&(NUM_BanType==1))
  404. {
  405. copy(ARG_BanType,charsmax(ARG_BanType),"IP");
  406. NUM_BanType = 3;
  407. }
  408. }
  409. }
  410. if (!Found)
  411. {
  412. for (new i=0;i<total;i++)
  413. {
  414. ids = player[i]
  415. get_user_name(ids,ARG_TempTarget,charsmax(ARG_TempTarget));
  416. if (equali(ARG_Target,ARG_TempTarget,strlen(ARG_Target)))
  417. Target[Found++] = ids;
  418. }
  419. if (Found)
  420. {
  421. if (Found>1)
  422. {
  423. if (NUM_BanType!=4)
  424. {
  425. if (id)
  426. client_cmd(id,"echo [UltimateBans] %i Jatekos Talalhato Hasonlo Nevvel . . . Nem lehet Bannolni!!",Found);
  427. else
  428. server_print("[UltimateBans] %i Jatekos Talalhato Hasonlo Nevvel . . . Nem lehet Bannolni!!",Found);
  429. return PLUGIN_HANDLED
  430. }
  431. }
  432. else
  433. {
  434. get_user_authid(Target[0],ARG_TempTarget,charsmax(ARG_TempTarget))
  435. switch (NUM_BanType)
  436. {
  437. case 1:
  438. {
  439. if (IsValidAUTHID(ARG_TempTarget))
  440. {
  441. copy(ARG_BanType,charsmax(ARG_BanType),"STEAMID");
  442. NUM_BanType = 2;
  443. }
  444. else
  445. {
  446. get_user_ip(ids,ARG_TempTarget,charsmax(ARG_TempTarget),1);
  447. copy(ARG_BanType,charsmax(ARG_BanType),"IP");
  448. NUM_BanType = 3;
  449. }
  450. }
  451. case 2:
  452. {
  453. if (!IsValidAUTHID(ARG_TempTarget))
  454. {
  455. if (id)
  456. client_cmd(id,"echo [UltimateBans] Az AuthID Nem Valos!!");
  457. else
  458. server_print("[UltimateBans] Az AuthID Nem Valos!!");
  459. return PLUGIN_HANDLED
  460. }
  461. }
  462. }
  463. }
  464. }
  465. else
  466. {
  467. if (id)
  468. client_cmd(id,"echo [UltimateBans] A Celpont Nem Talalhato!!");
  469. else
  470. server_print("[UltimateBans] A Celpont Nem Talalhato!!");
  471. return PLUGIN_HANDLED
  472. }
  473. }
  474. }
  475. else
  476. {
  477. if (((NUM_Target_Type!=2)&&(NUM_BanType==2))||((NUM_Target_Type!=3)&&(NUM_BanType==3)))
  478. {
  479. if (id)
  480. client_cmd(id,"echo [UltimateBans] A BanTipus nem egyezik a CelTipussal");
  481. else
  482. server_print("[UltimateBans] A BanTipus nem egyezik a CelTipussal");
  483. MODE_ADDBAN = false
  484. return PLUGIN_HANDLED
  485. }
  486. if (NUM_BanType==1)
  487. {
  488. switch (NUM_Target_Type)
  489. {
  490. case 2: {copy(ARG_BanType,charsmax(ARG_BanType),"STEAMID");NUM_BanType=2;}
  491. case 3: {copy(ARG_BanType,charsmax(ARG_BanType),"IP");NUM_BanType=3;}
  492. case 4: {copy(ARG_BanType,charsmax(ARG_BanType),"NAME");NUM_BanType=4;}
  493. }
  494. }
  495. if (CheckBan(ARG_Target,ARG_BanType)!=-2)
  496. {
  497. if (id)
  498. client_cmd(id,"echo [UltimateBans] A Jatekos Mar Bannolva Van");
  499. else
  500. server_print("[UltimateBans] A Jatekos Mar Bannolva Van");
  501. MODE_ADDBAN = false
  502. return PLUGIN_HANDLED
  503. }
  504. for (new i=0;i<total;i++)
  505. {
  506. ids = player[i];
  507. switch (NUM_BanType)
  508. {
  509. case 2:
  510. {
  511. get_user_authid(ids,ARG_TempTarget,charsmax(ARG_TempTarget));
  512. if (equali(ARG_TempTarget,ARG_Target))
  513. Target[Found++] = ids;
  514. }
  515. case 3:
  516. {
  517. get_user_ip(ids,ARG_TempTarget,charsmax(ARG_TempTarget),1);
  518. new temp = CheckIP(ARG_Target,ARG_TempTarget);
  519. if (temp)
  520. {
  521. if (temp==2)
  522. MODE_RANGEBAN = true;
  523. Target[Found++] = ids;
  524. }
  525. }
  526. case 4:
  527. {
  528. get_user_name(ids,ARG_TempTarget,charsmax(ARG_TempTarget));
  529. if (equali(ARG_Target,ARG_TempTarget,strlen(ARG_Target)))
  530. Target[Found++] = ids;
  531. }
  532. }
  533. }
  534. if (Found)
  535. {
  536. if (id)
  537. client_cmd(id,"echo [UltimateBans] %s Csatlakozott/Csatlakoztak a Szerverre.",(Found==1)?"A Celpont":"A Celpontok");
  538. else
  539. server_print("[UltimateBans] %s Csatlakozott/Csatlakoztak a Szerverre.",(Found==1)?"A Celpont":"A Celpontok");
  540. MODE_ADDBAN = false;
  541. }
  542. else
  543. Found = 1;
  544. }
  545. if (!MODE_ADDBAN)
  546. {
  547. get_pcvar_string (cvar_Flags,Flags,charsmax(Flags));
  548. strtolower(Flags);
  549. for (new i=0;i<Found;i++)
  550. for (new j=0;j<strlen(Flags);j++)
  551. if ((isalpha(Flags[j]))&&(get_user_flags(Target[i]) & power(2,(Flags[j]-97))))
  552. {
  553. if (id)
  554. client_cmd(id,"echo [UltimateBans] Ezt/Ezeket a Jatekost/Jatekosokat nem lehet Bannolni mert a Szerverhez Hozzaferesi Joggal rendelkezik/rendelkeznek");
  555. else
  556. server_print("[UltimateBans] Ezt/Ezeket a Jatekost/Jatekosokat nem lehet Bannolni mert a Szerverhez Hozzaferesi Joggal rendelkezik/rendelkeznek");
  557. return PLUGIN_HANDLED
  558. }
  559. }
  560. // ------==|| Ido ||==------
  561. static dot,count_digits,years,months,days,hours,minutes,seconds,Float:NUM_Duration,STR_BanTime[32],STR_Duration[128],STR_UnbanTime[32],_years[7],_months[5],_days[5],_hours[5],_minutes[5],_seconds[5],bool:is_permanent;
  562. years=0,months=0,days=0,hours=0,minutes=0,seconds=0,dot=0,count_digits=1,is_permanent=false;
  563. if (!isdigit(ARG_Duration[0]))
  564. {
  565. bad_input(id);
  566. MODE_ADDBAN = false
  567. return PLUGIN_HANDLED
  568. }
  569. for (new i=1;i<strlen(ARG_Duration);i++)
  570. {
  571. if (ARG_Duration[i]=='.')
  572. {
  573. if (++dot>1)
  574. {
  575. bad_input(id);
  576. MODE_ADDBAN = false
  577. return PLUGIN_HANDLED
  578. }
  579. }
  580. else if (!isdigit(ARG_Duration[i]))
  581. {
  582. bad_input(id);
  583. MODE_ADDBAN = false
  584. return PLUGIN_HANDLED
  585. }
  586. else if (!dot)
  587. count_digits++;
  588. }
  589. if (count_digits>8)
  590. NUM_Duration = 0.0;
  591. else
  592. NUM_Duration = str_to_float(ARG_Duration);
  593. minutes = floatround(NUM_Duration,floatround_floor);
  594. seconds = floatround(floatfract(NUM_Duration)*60,floatround_floor);
  595. while(minutes>=60)
  596. {
  597. minutes -= 60;
  598. hours++;
  599. }
  600. while(hours>=24)
  601. {
  602. hours -= 24;
  603. days++;
  604. }
  605. if (NUM_Duration)
  606. {
  607. is_permanent = false;
  608. len = 0;
  609. if (days)
  610. len += formatex(STR_Duration[len],charsmax(STR_Duration)-len,"%d Nap ",days);
  611. if (hours)
  612. len += formatex(STR_Duration[len],charsmax(STR_Duration)-len,"%i Ora ",hours);
  613. if (minutes)
  614. len += formatex(STR_Duration[len],charsmax(STR_Duration)-len,"%i Perc ",minutes);
  615. if (seconds)
  616. len += formatex(STR_Duration[len],charsmax(STR_Duration)-len,"%i Masodperc",seconds);
  617. format_time(_hours,charsmax(_hours),"%H");
  618. format_time(_minutes,charsmax(_minutes),"%M");
  619. format_time(_seconds,charsmax(_seconds),"%S");
  620. format_time(_days,charsmax(_days),"%d");
  621. format_time(_months,charsmax(_months),"%m");
  622. format_time(_years,charsmax(_years),"%Y");
  623. formatex(STR_BanTime,charsmax(STR_BanTime),"%s:%s:%s %s/%s/%s",_hours,_minutes,_seconds,_days,_months,_years);
  624. hours = str_to_num(_hours);
  625. months= str_to_num(_months);
  626. days = str_to_num(_days);
  627. years = str_to_num(_years);
  628. minutes = floatround(NUM_Duration,floatround_floor)+str_to_num(_minutes);
  629. while(minutes>=60)
  630. {
  631. minutes -= 60;
  632. hours++;
  633. }
  634. while(hours>=24)
  635. {
  636. hours -= 24;
  637. days++;
  638. }
  639. while(days>get_monthdays(months,years))
  640. {
  641. days -= get_monthdays(months,years);
  642. if (++months>12)
  643. {
  644. months -= 12;
  645. years++;
  646. }
  647. }
  648. seconds += str_to_num(_seconds);
  649. if (seconds>59)
  650. {
  651. seconds -= 60;
  652. if (minutes<59)
  653. minutes++;
  654. else
  655. {
  656. minutes=0;
  657. if (hours<23)
  658. hours++;
  659. else
  660. {
  661. hours=0;
  662. if (days<get_monthdays(months,years))
  663. days++;
  664. else
  665. {
  666. days=1;
  667. if (months<12)
  668. months++;
  669. else
  670. {
  671. months=1;
  672. years++;
  673. }
  674. }
  675. }
  676. }
  677. }
  678. formatex(STR_UnbanTime,charsmax(STR_UnbanTime),"%02i:%02i:%02i %02i/%02i/%d", hours,minutes,seconds,days,months,years);
  679. }
  680. else
  681. {
  682. is_permanent = true;
  683. copy(STR_Duration,charsmax(STR_Duration)," a Szerverrol");
  684. format_time(STR_BanTime,charsmax(STR_BanTime),"%H:%M %d/%m/%Y");
  685. copy(STR_UnbanTime,charsmax(STR_UnbanTime),"<null>");
  686. }
  687. // ------==|| Banner ||==------
  688. static Name2[64],AuthID2[32],IP2[16];
  689. if (id)
  690. {
  691. get_user_name(id,Name2,charsmax(Name2));
  692. get_user_ip(id,IP2,charsmax(IP2),1);
  693. get_user_authid(id,AuthID2,charsmax(AuthID2));
  694. }
  695. // ------==|| Final Step ||==------
  696. static Contact[128],Name1[64],AuthID1[32],IP1[16],DATA[BanInfo],func_buffer[1024],Float:handle_delay;
  697. len = 0;
  698. len += formatex(func_buffer[len],charsmax(func_buffer)-len,"^"%s^" ",ARG_BanType);
  699. if (MODE_ADDBAN)
  700. {
  701. switch (NUM_BanType)
  702. {
  703. case 2: len += formatex(func_buffer[len],charsmax(func_buffer)-len,"^"%s^" ^"<null>^" ^"<null>^" ",ARG_Target);
  704. case 3: len += formatex(func_buffer[len],charsmax(func_buffer)-len,"^"<null>^" ^"%s^" ^"<null>^" ",ARG_Target);
  705. case 4: len += formatex(func_buffer[len],charsmax(func_buffer)-len,"^"<null>^" ^"<null>^" ^"%s^" ",ARG_Target);
  706. }
  707. }
  708. else
  709. {
  710. get_user_authid(Target[0],AuthID1,charsmax(AuthID1));
  711. get_user_ip(Target[0],IP1,charsmax(IP1),1);
  712. get_user_name(Target[0],Name1,charsmax(Name1));
  713. if (Found==1)
  714. {
  715. if (MODE_RANGEBAN)
  716. len += formatex(func_buffer[len],charsmax(func_buffer)-len,"^"<null>^" ^"%s^" ^"<null>^" ",ARG_Target);
  717. else
  718. len += formatex(func_buffer[len],charsmax(func_buffer)-len,"^"%s^" ^"%s^" ^"%s^" ",AuthID1,IP1,(NUM_BanType==4)?ARG_Target:Name1);
  719. }
  720. else
  721. {
  722. switch (NUM_BanType)
  723. {
  724. case 2: len += formatex(func_buffer[len],charsmax(func_buffer)-len,"^"%s^" ^"<null>^" ^"<null>^" ",AuthID1);
  725. case 3: len += formatex(func_buffer[len],charsmax(func_buffer)-len,"^"<null>^" ^"%s^" ^"<null>^" ",MODE_RANGEBAN?ARG_Target:IP1);
  726. case 4: len += formatex(func_buffer[len],charsmax(func_buffer)-len,"^"<null>^" ^"<null>^" ^"%s^" ",ARG_Target);
  727. }
  728. }
  729. }
  730. len += formatex(func_buffer[len],charsmax(func_buffer)-len,"^"%s^" ^"%s^" ",STR_BanTime,STR_UnbanTime);
  731. if (id)
  732. len += formatex(func_buffer[len],charsmax(func_buffer)-len,"^"%s^" ^"%s^" ^"%s^" ",AuthID2,IP2,Name2);
  733. else
  734. len += formatex(func_buffer[len],charsmax(func_buffer)-len,"^"<null>^" ^"<null>^" ^"RCON/Server^" ");
  735. len += formatex(func_buffer[len],charsmax(func_buffer)-len,"^"%s^"",ARG_Reason);
  736. new file = fopen(ub_banlistfile,"a+");
  737. fprintf(file,"%s^n",func_buffer);
  738. fclose(file);
  739. parse(func_buffer,DATA[bantype],charsmax(DATA[bantype]),DATA[target_authid],charsmax(DATA[target_authid]),DATA[target_ip],charsmax(DATA[target_ip]),DATA[target_name],charsmax(DATA[target_name]),DATA[bantime],charsmax(DATA[bantime]),DATA[unbantime],charsmax(DATA[unbantime]),DATA[banner_authid],charsmax(DATA[banner_authid]),DATA[banner_ip],charsmax(DATA[banner_ip]),DATA[banner_name],charsmax(DATA[banner_name]),DATA[reason],charsmax(DATA[reason]));
  740. ArrayPushArray(banlist_array,DATA);
  741. TotalBans++;
  742. LastBanTime = get_gametime();
  743. if (MODE_ADDBAN)
  744. {
  745. formatex(func_buffer,charsmax(func_buffer),"^x01[UltimateBans] ^x03 %s^x04 hozzaadva a BANLISTAHOZ^x04 %s%s^x04 %s altal.^x01 [ Ok - ^"%s^" ]",ARG_Target,is_permanent?"Orokos":"for ",is_permanent?"":STR_Duration,id?Name2:"RCON/Server",ARG_Reason);
  746. ChatPrint(func_buffer);
  747. if (id)
  748. log_to_file("addons/amxmodx/logs/UB_Logs.log","<ADDBAN> < AuthID:^"%s^" , IP:^"%s^" , Nev:^"%s^" > BANNOLVA %s %s < AuthID:^"%s^" , IP:^"%s^" , Nev:^"%s^" > altal. [ BanTipus - ^"%s^" ] [ Ok - ^"%s^" ]",DATA[target_authid],DATA[target_ip],DATA[target_name],is_permanent?"Permanently":"for",is_permanent?"a Szerverrol":STR_Duration,AuthID2,IP2,Name2,ARG_BanType,ARG_Reason);
  749. else
  750. log_to_file("addons/amxmodx/logs/UB_Logs.log","<ADDBAN> < AuthID:^"%s^" , IP:^"%s^" , Nev:^"%s^" > BANNOLVA %s %s < RCON/Server > altal. [ BanTipus - ^"%s^" ] [ Ok - ^"%s^" ]",DATA[target_authid],DATA[target_ip],DATA[target_name],is_permanent?"Orokos":"for",is_permanent?"a Szerverrol":STR_Duration,ARG_BanType,ARG_Reason);
  751. MODE_ADDBAN = false;
  752. }
  753. else
  754. {
  755. handle_delay = 0.0;
  756. static Hostname[64];
  757. get_user_name(0,Hostname,charsmax(Hostname));
  758. for ( new i=0;i<Found;i++)
  759. {
  760. client_cmd(Target[i],"echo [UltimateBans] -------------------------------");
  761. client_cmd(Target[i],"echo [UltimateBans] --==|| BAN INFO ||==--");
  762. client_cmd(Target[i],"echo [UltimateBans] -------------------------------");
  763. client_cmd(Target[i],"echo [UltimateBans] Server - %s",Hostname);
  764. if (is_permanent)
  765. PrintBanInfo(DATA,Target[i]);
  766. else
  767. PrintBanInfo(DATA,Target[i],STR_Duration);
  768. get_pcvar_string(cvar_Contact,Contact,charsmax(Contact));
  769. if (!equali(Contact,"N/A"))
  770. {
  771. client_cmd(Target[i],"echo [UltimateBans] Unban Kereshez, Irj ide : ^"%s^"",Contact);
  772. client_cmd(Target[i],"echo [UltimateBans] -------------------------------");
  773. }
  774. get_user_authid(Target[i],AuthID1,charsmax(AuthID1));
  775. get_user_ip(Target[i],IP1,charsmax(IP1),1);
  776. get_user_name(Target[i],Name1,charsmax(Name1));
  777. formatex(func_buffer,charsmax(func_buffer),"^x01[UltimateBans]^x03 %s^x04 BANNOLVA lett^x03 %s%s^x04 BY^x03 %s.^x01 [ Ok - ^"%s^" ]",Name1,is_permanent?"Orokos":"for ",STR_Duration,id?Name2:"RCON/Server",ARG_Reason);
  778. set_task(handle_delay,"ChatPrint",80085,func_buffer,charsmax(func_buffer));
  779. if (id)
  780. formatex(func_buffer,charsmax(func_buffer),"<BAN> < AuthID:^"%s^" , IP:^"%s^" , Nev:^"%s^" > BANNOLVA %s %s < AuthID:^"%s^" , IP:^"%s^" , Nev:^"%s^" > altal. [ BanTipus - ^"%s^" ] [ Ok - ^"%s^" ]",AuthID1,MODE_RANGEBAN?ARG_Target:IP1,Name1,is_permanent?"Orokos":"for",is_permanent?"a Szerverrol":STR_Duration,AuthID2,IP2,Name2,ARG_BanType,ARG_Reason);
  781. else
  782. formatex(func_buffer,charsmax(func_buffer),"<BAN> < AuthID:^"%s^" , IP:^"%s^" , Nev:^"%s^" > BANNOLVA %s %s < RCON/Server > altal. [ BanTipus - ^"%s^" ] [ Ok - ^"%s^" ]",AuthID1,MODE_RANGEBAN?ARG_Target:IP1,Name1,is_permanent?"Orokos":"for",is_permanent?"a Szerverrol":STR_Duration,ARG_BanType,ARG_Reason);
  783. set_task(handle_delay,"DelayedLog",80085,func_buffer,charsmax(func_buffer));
  784. handle_delay += 0.5;
  785. server_cmd("kick #%d ^"Bannolva lettel %s%s. Bovebb Informacioert nezd meg a Konzolt.^"",get_user_userid(Target[i]),is_permanent?"Orokos":"for ",is_permanent?"a Szerverrol":STR_Duration);
  786. }
  787. }
  788. if (handle_ban_menu_call[id])
  789. {
  790. Menu_Ban_Display(id,Menu_Ban_pos[id]);
  791. handle_ban_menu_call[id] = false;
  792. }
  793. return PLUGIN_HANDLED
  794. }
  795.  
  796. public CmdADDBAN(id,level,cid)
  797. {
  798. if (!cmd_access(id,level,cid,2,false))
  799. return PLUGIN_HANDLED
  800. MODE_ADDBAN = true;
  801. static command[256];
  802. read_args(command,charsmax(command));
  803. if (id)
  804. client_cmd(id,"amx_ban %s",command);
  805. else
  806. server_cmd("amx_ban %s",command);
  807. return PLUGIN_HANDLED
  808. }
  809.  
  810. public CmdUNBAN(id,level,cid)
  811. {
  812. if (!cmd_access(id,level,cid,2,false))
  813. return PLUGIN_HANDLED
  814. // ------==|| Input Data Handling ||==------
  815. new ARG_Target[64],ARG_BanType[8];
  816. static ARG_Count,ARG_STR[128];
  817. ARG_Count = 0;
  818. read_args(ARG_STR,charsmax(ARG_STR));
  819. parse(ARG_STR,ARG_Target,charsmax(ARG_Target),ARG_BanType,charsmax(ARG_BanType));
  820. if (strlen(ARG_Target))
  821. {
  822. ARG_Count=1;
  823. trim(ARG_Target);
  824. if (equali(ARG_Target,"<null>",6))
  825. {
  826. bad_input(id);
  827. return PLUGIN_HANDLED
  828. }
  829. if (strlen(ARG_BanType))
  830. {
  831. ARG_Count=2;
  832. trim(ARG_BanType);
  833. }
  834. }
  835. // ------==|| Input Type Handling ||==------
  836. static NUM_BanType;
  837. if (ARG_Count==2)
  838. {
  839. if (equali(ARG_BanType,"AUTO",4))
  840. NUM_BanType = 1;
  841. else if (equali(ARG_BanType,"STEAMID",7))
  842. {
  843. copy(ARG_BanType,charsmax(ARG_BanType),"STEAMID");
  844. NUM_BanType = 2;
  845. }
  846. else if (equali(ARG_BanType,"IP",2))
  847. {
  848. copy(ARG_BanType,charsmax(ARG_BanType),"IP");
  849. NUM_BanType = 3;
  850. }
  851. else if (equali(ARG_BanType,"NAME",4))
  852. {
  853. copy(ARG_BanType,charsmax(ARG_BanType),"NEV");
  854. NUM_BanType = 4;
  855. }
  856. else
  857. {
  858. bad_input(id);
  859. return PLUGIN_HANDLED
  860. }
  861. }
  862. else
  863. NUM_BanType = 1;
  864. if (NUM_BanType==1)
  865. {
  866. if (IsValidAUTHID(ARG_Target))
  867. {
  868. copy (ARG_BanType,charsmax(ARG_BanType),"STEAMID");
  869. NUM_BanType = 2;
  870. }
  871. else if (IsValidIP(ARG_Target))
  872. {
  873. copy (ARG_BanType,charsmax(ARG_BanType),"IP");
  874. NUM_BanType = 3;
  875. }
  876. else
  877. {
  878. copy (ARG_BanType,charsmax(ARG_BanType),"NEV");
  879. NUM_BanType = 4;
  880. }
  881. }
  882. // ------==|| Final Step ||==------
  883. static pos,Unbanner_Name[64],DATA[BanInfo],func_buffer[256];
  884. MODE_UNBAN = true;
  885. pos = CheckBan(ARG_Target,ARG_BanType);
  886. if (pos==-2)
  887. {
  888. if (id)
  889. client_cmd(id,"echo [UltimateBans] A Jatekos Nem Talalhato");
  890. else
  891. server_print("[UltimateBans] A Jatekos Nem Talalhato");
  892. MODE_UNBAN = false;
  893. return PLUGIN_HANDLED
  894. }
  895. if (id)
  896. get_user_name(id,Unbanner_Name,charsmax(Unbanner_Name));
  897. ArrayGetArray(banlist_array,pos,DATA);
  898. if (!equali(DATA[target_name],"<null>"))
  899. formatex(func_buffer,charsmax(func_buffer),"^x01[UltimateBans]^x03 %s^x04 fel lett^x03 oldva^x04 ^"%s^" altal^x03",DATA[target_name],id?Unbanner_Name:"RCON/Server");
  900. else
  901. {
  902. if (NUM_BanType==2)
  903. formatex(func_buffer,charsmax(func_buffer),"^x01[UltimateBans]^x03 %s^x04 fel lett^x03 oldva^x04 ^"%s^" altal^x03",DATA[target_authid],id?Unbanner_Name:"RCON/Server");
  904. else
  905. formatex(func_buffer,charsmax(func_buffer),"^x01[UltimateBans]^x03 %s^x04 fel lett^x03 oldva^x04 ^"%s^" altal^x03",DATA[target_ip],id?Unbanner_Name:"RCON/Server");
  906. }
  907. ChatPrint(func_buffer);
  908. if (id)
  909. log_to_file("addons/amxmodx/logs/UB_Logs.log","<UNBAN> < AuthID:^"%s^" , IP:^"%s^" , Nev:^"%s^" , BanTipus:^"%s^" > Feloldotta < AuthID:^"%s^" , IP:^"%s^" , Nev:^"%s^" >",DATA[target_authid],DATA[target_ip],DATA[target_name],ARG_BanType,DATA[banner_authid],DATA[banner_ip],DATA[banner_name]);
  910. else
  911. log_to_file("addons/amxmodx/logs/UB_Logs.log","<UNBAN> < AuthID:^"%s^" , IP:^"%s^" , Nev:^"%s^" , BanTipus:^"%s^" > Feloldotta < RCON/Server >",DATA[target_authid],DATA[target_ip],DATA[target_name],ARG_BanType);
  912. ArrayDeleteItem(banlist_array,pos);
  913. TotalBans--;
  914. new file = fopen(ub_banlistfile,"wt");
  915. for(new i=0;i<TotalBans;i++)
  916. {
  917. ArrayGetArray(banlist_array,i,DATA);
  918. fprintf(file,"^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^"^n",DATA[bantype],DATA[target_authid],DATA[target_ip],DATA[target_name],DATA[bantime],DATA[unbantime],DATA[banner_authid],DATA[banner_ip],DATA[banner_name],DATA[reason]);
  919. }
  920. fclose(file);
  921. if (handle_unban_menu_call[id])
  922. {
  923. Menu_Unban_Display(id,Menu_Unban_pos[id]);
  924. handle_unban_menu_call[id] = false;
  925. }
  926. MODE_UNBAN = false;
  927. return PLUGIN_HANDLED
  928. }
  929.  
  930. public CmdQUERYNEXT(id,level,cid)
  931. {
  932. if (!cmd_access(id,level,cid,1,false))
  933. return PLUGIN_HANDLED
  934. if (QueryCount[id]<=QueryPointer[id]+4)
  935. {
  936. if (id)
  937. client_cmd(id,"echo [UltimateBans] A Query Kovetkezo Oldala nem Letezik");
  938. else
  939. server_print("[UltimateBans] A Query Kovetkezo Oldala nem Letezik");
  940. return PLUGIN_HANDLED
  941. }
  942. QueryPointer[id] += 5
  943. MODE_QUERY_CONTINUE = true;
  944. if (id)
  945. client_cmd(id,"ub_queryban %s %s",LastQuery[id],LastQueryType[id]);
  946. else
  947. server_cmd("ub_queryban %s %s",LastQuery[0],LastQueryType[0]);
  948. return PLUGIN_HANDLED
  949. }
  950.  
  951. public CmdQUERYBACK(id,level,cid)
  952. {
  953. if (!cmd_access(id,level,cid,1,false))
  954. return PLUGIN_HANDLED
  955. if (QueryPointer[id]-5<=0)
  956. {
  957. if (id)
  958. client_cmd(id,"echo [UltimateBans] A Query Elozo Oldala nem Letezik");
  959. else
  960. server_print("[UltimateBans] A Query Elozo Oldala nem Letezik");
  961. return PLUGIN_HANDLED
  962. }
  963. QueryPointer[id] -= 5
  964. MODE_QUERY_CONTINUE = true;
  965. if (id)
  966. client_cmd(id,"ub_queryban %s %s",LastQuery[id],LastQueryType[id]);
  967. else
  968. server_cmd("ub_queryban %s %s",LastQuery[0],LastQueryType[0]);
  969. return PLUGIN_HANDLED
  970. }
  971.  
  972. public CmdQUERY(id,level,cid)
  973. {
  974. if (!cmd_access(id,level,cid,2,false))
  975. return PLUGIN_HANDLED
  976. // ------==|| Input Data Handling ||==------
  977. new ARG_Target[64],ARG_BanType[8];
  978. static ARG_Count,ARG_STR[128];
  979. ARG_Count = 0;
  980. read_args(ARG_STR,charsmax(ARG_STR));
  981. trim(ARG_STR);
  982. parse(ARG_STR,ARG_Target,charsmax(ARG_Target),ARG_BanType,charsmax(ARG_BanType));
  983. if (strlen(ARG_Target))
  984. {
  985. ARG_Count=1;
  986. trim(ARG_Target);
  987. if (equali(ARG_Target,"<null>",6))
  988. {
  989. bad_input(id);
  990. MODE_QUERY_CONTINUE = false;
  991. return PLUGIN_HANDLED
  992. }
  993. if (strlen(ARG_BanType))
  994. {
  995. ARG_Count=2;
  996. trim(ARG_BanType);
  997. }
  998. }
  999. // ------==|| Input Type Handling ||==------
  1000. static NUM_BanType;
  1001. if (ARG_Count==2)
  1002. {
  1003. if (equali(ARG_BanType,"AUTO",4))
  1004. NUM_BanType = 1;
  1005. if (equali(ARG_BanType,"STEAMID",7))
  1006. {
  1007. copy(ARG_BanType,charsmax(ARG_BanType),"STEAMID");
  1008. NUM_BanType = 2;
  1009. }
  1010. else if (equali(ARG_BanType,"IP",2))
  1011. {
  1012. copy(ARG_BanType,charsmax(ARG_BanType),"IP");
  1013. NUM_BanType = 3;
  1014. }
  1015. else if (equali(ARG_BanType,"NAME",4))
  1016. {
  1017. copy(ARG_BanType,charsmax(ARG_BanType),"NAME");
  1018. NUM_BanType = 4;
  1019. }
  1020. else
  1021. {
  1022. bad_input(id);
  1023. MODE_QUERY_CONTINUE = false;
  1024. return PLUGIN_HANDLED
  1025. }
  1026. }
  1027. else
  1028. NUM_BanType = 1;
  1029. // ------==|| Final Step ||==------
  1030. static DATA[BanInfo],bool:ShowData,bool:Found;
  1031. Found = false;
  1032. if (MODE_QUERY_CONTINUE)
  1033. MODE_QUERY_CONTINUE = false;
  1034. else
  1035. QueryPointer[id] = 1;
  1036. QueryCount[id] = 0;
  1037. if (id)
  1038. {
  1039. client_cmd(id,"echo [UltimateBans] -------------------------------");
  1040. client_cmd(id,"echo [UltimateBans] --==|| QUERY EREDMENYEK ||==--");
  1041. client_cmd(id,"echo [UltimateBans] -------------------------------");
  1042. }
  1043. else
  1044. {
  1045. server_print("[UltimateBans] -------------------------------");
  1046. server_print("[UltimateBans] --==|| QUERY EREDMENYEK ||==--");
  1047. server_print("[UltimateBans] -------------------------------");
  1048. }
  1049. for (new i=0;i<TotalBans;i++)
  1050. {
  1051. ShowData = false;
  1052. ArrayGetArray(banlist_array,i,DATA);
  1053. switch (NUM_BanType)
  1054. {
  1055. case 1: if ((containi(DATA[target_authid],ARG_Target)!=-1)||(containi(DATA[target_ip],ARG_Target)!=-1)||(containi(DATA[target_name],ARG_Target)!=-1)) ShowData = true;
  1056. case 2: if (containi(DATA[target_authid],ARG_Target)!=-1) ShowData = true;
  1057. case 3: if (containi(DATA[target_ip],ARG_Target)!=-1) ShowData = true;
  1058. case 4: if (containi(DATA[target_name],ARG_Target)!=-1) ShowData = true;
  1059. }
  1060. if (ShowData)
  1061. {
  1062. QueryCount[id]++;
  1063. if (QueryPointer[id]+4>=QueryCount[id]>=QueryPointer[id])
  1064. {
  1065. Found = true;
  1066. PrintBanInfo(DATA,id);
  1067. }
  1068. }
  1069. }
  1070. if (!Found)
  1071. {
  1072. if (id)
  1073. {
  1074. client_cmd(id,"echo [UltimateBans] Nem Talalhato / Az Oldal nem Letezik");
  1075. client_cmd(id,"echo [UltimateBans] -------------------------------");
  1076. }
  1077. else
  1078. {
  1079. server_print("[UltimateBans] Nem Talalhato / Az Oldal nem Letezik");
  1080. server_print("[UltimateBans] -------------------------------");
  1081. }
  1082. }
  1083. else
  1084. {
  1085. copy(LastQuery[id],63,ARG_Target);
  1086. if (ARG_Count==2)
  1087. copy(LastQueryType[id],7,ARG_BanType);
  1088. if (id)
  1089. {
  1090. if (QueryCount[id]>=QueryPointer[id]+5)
  1091. client_cmd(id,"echo [UltimateBans] Ird be ^"ub_querynext^" a Kovetkezo Oldal megtekintesehez");
  1092. if (QueryPointer[id]-5>=0)
  1093. client_cmd(id,"echo [UltimateBans] Ird be ^"ub_queryback^" az Elozo Oldal megtekintesehez");
  1094. if (QueryCount[id]>=6)
  1095. client_cmd(id,"echo [UltimateBans] -------------------------------");
  1096. }
  1097. else
  1098. {
  1099. if (QueryCount[id]>=QueryPointer[id]+5)
  1100. server_print("[UltimateBans] Ird be ^"ub_querynext^" a Kovetkezo Oldal megtekintesehez");
  1101. if (QueryPointer[id]-5>=0)
  1102. server_print("[UltimateBans] Ird be ^"ub_queryback^" az Elozo Oldal megtekintesehez");
  1103. if (QueryCount[id]>=6)
  1104. server_print("[UltimateBans] -------------------------------");
  1105. }
  1106. }
  1107. return PLUGIN_HANDLED
  1108. }
  1109.  
  1110. public CmdBANLIST(id,level,cid)
  1111. {
  1112. if (!cmd_access(id,level,cid,1,false))
  1113. return PLUGIN_HANDLED
  1114.  
  1115. if (!TotalBans)
  1116. {
  1117. if (id)
  1118. client_cmd(id,"echo [UltimateBans] A Banlista Ures");
  1119. else
  1120. server_print("[UltimateBans] A Banlista Ures");
  1121. return PLUGIN_HANDLED
  1122. }
  1123. new ARG_STR[128],ARG_Start[8],Start,End;
  1124. read_args(ARG_STR,charsmax(ARG_STR));
  1125. parse(ARG_STR,ARG_Start,charsmax(ARG_Start));
  1126. if (strlen(ARG_Start))
  1127. {
  1128. trim(ARG_Start);
  1129. Start = str_to_num(ARG_Start);
  1130. if (!Start)
  1131. {
  1132. bad_input(id);
  1133. return PLUGIN_HANDLED
  1134. }
  1135. if (TotalBans>=5)
  1136. {
  1137. if (Start>TotalBans)
  1138. {
  1139. Start = TotalBans-4;
  1140. End = TotalBans;
  1141. }
  1142. else
  1143. {
  1144. if (Start+4<=TotalBans)
  1145. End = Start+4;
  1146. else
  1147. End = TotalBans;
  1148. }
  1149. }
  1150. else
  1151. {
  1152. if (Start>TotalBans)
  1153. Start = 1;
  1154. End = TotalBans;
  1155. }
  1156. }
  1157. else
  1158. {
  1159. Start = 1;
  1160. if (TotalBans>=5)
  1161. End = 5;
  1162. else
  1163. End = TotalBans;
  1164. }
  1165. if (id)
  1166. {
  1167. client_cmd(id,"echo [UltimateBans] -------------------------------");
  1168. client_cmd(id,"echo [UltimateBans] --==|| BAN LISTA ||==--");
  1169. client_cmd(id,"echo [UltimateBans] -------------------------------");
  1170. client_cmd(id,"echo [UltimateBans] Bejegyzesek %d-%d Osszes: %d",Start,End,TotalBans);
  1171. client_cmd(id,"echo [UltimateBans] -------------------------------");
  1172. }
  1173. else
  1174. {
  1175. server_print("[UltimateBans] -------------------------------");
  1176. server_print("[UltimateBans] --==|| BAN LISTA ||==--");
  1177. server_print("[UltimateBans] -------------------------------");
  1178. server_print("[UltimateBans] Bejegyzesek %d-%d Osszes: %d",Start,End,TotalBans);
  1179. server_print("[UltimateBans] -------------------------------");
  1180. }
  1181. static DATA[BanInfo];
  1182. for (new i=0;i<TotalBans;i++)
  1183. {
  1184. if (Start<=i+1<=End)
  1185. {
  1186. ArrayGetArray(banlist_array,i,DATA);
  1187. PrintBanInfo(DATA,id);
  1188. }
  1189. else if (i+1>End)
  1190. break;
  1191. }
  1192. if (id)
  1193. {
  1194. if (End<TotalBans)
  1195. {
  1196. if (End+5<=TotalBans)
  1197. client_cmd(id,"echo [UltimateBans] Ird be ^"ub_banlistfile %d^" a Kovetkezo 5 Bejegyzes megtekintesehez",End+1);
  1198. else
  1199. client_cmd(id,"echo [UltimateBans] Ird be ^"ub_banlistfile %d^" a Kovetkezo %d Bejegyzes megtekintesehez",End+1,TotalBans-End);
  1200. client_cmd(id,"echo [UltimateBans] -------------------------------");
  1201. }
  1202. }
  1203. else
  1204. {
  1205. if (End<TotalBans)
  1206. {
  1207. if (End+5<=TotalBans)
  1208. server_print("[UltimateBans] Ird be ^"ub_banlistfile %d^" a Kovetkezo 5 Bejegyzes megtekintesehez",End+1);
  1209. else
  1210. server_print("[UltimateBans] Ird be ^"ub_banlistfile %d^" a Kovetkezo %d Bejegyzes megtekintesehez",End+1,TotalBans-End);
  1211. server_print("[UltimateBans] -------------------------------");
  1212. }
  1213. }
  1214. return PLUGIN_HANDLED
  1215. }
  1216.  
  1217. public CmdRELOAD()
  1218. {
  1219. server_print("[UltimateBans] Minden Ban Ujratoltve!");
  1220. CmdLOAD();
  1221. }
  1222.  
  1223. CmdLOAD()
  1224. {
  1225. ArrayClear(banlist_array);
  1226. TotalBans = 0;
  1227. new file,func_buffer[1024],DATA[BanInfo],bool:filter_file,NUM_BanType;
  1228. filter_file = false;
  1229. MODE_LOADBAN = true;
  1230. file = fopen(ub_banlistfile, "rt");
  1231. while(!feof(file))
  1232. {
  1233. fgets(file,func_buffer,charsmax(func_buffer));
  1234. trim(func_buffer);
  1235. if (!func_buffer[0])
  1236. continue;
  1237. parse(func_buffer,DATA[bantype],charsmax(DATA[bantype]),DATA[target_authid],charsmax(DATA[target_authid]),DATA[target_ip],charsmax(DATA[target_ip]),DATA[target_name],charsmax(DATA[target_name]),DATA[bantime],charsmax(DATA[bantime]),DATA[unbantime],charsmax(DATA[unbantime]),DATA[banner_authid],charsmax(DATA[banner_authid]),DATA[banner_ip],charsmax(DATA[banner_ip]),DATA[banner_name],charsmax(DATA[banner_name]),DATA[reason],charsmax(DATA[reason]));
  1238. trim(DATA[bantype]);
  1239. if (!(DATA[bantype][0]))
  1240. copy(DATA[bantype],charsmax(DATA[bantype]),"<null>");
  1241. trim(DATA[target_authid]);
  1242. if (!(DATA[target_authid][0]))
  1243. copy(DATA[target_authid],charsmax(DATA[target_authid]),"<null>");
  1244. trim(DATA[target_ip]);
  1245. if (!(DATA[target_ip][0]))
  1246. copy(DATA[target_ip],charsmax(DATA[target_ip]),"<null>");
  1247. trim(DATA[target_name]);
  1248. if (!(DATA[target_name][0]))
  1249. copy(DATA[target_name],charsmax(DATA[target_name]),"<null>");
  1250. trim(DATA[bantime]);
  1251. if (!(DATA[bantime][0]))
  1252. copy(DATA[bantime],charsmax(DATA[bantime]),"<null>");
  1253. trim(DATA[unbantime]);
  1254. if (!(DATA[unbantime][0]))
  1255. copy(DATA[unbantime],charsmax(DATA[unbantime]),"<null>");
  1256. trim(DATA[banner_authid]);
  1257. if (!(DATA[banner_authid][0]))
  1258. copy(DATA[banner_authid],charsmax(DATA[banner_authid]),"<null>");
  1259. trim(DATA[banner_ip]);
  1260. if (!(DATA[banner_ip][0]))
  1261. copy(DATA[banner_ip],charsmax(DATA[banner_ip]),"<null>");
  1262. trim(DATA[banner_name]);
  1263. if (!(DATA[banner_name][0]))
  1264. copy(DATA[banner_name],charsmax(DATA[banner_name]),"<null>");
  1265. trim(DATA[reason]);
  1266. if (!(DATA[reason][0]))
  1267. copy(DATA[reason],charsmax(DATA[reason]),"<null>");
  1268. if (equali(DATA[bantype],"STEAMID",7))
  1269. NUM_BanType = 2;
  1270. else if (equali(DATA[bantype],"IP",2))
  1271. NUM_BanType = 3;
  1272. else if (equali(DATA[bantype],"NAME",4))
  1273. NUM_BanType = 4;
  1274. else
  1275. {
  1276. filter_file = true;
  1277. continue;
  1278. }
  1279. switch (NUM_BanType)
  1280. {
  1281. case 2:
  1282. {
  1283. if (!IsValidAUTHID(DATA[target_authid]))
  1284. {
  1285. filter_file = true;
  1286. continue;
  1287. }
  1288. if (CheckBan(DATA[target_authid],"STEAMID")!=-2)
  1289. {
  1290. filter_file = true;
  1291. continue;
  1292. }
  1293. }
  1294. case 3:
  1295. {
  1296. if (!IsValidIP(DATA[target_ip]))
  1297. {
  1298. filter_file = true;
  1299. continue;
  1300. }
  1301. if (CheckBan(DATA[target_ip],"IP")!=-2)
  1302. {
  1303. filter_file = true;
  1304. continue;
  1305. }
  1306. }
  1307. case 4:
  1308. {
  1309. if (equali(DATA[target_name],"<null>",6))
  1310. {
  1311. filter_file = true;
  1312. continue;
  1313. }
  1314. if (CheckBan(DATA[target_name],"NEV")!=-2)
  1315. {
  1316. filter_file = true;
  1317. continue;
  1318. }
  1319. }
  1320. }
  1321. if ((!equali(DATA[unbantime],"<null>",6))&&(!IsValidTIME(DATA[unbantime])))
  1322. {
  1323. filter_file = true;
  1324. continue;
  1325. }
  1326. ArrayPushArray(banlist_array,DATA);
  1327. TotalBans++;
  1328. }
  1329. fclose(file);
  1330. MODE_LOADBAN = false;
  1331. for (new i=0;i<33;i++)
  1332. if (auth_delay[i])
  1333. {
  1334. client_authorized(i);
  1335. auth_delay[i] = false;
  1336. }
  1337. if (task_exists(1337))
  1338. remove_task(1337);
  1339. set_task(1.0,"CheckTimeUP",1337);
  1340. if (!filter_file)
  1341. return;
  1342. file = fopen(ub_banlistfile, "wt");
  1343. for(new i=0;i<TotalBans;i++)
  1344. {
  1345. ArrayGetArray(banlist_array,i,DATA);
  1346. fprintf(file,"^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^"^n",DATA[bantype],DATA[target_authid],DATA[target_ip],DATA[target_name],DATA[bantime],DATA[unbantime],DATA[banner_authid],DATA[banner_ip],DATA[banner_name],DATA[reason]);
  1347. }
  1348. fclose(file);
  1349. }
  1350.  
  1351. public CmdRESET()
  1352. {
  1353. new file = fopen(ub_banlistfile,"wt");fclose(file);
  1354. ArrayClear(banlist_array);
  1355. TotalBans=0;
  1356. log_to_file("addons/amxmodx/logs/UB_Logs.log","< - - - - - MINDEN BAN VISSZAALLITASA - - - - - >");
  1357. }
  1358.  
  1359. public CheckTimeUP()
  1360. {
  1361. static Float:temp_interval;
  1362. temp_interval = get_pcvar_float(cvar_CheckInterval);
  1363. if (temp_interval<1.0)
  1364. {
  1365. set_task(1.0,"CheckTimeUP",1337);
  1366. return PLUGIN_HANDLED
  1367. }
  1368. if (!TotalBans)
  1369. {
  1370. set_task(temp_interval,"CheckTimeUP",1337);
  1371. return PLUGIN_HANDLED
  1372. }
  1373. static DATA[BanInfo],func_buffer[256],bool:filter_file,Float:handle_delay;
  1374. handle_delay = 0.0;
  1375. filter_file = false;
  1376. for(new i=0;i<TotalBans;i++)
  1377. {
  1378. ArrayGetArray(banlist_array,i,DATA);
  1379. if (equali(DATA[unbantime],"<null>",6))
  1380. continue;
  1381. if (!get_ban_timeleft(DATA[unbantime]))
  1382. {
  1383. if (!equali(DATA[target_name],"<null>",6))
  1384. formatex(func_buffer,charsmax(func_buffer),"^x01[UltimateBans]^x04 BANTIME Up/Elaped for^x03 %s",DATA[target_name]);
  1385. else
  1386. {
  1387. if ((equali(DATA[bantype],"STEAMID",7))&&(!equali(DATA[target_authid],"<null>",6)))
  1388. formatex(func_buffer,charsmax(func_buffer),"^x01[UltimateBans]^x04 BANTIME Up/Elaped for^x03 %s",DATA[target_authid]);
  1389. else
  1390. formatex(func_buffer,charsmax(func_buffer),"^x01[UltimateBans] ^x04 BANTIME Up/Elaped for^x03 %s",DATA[target_ip]);
  1391. }
  1392. set_task(handle_delay,"ChatPrint",80085,func_buffer,charsmax(func_buffer));
  1393. formatex(func_buffer,charsmax(func_buffer),"<UNBAN> BANTIME Up/Elapsed for < AuthID:^"%s^" , IP:^"%s^" , Nev:^"%s^" , BanTipus:^"%s^" >",DATA[target_authid],DATA[target_ip],DATA[target_name],DATA[bantype]);
  1394. set_task(handle_delay,"DelayedLog",80085,func_buffer,charsmax(func_buffer));
  1395. handle_delay += 0.5;
  1396. ArrayDeleteItem(banlist_array,i);
  1397. TotalBans--;
  1398. i--;
  1399. filter_file = true;
  1400. }
  1401. }
  1402. if (!filter_file)
  1403. {
  1404. set_task(temp_interval,"CheckTimeUP",1337);
  1405. return PLUGIN_HANDLED
  1406. }
  1407. new file = fopen(ub_banlistfile,"wt");
  1408. for(new i=0;i<TotalBans;i++)
  1409. {
  1410. ArrayGetArray(banlist_array,i,DATA);
  1411. fprintf(file,"^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^"^n",DATA[bantype],DATA[target_authid],DATA[target_ip],DATA[target_name],DATA[bantime],DATA[unbantime],DATA[banner_authid],DATA[banner_ip],DATA[banner_name],DATA[reason]);
  1412. }
  1413. fclose(file);
  1414. set_task(temp_interval,"CheckTimeUP",1337);
  1415. return PLUGIN_HANDLED
  1416. }
  1417.  
  1418. public CmdBANMENU(id,level,cid)
  1419. {
  1420. if (!cmd_access(id,level,cid,1,false))
  1421. return PLUGIN_HANDLED
  1422. Menu_Ban_pos[id] = 0;
  1423. Menu_Ban_Display(id,Menu_Ban_pos[id]);
  1424. return PLUGIN_HANDLED
  1425. }
  1426.  
  1427. public Menu_Ban_Keys(id,key)
  1428. {
  1429. switch (key)
  1430. {
  1431. case 9:
  1432. {
  1433. if (Menu_Ban_pos[id])
  1434. Menu_Ban_Display(id,--Menu_Ban_pos[id])
  1435. else
  1436. Menu_Ban_pos[id] = 0;
  1437. return PLUGIN_HANDLED
  1438. }
  1439. case 8: Menu_Ban_Display(id,++Menu_Ban_pos[id]);
  1440. case 7:
  1441. {
  1442. client_print(id,print_chat,"[UltimateBans] Ird be a BAN Idotartamat Percben kifejezve");
  1443. client_cmd(id,"messagemode UB_SetDuration");
  1444. }
  1445. case 6:
  1446. {
  1447. if(Menu_Ban_BanType[id]<3)
  1448. Menu_Ban_BanType[id]++;
  1449. else
  1450. Menu_Ban_BanType[id]=0;
  1451. Menu_Ban_Display(id,Menu_Ban_pos[id]);
  1452. }
  1453. default:
  1454. {
  1455. Menu_Ban_Target[id] = Menu_Ban_Players[id][Menu_Ban_pos[id]*6+key];
  1456. if(!is_user_connected(Menu_Ban_Target[id]))
  1457. {
  1458. client_print(id,print_chat,"[UltimateBans] Sajnaljuk, de a Jatekos mar Lecsatlakozott a Szerverrol!");
  1459. Menu_Ban_pos[id] = 0;
  1460. Menu_Ban_Display(id,Menu_Ban_pos[id]);
  1461. return PLUGIN_HANDLED
  1462. }
  1463. client_print(id,print_chat,"[UltimateBans] Ird be a bannolas okat a Jatekos Bannolasahoz");
  1464. client_cmd(id,"messagemode UB_SetReason");
  1465. }
  1466. }
  1467. return PLUGIN_HANDLED
  1468. }
  1469.  
  1470. Menu_Ban_Display(id,pos)
  1471. {
  1472. static Keys,len,Start,End,temp_pos,Name[64],bool:is_flagged,func_Buffer[512];
  1473. temp_pos=0,Keys=MENU_KEY_0|MENU_KEY_7|MENU_KEY_8;
  1474. get_players(Menu_Ban_Players[id],Menu_Ban_Total[id]);
  1475. Start = pos*6;
  1476. if (Start>Menu_Ban_Total[id])
  1477. return PLUGIN_HANDLED
  1478. if (Start<0)
  1479. Start=0;
  1480. End = Start+6;
  1481. if (End>Menu_Ban_Total[id])
  1482. End=Menu_Ban_Total[id];
  1483. get_pcvar_string (cvar_Flags,Flags,charsmax(Flags));
  1484. strtolower(Flags);
  1485. is_flagged = false;
  1486. len = formatex(func_Buffer,charsmax(func_Buffer),"\yBan Menu:^n^n");
  1487. for (new i=Start;i<End;i++)
  1488. {
  1489. ids = Menu_Ban_Players[id][i];
  1490. temp_pos++;
  1491. get_user_name(ids,Name,charsmax(Name));
  1492. if (id==ids)
  1493. {
  1494. len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"\y%i. \d%s^t\r(On)^n",temp_pos,Name);
  1495. continue;
  1496. }
  1497. for (new j=0;j<strlen(Flags);j++)
  1498. if ((isalpha(Flags[j]))&&(get_user_flags(ids) & power(2,(Flags[j]-97))))
  1499. {
  1500. is_flagged = true;
  1501. break;
  1502. }
  1503. if (is_flagged)
  1504. {
  1505. len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"\y%i. \d%s^t\r(Megjelolve)^n",temp_pos,Name);
  1506. is_flagged = false;
  1507. }
  1508. else
  1509. {
  1510. len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"\y%i. \w%s^n",temp_pos,Name);
  1511. Keys |= (1<<temp_pos-1);
  1512. }
  1513. }
  1514. switch (Menu_Ban_BanType[id])
  1515. {
  1516. case 0: len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"^n\y7. \wBanTipus: \dAUTO^n");
  1517. case 1: len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"^n\y7. \wBanTipus: \wSTEAMID^n");
  1518. case 2: len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"^n\y7. \wBanTipus: \wIP^n");
  1519. case 3: len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"^n\y7. \wBanTipus: \wNEV^n");
  1520. }
  1521. if (!Menu_Ban_Duration[id])
  1522. len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"\y8. \wIdotartam: \dOrok^n^n");
  1523. else
  1524. len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"\y8. \wIdotartam: \w%s^n^n",STR_Menu_Ban_Duration[id]);
  1525. if (End!=Menu_Ban_Total[id])
  1526. {
  1527. len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"\y9. \wKovetkezo^n");
  1528. Keys |= MENU_KEY_9;
  1529. }
  1530. len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"\y0. \w%s^n",Start?"Vissza":"Kilepes");
  1531. show_menu(id,Keys,func_Buffer,-1,"Ban Menu");
  1532. return PLUGIN_HANDLED
  1533. }
  1534.  
  1535. public CmdUNBANMENU(id,level,cid)
  1536. {
  1537. if (!cmd_access(id,level,cid,1,false))
  1538. return PLUGIN_HANDLED
  1539. Menu_Unban_pos[id] = 0;
  1540. Menu_Unban_Display(id,Menu_Unban_pos[id]);
  1541. return PLUGIN_HANDLED
  1542. }
  1543.  
  1544. public Menu_Unban_Keys(id,key)
  1545. {
  1546. switch (key)
  1547. {
  1548. case 9:
  1549. {
  1550. if (Menu_Unban_pos[id])
  1551. Menu_Unban_Display(id,--Menu_Unban_pos[id])
  1552. else
  1553. Menu_Unban_pos[id] = 0;
  1554. return PLUGIN_HANDLED
  1555. }
  1556. case 8: Menu_Unban_Display(id,++Menu_Unban_pos[id]);
  1557. default:
  1558. {
  1559. if(Menu_Unban_Time[id]<LastBanTime<=get_gametime())
  1560. {
  1561. client_print(id,print_chat,"[UltimateBans] Sajnaljuk, de a BannLista regota nem lett Frissitve. Probald Ujra.");
  1562. Menu_Unban_pos[id] = 0;
  1563. Menu_Unban_Display(id,Menu_Unban_pos[id]);
  1564. return PLUGIN_HANDLED
  1565. }
  1566. static DATA[BanInfo];
  1567. handle_unban_menu_call[id] = true;
  1568. ArrayGetArray(banlist_array,TotalBans-1-Menu_Unban_pos[id]*6-key,DATA);
  1569. if (equali(DATA[bantype],"STEAMID",7))
  1570. client_cmd(id,"amx_unban ^"%s^" ^"STEAMID^"",DATA[target_authid]);
  1571. else if (equali(DATA[bantype],"IP",2))
  1572. client_cmd(id,"amx_unban ^"%s^" ^"IP^"",DATA[target_ip]);
  1573. else if (equali(DATA[bantype],"NAME",4))
  1574. client_cmd(id,"amx_unban ^"%s^" ^"NEV^"",DATA[target_name]);
  1575. }
  1576. }
  1577. return PLUGIN_HANDLED
  1578. }
  1579.  
  1580. Menu_Unban_Display(id,pos)
  1581. {
  1582. if (!TotalBans)
  1583. {
  1584. client_print(id,print_chat,"[UltimateBans] Nem talalhatok Bannolasi Bejegyzesek a Szerver adatbazisaban");
  1585. return PLUGIN_HANDLED
  1586. }
  1587. static Keys,len,Start,End,temp_pos,func_Buffer[512],DATA[BanInfo];
  1588. temp_pos=0,Keys=MENU_KEY_0;
  1589. Start = TotalBans-1-pos*6;
  1590. if (Start<0)
  1591. return PLUGIN_HANDLED
  1592. if (0<=Start<=5)
  1593. End = 0;
  1594. else
  1595. End = Start-5;
  1596. len = formatex(func_Buffer,charsmax(func_Buffer),"\yUnban Menu:^n^n\yMegjegyzes: \wBovebb Informacio a^n Kitiltott Jatekosrol, Ird be a Konzolba:^n \yamx_queryban \w<celpont> \r<tipus>^n^n");
  1597. for (new i=Start;i>=End;i--)
  1598. {
  1599. ArrayGetArray(banlist_array,i,DATA);
  1600. temp_pos++;
  1601. if (equali(DATA[target_name],"<null>"))
  1602. {
  1603. if (equali(DATA[bantype],"STEAMID",7))
  1604. len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"\y%i.^t\w%s^t\r[STEAMID]^n",temp_pos,DATA[target_authid]);
  1605. else
  1606. len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"\y%i.^t\w%s^t\r[IP]^n",temp_pos,DATA[target_ip]);
  1607. }
  1608. else
  1609. {
  1610. if (equali(DATA[bantype],"STEAMID",7))
  1611. len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"\y%i.^t\w%s^t\r[STEAMID]^t\d( %s )^n",temp_pos,DATA[target_authid],DATA[target_name]);
  1612. else if (equali(DATA[bantype],"IP",2))
  1613. len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"\y%i.^t\w%s^t\r[IP]^t\d( %s )^n",temp_pos,DATA[target_ip],DATA[target_name]);
  1614. else
  1615. len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"\y%i.^t\w%s^t\r[NEV]^n",temp_pos,DATA[target_name]);
  1616. }
  1617. Keys |= (1<<temp_pos-1);
  1618. }
  1619. len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"^n");
  1620. if (End>0)
  1621. {
  1622. len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"\y9. \wKovetkezo^n");
  1623. Keys |= MENU_KEY_9;
  1624. }
  1625. len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"\y0. \w%s^n",(Start==TotalBans-1)?"Kilepes":"Vissza");
  1626. show_menu(id,Keys,func_Buffer,-1,"Unban Menu");
  1627. Menu_Unban_Time[id] = get_gametime();
  1628. return PLUGIN_HANDLED
  1629. }
  1630.  
  1631. public CmdVOTEMENU(id)
  1632. {
  1633. if (!get_pcvar_num(cvar_vote_enable))
  1634. {
  1635. client_print(id,print_chat,"[UltimateBans] A Voteban Menu a Szerver altal letiltva");
  1636. return PLUGIN_HANDLED
  1637. }
  1638. Menu_Ban_pos[id] = 0;
  1639. Menu_Vote_Display(id,Menu_Ban_pos[id]);
  1640. return PLUGIN_HANDLED
  1641. }
  1642.  
  1643. public Menu_Vote_Keys(id,key)
  1644. {
  1645. switch (key)
  1646. {
  1647. case 9:
  1648. {
  1649. if (Menu_Ban_pos[id])
  1650. Menu_Vote_Display(id,--Menu_Ban_pos[id])
  1651. else
  1652. Menu_Ban_pos[id] = 0;
  1653. return PLUGIN_HANDLED
  1654. }
  1655. case 8: Menu_Vote_Display(id,++Menu_Ban_pos[id]);
  1656. default:
  1657. {
  1658. static ids,Float:duration,Req_Votes_Percent,szName[2][64],func_buffer[128];
  1659. if (get_gametime()-LastVoted[id]<get_pcvar_float(cvar_vote_delay))
  1660. {
  1661. client_print(id,print_chat,"[UltimateBans] Varj egy Kicsit mielott ismet Szavaznal");
  1662. return PLUGIN_HANDLED
  1663. }
  1664. ids = Menu_Ban_Players[id][Menu_Ban_pos[id]*6+key];
  1665. if(!is_user_connected(ids))
  1666. {
  1667. client_print(id,print_chat,"[UltimateBans] Sajnaljuk, de a Jatekos mar Lecsatlakozott a Szerverrol");
  1668. Menu_Ban_pos[id] = 0;
  1669. Menu_Vote_Display(id,Menu_Ban_pos[id]);
  1670. return PLUGIN_HANDLED
  1671. }
  1672. if (Votes_Players[id][ids])
  1673. {
  1674. client_print(id,print_chat,"[UltimateBans] Mar szavaztal ennel a Jatekosnal");
  1675. Menu_Vote_Display(id,Menu_Ban_pos[id]);
  1676. return PLUGIN_HANDLED
  1677. }
  1678. Votes_Players[id][ids] = 1;
  1679. get_user_name(id,szName[0],charsmax(szName[]));
  1680. get_user_name(ids,szName[1],charsmax(szName[]));
  1681. formatex(func_buffer,charsmax(func_buffer),"^x01[UltimateBans]^x03 %s^x04 szavazott^x03 %s Bannolasaban",szName[0],szName[1]);
  1682. get_players(player,total);
  1683. for(new i=0;i<total;i++)
  1684. {
  1685. message_begin(MSG_ONE,msgid,{0,0,0},player[i]);
  1686. write_byte(player[i]);
  1687. write_string(func_buffer);
  1688. message_end();
  1689. }
  1690. LastVoted[id] = get_gametime();
  1691. Req_Votes_Percent = floatround(floatmul(get_pcvar_float(cvar_vote_ratio),100.0))-eval_votes(ids);
  1692. if (Req_Votes_Percent<=0)
  1693. {
  1694. duration = get_pcvar_float(cvar_vote_time);
  1695. if (duration<0.0)
  1696. server_cmd("amx_ban #%d ^"60.0^" ^"Szavazas altal Bannolva^" ^"AUTO^"",get_user_userid(ids));
  1697. else if (duration==0.0||duration>9999999.0)
  1698. server_cmd("amx_ban #%d ^"0.0^" ^"Szavazas altal Bannolva^" ^"AUTO^"",get_user_userid(ids));
  1699. else
  1700. server_cmd("amx_ban #%d ^"%f^" ^"Szavazas altal Bannolva^" ^"AUTO^"",get_user_userid(ids),duration);
  1701. }
  1702. else
  1703. client_print(id,print_chat,"[UltimateBans] Meg %i szavazat szukseges %s kibannolasahoz",floatround(floatmul(float(Req_Votes_Percent)/100.0,float(total)),floatround_ceil),szName[1]);
  1704. Menu_Vote_Display(id,Menu_Ban_pos[id]);
  1705. }
  1706. }
  1707. return PLUGIN_HANDLED
  1708. }
  1709.  
  1710. Menu_Vote_Display(id,pos)
  1711. {
  1712. static Keys,len,Start,End,temp_pos,Name[64],bool:is_flagged,func_Buffer[512];
  1713. temp_pos=0,Keys=MENU_KEY_0;
  1714. get_players(Menu_Ban_Players[id],Menu_Ban_Total[id]);
  1715. if (Menu_Ban_Total[id]<get_pcvar_num(cvar_vote_min))
  1716. {
  1717. client_print(id,print_chat,"[UltimateBans] Nincs Eleg Jatekos a Voteban hasznalatahoz");
  1718. return PLUGIN_HANDLED
  1719. }
  1720. Start = pos*8;
  1721. if (Start>Menu_Ban_Total[id])
  1722. return PLUGIN_HANDLED
  1723. if (Start<0)
  1724. Start=0;
  1725. End = Start+8;
  1726. if (End>Menu_Ban_Total[id])
  1727. End=Menu_Ban_Total[id];
  1728. get_pcvar_string (cvar_Flags,Flags,charsmax(Flags));
  1729. strtolower(Flags);
  1730. is_flagged = false;
  1731. len = formatex(func_Buffer,charsmax(func_Buffer),"\yVoteban Menu:^n^n");
  1732. for (new i=Start;i<End;i++)
  1733. {
  1734. ids = Menu_Ban_Players[id][i];
  1735. temp_pos++;
  1736. get_user_name(ids,Name,charsmax(Name));
  1737. if (id==ids)
  1738. {
  1739. len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"\y%i. \d%s^t\y(\rOn\y)^n",temp_pos,Name);
  1740. continue;
  1741. }
  1742. for (new j=0;j<strlen(Flags);j++)
  1743. if ((isalpha(Flags[j]))&&(get_user_flags(ids) & power(2,(Flags[j]-97))))
  1744. {
  1745. is_flagged = true;
  1746. break;
  1747. }
  1748. if (is_flagged)
  1749. {
  1750. len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"\y%i. \d%s^t\y(\rMegjelolve\y)^n",temp_pos,Name);
  1751. is_flagged = false;
  1752. }
  1753. else
  1754. {
  1755. len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"\y%i. \w%s^t\y(\r%i%%\y)^n",temp_pos,Name,eval_votes(ids));
  1756. Keys |= (1<<temp_pos-1);
  1757. }
  1758. }
  1759. len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"^n");
  1760. if (End!=Menu_Ban_Total[id])
  1761. {
  1762. len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"\y9. \wKovetkezo^n");
  1763. Keys |= MENU_KEY_9;
  1764. }
  1765. len += formatex(func_Buffer[len],charsmax(func_Buffer)-len,"\y0. \w%s^n",Start?"Vissza":"Kilepes");
  1766. show_menu(id,Keys,func_Buffer,-1,"Voteban Menu");
  1767. return PLUGIN_HANDLED
  1768. }
  1769.  
  1770. public bad_input(id)
  1771. {
  1772. if (id)
  1773. client_cmd(id,"echo [UltimateBans] Rossz Bemenet");
  1774. else
  1775. server_print("[UltimateBans] Rossz Bemenet");
  1776. }
  1777.  
  1778. public JoinKick(Timeleft[],id)
  1779. {
  1780. if (!equali(Timeleft,"<null>"))
  1781. server_cmd("kick #%d ^"Bannolva lettel errol a Szerverrol. Hatralevo ido: %s. Bovebb Informacioert nezd meg a Konzolt.^"",get_user_userid(id),Timeleft);
  1782. else
  1783. server_cmd("kick #%d ^"Orokre Bannoltak errol a Szerverrol. Bovebb Informacioert nezd meg a Konzolt.^"",get_user_userid(id));
  1784. }
  1785.  
  1786. get_monthdays (months,years=0)
  1787. {
  1788. switch(months)
  1789. {
  1790. case 1: return 31;
  1791. case 2: return ((years%4)?28:29);
  1792. case 3: return 31;
  1793. case 4: return 30;
  1794. case 5: return 31;
  1795. case 6: return 30;
  1796. case 7: return 31;
  1797. case 8: return 31;
  1798. case 9: return 30;
  1799. case 10: return 31;
  1800. case 11: return 30;
  1801. case 12: return 31;
  1802. }
  1803. return 30;
  1804. }
  1805.  
  1806. CheckBan (const input[],const input_type[])
  1807. {
  1808. static DATA[BanInfo],pos,Found,bool:tmp;
  1809. tmp=true,Found=0;
  1810. for (new i=0;i<TotalBans;i++)
  1811. {
  1812. ArrayGetArray(banlist_array,i,DATA);
  1813. if (!equali(DATA[bantype],input_type))
  1814. continue;
  1815. if (equali(input_type,"STEAMID",7))
  1816. {
  1817. if (equali(DATA[target_authid],input))
  1818. {
  1819. if (MODE_LOADBAN)
  1820. Found++;
  1821. else
  1822. return i;
  1823. }
  1824. }
  1825. else if (equali(input_type,"IP",2))
  1826. {
  1827. if (MODE_LOADBAN)
  1828. {
  1829. if (equal(DATA[target_ip],input))
  1830. Found++;
  1831. }
  1832. else if (MODE_UNBAN)
  1833. {
  1834. if (equal(DATA[target_ip],input))
  1835. return i;
  1836. }
  1837. else
  1838. {
  1839. if (CheckIP(DATA[target_ip],input))
  1840. {
  1841. if (MODE_ADDBAN)
  1842. return i;
  1843. else
  1844. Found++;
  1845. }
  1846. }
  1847. }
  1848. else if (equali(input_type,"NAME",4))
  1849. {
  1850. if (MODE_LOADBAN)
  1851. {
  1852. if (equal(DATA[target_name],input))
  1853. Found++;
  1854. }
  1855. else if (MODE_UNBAN)
  1856. {
  1857. if (equal(DATA[target_name],input))
  1858. return i;
  1859. }
  1860. else
  1861. {
  1862. if (equali(DATA[target_name],input,strlen(DATA[target_name])))
  1863. {
  1864. if (MODE_ADDBAN)
  1865. return i;
  1866. else
  1867. Found++;
  1868. }
  1869. }
  1870. }
  1871. if ((Found==1)&&(tmp))
  1872. {
  1873. pos = i;
  1874. tmp = false;
  1875. }
  1876. if (Found>1)
  1877. return -1;
  1878. }
  1879. if (Found==1)
  1880. return pos;
  1881. return -2;
  1882. }
  1883.  
  1884. CheckIP (const param1[],const param2[])
  1885. {
  1886. if (equal(param1,param2))
  1887. return 1;
  1888. static Range[16],IP[16],p1[3],p2[3],p3[3],p4[3],r1[3],r2[3],r3[3],r4[3];
  1889. copy(Range,charsmax(Range),param1);
  1890. copy(IP,charsmax(IP),param2);
  1891. replace_all(Range,charsmax(Range),"."," ");
  1892. replace_all(IP,charsmax(IP),"."," ");
  1893. parse(Range,r1,charsmax(r1),r2,charsmax(r2),r3,charsmax(r3),r4,charsmax(r4));
  1894. parse(IP,p1,charsmax(p1),p2,charsmax(p2),p3,charsmax(p3),p4,charsmax(p4));
  1895. if (!str_to_num(r4))
  1896. {
  1897. if (equal(p1,r1)&&equal(p2,r2)&&equal(p3,r3))
  1898. return 2;
  1899. if (!str_to_num(r3))
  1900. {
  1901. if (equal(p1,r1)&&equal(p2,r2))
  1902. return 2;
  1903. if (!str_to_num(r2))
  1904. if (equal(p1,r1))
  1905. return 2;
  1906. }
  1907. }
  1908. return 0;
  1909. }
  1910.  
  1911. get_ban_timeleft (const raw_input[],output[]="<null>",len2=-1)
  1912. {
  1913. static NUM_NOW_hours,input[32],NUM_NOW_minutes,NUM_NOW_seconds,NUM_NOW_days,NUM_NOW_months,NUM_NOW_years,NOW_totalminutes,NUM_UNBAN_hours,NUM_UNBAN_minutes,NUM_UNBAN_seconds,NUM_UNBAN_days,NUM_UNBAN_months,NUM_UNBAN_years;
  1914. static STR_NOW_hours[5],STR_NOW_minutes[5],STR_NOW_seconds[5],STR_NOW_days[5],STR_NOW_months[5],STR_NOW_years[7],STR_UNBAN_hours[5],STR_UNBAN_minutes[5],STR_UNBAN_seconds[5],STR_UNBAN_days[5],STR_UNBAN_months[5],STR_UNBAN_years[7];
  1915. static UNBAN_totalminutes,days_left,hours_left,minutes_left,seconds_left,REM_totalminutes,len;
  1916. copy(input,charsmax(input),raw_input);
  1917. replace_all(input,charsmax(input),":"," ");
  1918. replace_all(input,charsmax(input),"/"," ");
  1919. format_time(STR_NOW_hours,charsmax(STR_NOW_hours),"%H");
  1920. format_time(STR_NOW_minutes,charsmax(STR_NOW_minutes),"%M");
  1921. format_time(STR_NOW_seconds,charsmax(STR_NOW_seconds),"%S");
  1922. format_time(STR_NOW_days,charsmax(STR_NOW_days),"%d");
  1923. format_time(STR_NOW_months,charsmax(STR_NOW_months),"%m");
  1924. format_time(STR_NOW_years,charsmax(STR_NOW_years),"%Y");
  1925. NUM_NOW_hours = str_to_num(STR_NOW_hours);
  1926. NUM_NOW_minutes = str_to_num(STR_NOW_minutes);
  1927. NUM_NOW_seconds = str_to_num(STR_NOW_seconds);
  1928. NUM_NOW_days = str_to_num(STR_NOW_days);
  1929. NUM_NOW_months = str_to_num(STR_NOW_months);
  1930. NUM_NOW_years = str_to_num(STR_NOW_years);
  1931. parse(input,STR_UNBAN_hours,charsmax(STR_UNBAN_hours),STR_UNBAN_minutes,charsmax(STR_UNBAN_minutes),STR_UNBAN_seconds,charsmax(STR_UNBAN_seconds),STR_UNBAN_days,charsmax(STR_UNBAN_days),STR_UNBAN_months,charsmax(STR_UNBAN_months),STR_UNBAN_years,charsmax(STR_UNBAN_years));
  1932. NUM_UNBAN_hours = str_to_num(STR_UNBAN_hours);
  1933. NUM_UNBAN_minutes = str_to_num(STR_UNBAN_minutes);
  1934. NUM_UNBAN_seconds = str_to_num(STR_UNBAN_seconds);
  1935. NUM_UNBAN_days = str_to_num(STR_UNBAN_days);
  1936. NUM_UNBAN_months = str_to_num(STR_UNBAN_months);
  1937. NUM_UNBAN_years = str_to_num(STR_UNBAN_years);
  1938. if (NUM_UNBAN_years<NUM_NOW_years
  1939. ||NUM_UNBAN_years==NUM_NOW_years&&NUM_UNBAN_months<NUM_NOW_months
  1940. ||NUM_UNBAN_years==NUM_NOW_years&&NUM_UNBAN_months==NUM_NOW_months&&NUM_UNBAN_days<NUM_NOW_days
  1941. ||NUM_UNBAN_years==NUM_NOW_years&&NUM_UNBAN_months==NUM_NOW_months&&NUM_UNBAN_days==NUM_NOW_days&&NUM_UNBAN_hours<NUM_NOW_hours
  1942. ||NUM_UNBAN_years==NUM_NOW_years&&NUM_UNBAN_months==NUM_NOW_months&&NUM_UNBAN_days==NUM_NOW_days&&NUM_UNBAN_hours==NUM_NOW_hours&&NUM_UNBAN_minutes<NUM_NOW_minutes
  1943. ||NUM_UNBAN_years==NUM_NOW_years&&NUM_UNBAN_months==NUM_NOW_months&&NUM_UNBAN_days==NUM_NOW_days&&NUM_UNBAN_hours==NUM_NOW_hours&&NUM_UNBAN_minutes==NUM_NOW_minutes&&NUM_UNBAN_seconds<=NUM_NOW_seconds)
  1944. return 0;
  1945. if (len2==-1)
  1946. return 1;
  1947. for (new z=0;z<=len2;z++)
  1948. output[z] = 0;
  1949. if (NUM_NOW_months==1||NUM_NOW_months==2)
  1950. {
  1951. NUM_NOW_months += 12;
  1952. NUM_NOW_years--;
  1953. }
  1954. if (NUM_UNBAN_months==1||NUM_UNBAN_months==2)
  1955. {
  1956. NUM_UNBAN_months += 12;
  1957. NUM_UNBAN_years--;
  1958. }
  1959. days_left =(floatround(365.0*NUM_UNBAN_years,floatround_floor)-floatround(365.0*NUM_NOW_years,floatround_floor))
  1960. +(floatround(NUM_UNBAN_years/4.0,floatround_floor)-floatround(NUM_NOW_years/4.0,floatround_floor))
  1961. -(floatround(NUM_UNBAN_years/100.0,floatround_floor)-floatround(NUM_NOW_years/100.0,floatround_floor))
  1962. +(floatround(NUM_UNBAN_years/400.0,floatround_floor)-floatround(NUM_NOW_years/400.0,floatround_floor))
  1963. +(NUM_UNBAN_days-NUM_NOW_days)
  1964. +(floatround(((153.0*NUM_UNBAN_months)+8.0)/5.0,floatround_floor)-floatround(((153.0*NUM_NOW_months)+8.0)/5.0,floatround_floor));
  1965. NOW_totalminutes = (60*NUM_NOW_hours)+NUM_NOW_minutes;
  1966. UNBAN_totalminutes = (60*NUM_UNBAN_hours)+NUM_UNBAN_minutes;
  1967. if (UNBAN_totalminutes>=NOW_totalminutes)
  1968. REM_totalminutes = UNBAN_totalminutes-NOW_totalminutes;
  1969. else
  1970. {
  1971. REM_totalminutes = 1440-(NOW_totalminutes-UNBAN_totalminutes);
  1972. days_left--;
  1973. }
  1974. hours_left = REM_totalminutes/60;
  1975. minutes_left = REM_totalminutes-(hours_left*60);
  1976. if (NUM_UNBAN_seconds-NUM_NOW_seconds>0)
  1977. seconds_left = NUM_UNBAN_seconds-NUM_NOW_seconds;
  1978. else
  1979. {
  1980. seconds_left = 60-(NUM_NOW_seconds-NUM_UNBAN_seconds);
  1981. if (minutes_left)
  1982. minutes_left--;
  1983. else
  1984. {
  1985. minutes_left = 59;
  1986. if (hours_left)
  1987. hours_left--;
  1988. else
  1989. {
  1990. hours_left = 23;
  1991. days_left--;
  1992. }
  1993. }
  1994. }
  1995. len = 0;
  1996. if (days_left)
  1997. len += formatex(output[len],len2-len,"%d Nap ",days_left);
  1998. if (hours_left)
  1999. len += formatex(output[len],len2-len,"%i Ora ",hours_left);
  2000. if (minutes_left)
  2001. len += formatex(output[len],len2-len,"%i Perc ",minutes_left);
  2002. if (seconds_left)
  2003. len += formatex(output[len],len2-len,"%i Masodperc",seconds_left);
  2004. return 1;
  2005. }
  2006.  
  2007. public ChatPrint(const message[])
  2008. {
  2009. get_players(player,total);
  2010. for(new i=0;i<total;i++)
  2011. {
  2012. ids = player[i];
  2013. message_begin(MSG_ONE,msgid,{0,0,0},ids);
  2014. write_byte(ids);
  2015. write_string(message);
  2016. message_end();
  2017. }
  2018. }
  2019.  
  2020. public DelayedLog(const message[])
  2021. log_to_file("addons/amxmodx/logs/UB_Logs.log",message);
  2022.  
  2023. PrintBanInfo(DATA[],id=0,Timeleft[]="<null>")
  2024. {
  2025. if (id)
  2026. {
  2027. client_cmd(id,"echo [UltimateBans] BanTipus - %s",DATA[bantype]);
  2028. if (!equali(DATA[target_authid],"<null>",6))
  2029. client_cmd(id,"echo [UltimateBans] Admin ID - %s",DATA[target_authid]);
  2030. if (!equali(DATA[target_ip],"<null>",6))
  2031. client_cmd(id,"echo [UltimateBans] Admin IP - %s",DATA[target_ip]);
  2032. if (!equali(DATA[target_name],"<null>",6))
  2033. client_cmd(id,"echo [UltimateBans] Admin Neve - %s",DATA[target_name]);
  2034. client_cmd(id,"echo [UltimateBans] Ban Ideje - %s",DATA[bantime]);
  2035. if (!equali(DATA[unbantime],"<null>",6))
  2036. client_cmd(id,"echo [UltimateBans] Unban Ideje - %s",DATA[unbantime]);
  2037. else
  2038. client_cmd(id,"echo [UltimateBans] Unban Ideje - Soha ( Orok Ban )");
  2039. if (!equali(Timeleft,"<null>",6))
  2040. client_cmd(id,"echo [UltimateBans] Lejarata - %s",Timeleft);
  2041. if (!equali(DATA[banner_name],"<null>",6))
  2042. {
  2043. if (!equali(DATA[banner_name],"RCON/Server",11))
  2044. {
  2045. client_cmd(id,"echo [UltimateBans] Bannolt ID - %s",DATA[banner_authid]);
  2046. client_cmd(id,"echo [UltimateBans] Bannolt IP - %s",DATA[banner_ip]);
  2047. }
  2048. client_cmd(id,"echo [UltimateBans] Bannolt Neve - %s",DATA[banner_name]);
  2049. }
  2050. if (!equali(DATA[reason],"<null>",6))
  2051. client_cmd(id,"echo [UltimateBans] Ok- %s",DATA[reason]);
  2052. client_cmd(id,"echo [UltimateBans] -------------------------------");
  2053. }
  2054. else
  2055. {
  2056. server_print("[UltimateBans] BanTipus - %s",DATA[bantype]);
  2057. if (!equali(DATA[target_authid],"<null>",6))
  2058. server_print("[UltimateBans] Admin ID - %s",DATA[target_authid]);
  2059. if (!equali(DATA[target_ip],"<null>",6))
  2060. server_print("[UltimateBans] Admin IP - %s",DATA[target_ip]);
  2061. if (!equali(DATA[target_name],"<null>",6))
  2062. server_print("[UltimateBans] Admin Neve - %s",DATA[target_name]);
  2063. server_print("[UltimateBans] Ban Ideje - %s",DATA[bantime]);
  2064. if (!equali(DATA[unbantime],"<null>",6))
  2065. server_print("[UltimateBans] UnBan Ideje - %s",DATA[unbantime]);
  2066. if (!equali(DATA[banner_name],"<null>",6))
  2067. {
  2068. if (!equali(DATA[banner_name],"RCON/Server",11))
  2069. {
  2070. server_print("[UltimateBans] Bannolt ID - %s",DATA[banner_authid]);
  2071. server_print("[UltimateBans] Bannolt IP - %s",DATA[banner_ip]);
  2072. }
  2073. server_print("[UltimateBans] Bannolt Neve - %s",DATA[banner_name]);
  2074. }
  2075. if (!equali(DATA[reason],"<null>",6))
  2076. server_print("[UltimateBans] Ok - %s",DATA[reason]);
  2077. server_print("[UltimateBans] -------------------------------");
  2078. }
  2079. }
  2080.  
  2081. public Menu_SetDuration(id)
  2082. {
  2083. static len,dot,count_digits,seconds,minutes,hours,days,ARG_Menu_Duration[128];
  2084. len=0,dot=0,count_digits=1,minutes=0,seconds=0,hours=0,days=0;
  2085. read_args(ARG_Menu_Duration,charsmax(ARG_Menu_Duration));
  2086. remove_quotes(ARG_Menu_Duration);
  2087. trim(ARG_Menu_Duration);
  2088. if (!strlen(ARG_Menu_Duration))
  2089. {
  2090. Menu_Ban_Display(id,Menu_Ban_pos[id]);
  2091. return PLUGIN_HANDLED
  2092. }
  2093. if (!isdigit(ARG_Menu_Duration[0]))
  2094. {
  2095. client_print(id,print_chat,"[UltimateBans] Rossz Bemenet");
  2096. Menu_Ban_Display(id,Menu_Ban_pos[id]);
  2097. return PLUGIN_HANDLED
  2098. }
  2099. for (new i=1;i<strlen(ARG_Menu_Duration);i++)
  2100. {
  2101. if (ARG_Menu_Duration[i]=='.')
  2102. {
  2103. if (++dot>1)
  2104. {
  2105. client_print(id,print_chat,"[UltimateBans] Rossz Bemenet");
  2106. Menu_Ban_Display(id,Menu_Ban_pos[id]);
  2107. return PLUGIN_HANDLED
  2108. }
  2109. }
  2110. else if (!isdigit(ARG_Menu_Duration[i]))
  2111. {
  2112. client_print(id,print_chat,"[UltimateBans] Rossz Bemenet");
  2113. Menu_Ban_Display(id,Menu_Ban_pos[id]);
  2114. return PLUGIN_HANDLED
  2115. }
  2116. else if (!dot)
  2117. count_digits++;
  2118. }
  2119. if (count_digits>8)
  2120. {
  2121. Menu_Ban_Duration[id] = 0.0;
  2122. copy(STR_Menu_Ban_Duration[id],127,"Permanent");
  2123. return PLUGIN_HANDLED
  2124. }
  2125. else
  2126. Menu_Ban_Duration[id] = str_to_float(ARG_Menu_Duration);
  2127. minutes = floatround(Menu_Ban_Duration[id],floatround_floor);
  2128. seconds = floatround(floatfract(Menu_Ban_Duration[id])*60,floatround_floor);
  2129. while(minutes>=60)
  2130. {
  2131. minutes -= 60;
  2132. hours++;
  2133. }
  2134. while(hours>=24)
  2135. {
  2136. hours -= 24;
  2137. days++;
  2138. }
  2139. if (Menu_Ban_Duration[id])
  2140. {
  2141. if (days)
  2142. len += formatex(STR_Menu_Ban_Duration[id][len],127-len,"%d Nap ",days);
  2143. if (hours)
  2144. len += formatex(STR_Menu_Ban_Duration[id][len],127-len,"%i Ora ",hours);
  2145. if (minutes)
  2146. len += formatex(STR_Menu_Ban_Duration[id][len],127-len,"%i Perc ",minutes);
  2147. if (seconds)
  2148. len += formatex(STR_Menu_Ban_Duration[id][len],127-len,"%i Masodperc",seconds);
  2149. }
  2150. else
  2151. {
  2152. Menu_Ban_Duration[id] = 0.0;
  2153. copy(STR_Menu_Ban_Duration[id],127,"Permanent");
  2154. }
  2155. Menu_Ban_Display(id,Menu_Ban_pos[id]);
  2156. return PLUGIN_HANDLED
  2157. }
  2158.  
  2159. public Menu_SetReason(id)
  2160. {
  2161. static ARG_Menu_Reason[128],AuthID[32];
  2162. ids = Menu_Ban_Target[id];
  2163. if(!is_user_connected(ids))
  2164. {
  2165. client_print(id,print_chat,"[UltimateBans] Sajnaljuk, de a Jatekos mar Lecsatlakozott a Szerverrol!");
  2166. Menu_Ban_Display(id,Menu_Ban_pos[id]);
  2167. return PLUGIN_HANDLED
  2168. }
  2169. read_args(ARG_Menu_Reason,charsmax(ARG_Menu_Reason));
  2170. remove_quotes(ARG_Menu_Reason);
  2171. trim(ARG_Menu_Reason);
  2172. handle_ban_menu_call[id] = true;
  2173. switch (Menu_Ban_BanType[id])
  2174. {
  2175. case 0: client_cmd(id,"amx_ban #%i ^"%f^" ^"%s^" ^"AUTO^"",get_user_userid(ids),Menu_Ban_Duration[id],ARG_Menu_Reason);
  2176. case 1:
  2177. {
  2178. get_user_authid(ids,AuthID,charsmax(AuthID));
  2179. if (IsValidAUTHID(AuthID))
  2180. client_cmd(id,"amx_ban #%i ^"%f^" ^"%s^" ^"STEAMID^"",get_user_userid(ids),Menu_Ban_Duration[id],ARG_Menu_Reason);
  2181. else
  2182. {
  2183. client_print(id,print_chat,"[UltimateBans] Az AuthID Nem Valos");
  2184. handle_ban_menu_call[id] = false;
  2185. Menu_Ban_Display(id,Menu_Ban_pos[id]);
  2186. return PLUGIN_HANDLED
  2187. }
  2188. }
  2189. case 2: client_cmd(id,"amx_ban #%i ^"%f^" ^"%s^" ^"IP^"",get_user_userid(ids),Menu_Ban_Duration[id],ARG_Menu_Reason);
  2190. case 3: client_cmd(id,"amx_ban #%i ^"%f^" ^"%s^" ^"NEV^"",get_user_userid(ids),Menu_Ban_Duration[id],ARG_Menu_Reason);
  2191. }
  2192. Menu_Ban_Reset(id);
  2193. Menu_Ban_Display(id,Menu_Ban_pos[id]);
  2194. return PLUGIN_HANDLED
  2195. }
  2196.  
  2197. public Menu_Ban_Reset(id)
  2198. {
  2199. Menu_Ban_pos[id] = 0;
  2200. Menu_Ban_Duration[id] = 0.0;
  2201. for (new i=0;i<128;i++)
  2202. STR_Menu_Ban_Duration[id][i]=0;
  2203. Menu_Ban_BanType[id] = 0;
  2204. }
  2205.  
  2206. stock eval_votes(ids)
  2207. {
  2208. new id,tmp_count;
  2209. get_players(player,total);
  2210. for (new i=0;i<total;i++)
  2211. {
  2212. id = player[i];
  2213. if (Votes_Players[id][ids])
  2214. tmp_count++;
  2215. }
  2216. return floatround(floatmul(float(tmp_count)/float(total),100.0));
  2217. }