Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.15 KB | None | 0 0
  1. /* AMX Mod X script.
  2. *
  3. * Enhanced Map Searching (amx_ejl_searchmaps.sma)
  4. * Copyright (C) 2003-2004 Eric Lidman / jtp10181
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. *
  20. * In addition, as a special exception, the author gives permission to
  21. * link the code of this program with the Half-Life Game Engine ("HL
  22. * Engine") and Modified Game Libraries ("MODs") developed by Valve,
  23. * L.L.C ("Valve"). You must obey the GNU General Public License in all
  24. * respects for all of the code used other than the HL Engine and MODs
  25. * from Valve. If you modify this file, you may extend this exception
  26. * to your version of the file, but you are not obligated to do so. If
  27. * you do not wish to do so, delete this exception statement from your
  28. * version.
  29. *
  30. ****************************************************************************
  31. *
  32. * Version 1.6 - 07/24/2005
  33. *
  34. * Original by Eric Lidman aka "Ludwig van" <ejlmozart@hotmail.com>
  35. * Homepage: http://lidmanmusic.com/cs/plugins.html
  36. *
  37. * Upgraded to STEAM and ported to AMXx by: jtp10181 <jtp@jtpage.net>
  38. * Homepage: http://www.jtpage.net
  39. *
  40. ****************************************************************************
  41. *
  42. * This plugin allows users to search through all the maps on your server. The
  43. * plugin can either search through the servers maps folder and lists them
  44. * from there, or it can read from a file. This can be set as a compile time
  45. * define below. To cut down on the lag caused by file actions, the maps are
  46. * loaded into memory at the start of each map and searched from there while
  47. * games are in progress. Thus if you add a map to your server, it wont show
  48. * up in the search until you load the next map. If you are loading the map
  49. * list from a file a map will not show up until it is added to the file being
  50. * read. This plugin also has an automatic chat response that will tell people
  51. * what map is currently playing based on some common questions that are asked.
  52. *
  53. * Commands:
  54. *
  55. * mapsearch <target> returns up to 20 maps in the HUD containing the search target
  56. *
  57. * listmaps returns all maps in the console paginated amx_help style
  58. *
  59. * listmaps <target> returns all maps containing search target in the
  60. * console amx_help style.
  61. *
  62. * listmapsm returns all maps in a MOTD popup paginated amx_help style
  63. *
  64. * listmapsm <target> returns all maps containing search target in a
  65. * MOTD popup window.
  66. *
  67. * ***IF LISTCYCLE mode is enabled below***
  68. *
  69. * listcycle returns mapcycle in the console paginated amx_help style
  70. *
  71. * listcycle <target> returns mapcycle maps containing search target in the
  72. * console amx_help style.
  73. *
  74. * listcyclem returns mapcycle in a MOTD popup paginated amx_help style
  75. *
  76. * listcyclem <target> returns mapcycle maps containing search target in a
  77. * MOTD popup window.
  78. *
  79. *
  80. * Changelog:
  81. *
  82. * v1.6 - JTP10181 - 07/24/05
  83. * - Fixed bug causing it to not compile on loadfile mode
  84. * - Merged in multi-language code from faluco (Thanks!)
  85. *
  86. * v1.5 - JTP10181 - 10/17/04
  87. * - Fixed readdir code so it works on linux (thanks PM)
  88. * - Small tweaks to code to fix some dumb things I did
  89. *
  90. * v1.4 - JTP10181 - 07/22/04
  91. * - Added new compile option to enable listcycle to list the current mapcycle
  92. * - Fixed a few random things that I was doing incorrectly
  93. * - Condensed the "admin" command function into one function
  94. *
  95. * v1.3 - JTP10181 - 07/02/04
  96. * - Added some new code to catch "say listmaps" and block it from
  97. * being used by other plugins (Deags Map Manager)
  98. * - Added MOTD popup support in the form of "listmapsm"
  99. * - Added some basic dupe checking where it loads the maps in from a dir
  100. * - Added function to sort the array with the maps
  101. * - Added advanced dupe checking into the sorting function
  102. *
  103. * v1.2.2 - JTP10181 - 06/08/04
  104. * - Tweaked the help info for the commands a little
  105. * - Fixed some hardcoded paths I left in on accident
  106. *
  107. * v1.2.1 - JTP10181
  108. * - Changed all printed messages to use the [AMXX] tag instead of [AMX]
  109. *
  110. * v1.2 - JTP10181
  111. * - Added ability to read from a file as a compile option
  112. * - Fixes for steam (.ztmp files ignored)
  113. * - Added listmaps output to console amx_help style (thanks tcquest78for amx_help code)
  114. * - Added a "currentmap" response to the say handler, people are always asking this.
  115. * - Added lots of other common triggers to a handle say catch so anyone trying to find
  116. * maps should not have a problem
  117. *
  118. * Below v1.2 was maintained by Eric Lidman
  119. *
  120. ***************************************************************************/
  121.  
  122. #include <amxmodx>
  123. #include <amxmisc>
  124.  
  125. #define MAX_MAPS 2000 // Max number of maps the plugin will handle
  126. #define MAPAMOUNT 36 // Number of maps per page (3 on a line)
  127.  
  128. // Number of maps per MOTD page (4 on a line)
  129. // Setting this higher than 56 will cause some output to be cropped
  130. // due to limitations of the STEAM MOTD boxes.
  131. #define MAPAMOUNT_MOTD 56
  132.  
  133. /* Set to 0 to read the maps from the maps folder
  134. * Set to 1 to attempt to read from a file in the following order:
  135. * <configdir>/map_manage/allmaps.txt
  136. * <configdir>/map_manage/mapchoice.ini
  137. * mapcycle.txt
  138. *
  139. * NOTE: In testing reading the directory had issues with LINUX server
  140. * where it was reading each map multiples times into the maps array.
  141. */
  142. #define LOADFILE 1
  143.  
  144. //Set to 1 to enable listcycle mode which adds an extra command
  145. //to display and search the current mapcycle.
  146. #define LISTCYCLE 0
  147.  
  148. // Max number of mapcycle maps the plugin will handle
  149. #define MAX_CYCLE_MAPS 64
  150.  
  151. /***********************************************************************************
  152. * *
  153. * *END* customizable section of code. other changes can be done with the cvars * *
  154. * *
  155. ************************************************************************************/
  156.  
  157. new totalmaps
  158. new T_LMaps[MAX_MAPS][32]
  159.  
  160. #if LISTCYCLE
  161. new totalmapsc
  162. new T_LCycle[MAX_CYCLE_MAPS][32]
  163. #endif
  164.  
  165. public plugin_init() {
  166. register_plugin("Enhanced Map Searching","1.6","EJL/JTP10181")
  167. register_dictionary("amx_ejl_searchmaps.txt")
  168. register_clcmd("say","HandleSay")
  169. register_clcmd("mapsearch","admin_mapsearch",0,"<search> - Lists available maps in HUD with search target in their name")
  170. register_concmd("listmaps","admin_listmaps",0,"[search] [start] - Lists/Searches available maps in console")
  171. register_clcmd("listmapsm","admin_listmaps",0,"[search] [start] - Lists/Searches available maps in MOTD popup")
  172. register_clcmd("/maps","admin_listmaps",0,"[search] [start] - Lists/Searches available maps in MOTD popup")
  173. #if LISTCYCLE
  174. register_concmd("listcycle","admin_listmaps",0,"[search] [start] - Lists/Searches current mapcycle in console")
  175. register_clcmd("listcyclem","admin_listmaps",0,"[search] [start] - Lists/Searches current mapcycle in MOTD popup")
  176. register_clcmd("/maps","admin_listmaps",0,"[search] [start] - Lists/Searches current mapcycle in MOTD popup")
  177. #endif
  178. register_clcmd("say listmaps","say_listmaps",0,"[search] [start] - Lists/Searches available maps in console")
  179.  
  180. get_listing()
  181. sort_maps()
  182. }
  183.  
  184. public HandleSay(id) {
  185. new Speech[192]
  186. read_args(Speech,192)
  187. remove_quotes(Speech)
  188. if(equal(Speech,"mapsearch",9)){
  189. search_engine(id,Speech[10])
  190. }
  191. else if(equal(Speech,"find",4)){
  192. search_engine(id,Speech[5])
  193. }
  194. else if(equal(Speech,"findmaps",8)){
  195. search_engine(id,Speech[9])
  196. }
  197. else if(equal(Speech,"searchmaps",10)){
  198. search_engine(id,Speech[11])
  199. }
  200. else if(equal(Speech,"maplist",7)){
  201. search_engine(id,Speech[8])
  202. }
  203. else if(equal(Speech,"listmapsm",9)){
  204. client_print(id, print_chat, "%L", id, "DISP_IN_MOTD")
  205. new cmd[32],arg1[32],arg2[32]
  206. parse(Speech,cmd,31,arg1,31,arg2,31)
  207. listmaps_motd_engine(id,arg1,arg2,cmd,T_LMaps,totalmaps)
  208. }
  209. else if(equal(Speech,"listmaps",8)){
  210. client_print(id, print_chat, "%L", id, "DISP_IN_CONS")
  211. new cmd[32],arg1[32],arg2[32]
  212. parse(Speech,cmd,31,arg1,31,arg2,31)
  213. listmaps_engine(id,arg1,arg2,cmd,T_LMaps,totalmaps)
  214. }
  215. #if LISTCYCLE
  216. else if(equal(Speech,"listcyclem",10)){
  217. client_print(id, print_chat, "%L", id, "DISP_CYCLE_MOTD")
  218. new cmd[32],arg1[32],arg2[32]
  219. parse(Speech,cmd,31,arg1,31,arg2,31)
  220. listmaps_motd_engine(id,arg1,arg2,cmd,T_LCycle,totalmapsc)
  221. }
  222. else if(equal(Speech,"listcycle",9)){
  223. client_print(id, print_chat, "%L", id, "DISP_CYCLE_CONS")
  224. new cmd[32],arg1[32],arg2[32]
  225. parse(Speech,cmd,31,arg1,31,arg2,31)
  226. listmaps_engine(id,arg1,arg2,cmd,T_LCycle,totalmapsc)
  227. }
  228. #endif
  229. else if(equal(Speech,"current map",11) || equal(Speech,"currentmap",10) || equal(Speech,"thismap",7) || (containi(Speech, "this map") != -1) || (containi(Speech, "map is this") != -1)){
  230. new mapname[32]
  231. get_mapname(mapname,31)
  232. client_print(id, print_chat, "%L", id, "EJL_CUR_MAP", mapname)
  233. }
  234. return PLUGIN_CONTINUE
  235. }
  236.  
  237. public admin_mapsearch(id) {
  238. new argx[32]
  239. read_argv(1,argx,32)
  240. search_engine(id,argx)
  241. return PLUGIN_HANDLED
  242. }
  243.  
  244. public admin_listmaps(id) {
  245. new cmd[32], argx[32], argy[32]
  246. read_argv(0,cmd,32)
  247. read_argv(1,argx,32)
  248. read_argv(2,argy,32)
  249.  
  250. if (equali(cmd,"listmaps")) {
  251. listmaps_engine(id,argx,argy,cmd,T_LMaps,totalmaps)
  252. }
  253. else if (equali(cmd,"listmapsm")) {
  254. console_print(id, "%L", id, "DISP_IN_MOTD")
  255. listmaps_motd_engine(id,argx,argy,cmd,T_LMaps,totalmaps)
  256. }
  257. #if LISTCYCLE
  258. else if (equali(cmd,"listcycle")) {
  259. listmaps_engine(id,argx,argy,cmd,T_LCycle,totalmapsc)
  260. }
  261. else if (equali(cmd,"listcyclem")) {
  262. console_print(id, "%L", id, "DISP_CYCLE_MOTD")
  263. listmaps_motd_engine(id,argx,argy,cmd,T_LCycle,totalmapsc)
  264. }
  265. #endif
  266. return PLUGIN_HANDLED
  267. }
  268.  
  269. //This event is only being used to catch the say listmaps and block it so other plugins wont respond.
  270. //The actual response handling from this plugin is in the HandleSay function
  271. public say_listmaps(id) {
  272. return PLUGIN_HANDLED
  273. }
  274.  
  275. search_engine(id,argx[]){
  276. new LMaps[20][32]
  277. new b
  278. for(new a = 0; a < totalmaps; a++) {
  279. if (containi(T_LMaps[a],argx) != -1) {
  280. if(b < 20){
  281. copy(LMaps[b], 32, T_LMaps[a])
  282. b++
  283. }
  284. }
  285. }
  286. new msg[800]
  287. set_hudmessage(10,100,250, 0.75, 0.10, 2, 0.02, 14.0, 0.01, 0.1, 23)
  288. if(b > 0){
  289. format(msg,800,"%L^n^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n",
  290. id, "SRC_RES_HUD", totalmaps, LMaps[0],LMaps[1],LMaps[2],LMaps[3],LMaps[4],LMaps[5],LMaps[6],LMaps[7],LMaps[8],LMaps[9],LMaps[10],LMaps[11],LMaps[12],LMaps[13],LMaps[14],LMaps[15],LMaps[16],LMaps[17],LMaps[18],LMaps[19])
  291. show_hudmessage(id,msg)
  292. }else{
  293. show_hudmessage(id, "%L", id, "NO_RES_SRC", totalmaps)
  294. }
  295. client_print(id, print_chat, "%L", id, "SRC_RES_LRIGHT")
  296. return PLUGIN_CONTINUE
  297. }
  298.  
  299. listmaps_engine(id,arg1[],arg2[],cmd[],MapList[][],TMaps){
  300.  
  301. if (equal(cmd,"listcycle"))
  302. console_print(id,"^n---------------- %L -----------------", id, "CONS_CYCLELISTING")
  303. else
  304. console_print(id,"^n------------------- %L -------------------", id, "CONS_MAPLISTING")
  305.  
  306. new start=0, end=0, tmcount=0
  307. new tempmap[4][32]
  308. if (!isdigit(arg1[0]) && !equal("", arg1)) {
  309. new n=1
  310. start = arg2 ? str_to_num(arg2) : 1
  311. if (--start < 0) start = 0
  312. end = start + MAPAMOUNT
  313. for(new x = 0; x < TMaps; x++) {
  314. if (containi(MapList[x], arg1) != -1) {
  315. if (n > start && n <= end) {
  316. copy(tempmap[tmcount],31,MapList[x])
  317. tmcount++
  318. if (tmcount > 2) {
  319. tmcount = 0
  320. console_print(id,"%-20s %-20s %-20s",tempmap[0],tempmap[1],tempmap[2])
  321. }
  322. }
  323. n++
  324. }
  325. }
  326.  
  327. if (tmcount != 0 ) {
  328. new z
  329. for (z = tmcount; z < 3; z++) {
  330. tempmap[z] = ""
  331. }
  332. console_print(id,"%-20s %-20s %-20s",tempmap[0],tempmap[1],tempmap[2])
  333. }
  334.  
  335. if (n-1 == 0)
  336. console_print(id,"--------------- %L ---------------", id, "NO_MATCHES_SRC")
  337. else if (start+1 > n-1)
  338. console_print(id,"---------------- %L ----------------", id, "HIGHEST_ENTRY", n-1)
  339. else if (n-1 < end)
  340. console_print(id,"---------------- %L ----------------", id, "CONS_ENTRIES", start+1,n-1,n-1)
  341. else
  342. console_print(id,"---------------- %L ----------------", id, "CONS_ENTRIES", start+1,end,n-1)
  343.  
  344. if (end < n-1)
  345. console_print(id,"-------------- %L --------------", id, "USE_FOR_MORE", cmd,arg1,end+1)
  346. }
  347. else {
  348. start = arg1 ? str_to_num(arg1) : 1
  349. if (--start < 0) start = 0
  350. if (start >= TMaps) start = TMaps - 1
  351. end = start + MAPAMOUNT
  352. if (end > TMaps) end = TMaps
  353. for (new i = start; i < end; i++){
  354. copy(tempmap[tmcount],31,MapList[i])
  355. tmcount++
  356. if (tmcount > 2) {
  357. tmcount = 0
  358. console_print(id,"%-20s %-20s %-20s",tempmap[0],tempmap[1],tempmap[2])
  359. }
  360. }
  361.  
  362. if (tmcount != 0 ) {
  363. new z
  364. for (z = tmcount; z < 3; z++) {
  365. tempmap[z] = ""
  366. }
  367. console_print(id,"%-20s %-20s %-20s",tempmap[0],tempmap[1],tempmap[2])
  368. }
  369.  
  370. console_print(id,"---------------- %L ----------------", id, "CONS_ENTRIES", start+1,end,TMaps)
  371. if (end < TMaps)
  372. console_print(id,"-------------- %L --------------", id, "USE_FOR_MORE2", cmd,end+1)
  373. }
  374. #if LISTCYCLE
  375. if (equal(cmd,"listcycle"))
  376. console_print(id,"%L", id, "ALSO_LISTMAPS")
  377. else if (equal(cmd,"listmaps"))
  378. console_print(id,"%L", id, "ALSO_LISTCYCLE")
  379. #endif
  380. console_print(id,"")
  381. return PLUGIN_HANDLED
  382. }
  383.  
  384. listmaps_motd_engine(id,arg1[],arg2[],cmd[],MapList[][],TMaps){
  385.  
  386. new len = 2047
  387. new buffer[2048]
  388. new s = 0
  389.  
  390. #if !defined NO_STEAM
  391. s += copy( buffer[s],len-s,"<html><head><style type=^"text/css^">pre{color:#FFB000;}body{background:#000000;margin-left:8px;margin-top:0px;}</style></head><body><pre>^n")
  392. #endif
  393.  
  394. #if LISTCYCLE
  395. s += format( buffer[s],len-s,"<div align=^"center^">%L</div>^n", id, "USAGE_LISTCYCLE")
  396. #endif
  397. s += format( buffer[s],len-s,"<div align=^"center^">%L</div>^n^n^n", id, "USAGE_LISTMAPS")
  398.  
  399. new start=0, end=0, tmcount=0
  400. new tempmap[5][32]
  401. if (!isdigit(arg1[0]) && !equal("", arg1)) {
  402. new n=1,x
  403. start = arg2 ? str_to_num(arg2) : 1
  404. if (--start < 0) start = 0
  405. end = start + MAPAMOUNT_MOTD
  406. for( x = 0; x < TMaps; x++) {
  407. if (containi(MapList[x], arg1) != -1) {
  408. if (n > start && n <= end) {
  409. copy(tempmap[tmcount],31,MapList[x])
  410. tmcount++
  411. if (tmcount > 3) {
  412. tmcount = 0
  413. s += format( buffer[s],len-s,"%-20s %-20s %-20s %-20s^n",tempmap[0],tempmap[1],tempmap[2],tempmap[3])
  414. }
  415. }
  416. n++
  417. }
  418. }
  419.  
  420. if (tmcount != 0 ) {
  421. new z
  422. for (z = tmcount; z < 4; z++) {
  423. tempmap[z] = ""
  424. }
  425. s += format( buffer[s],len-s,"%-20s %-20s %-20s %-20s^n",tempmap[0],tempmap[1],tempmap[2],tempmap[3])
  426. }
  427.  
  428. s += copy( buffer[s],len-s,"^n")
  429.  
  430. if (n-1 == 0)
  431. s += format( buffer[s],len-s,"<div align=^"center^"><[ %L ]></div>^n", id, "NO_MATCHES_SRC")
  432. else if (start+1 > n-1)
  433. s += format( buffer[s],len-s,"<div align=^"center^"><[ %L ]></div>^n", id, "HIGHEST_ENTRY", n-1)
  434. else if (n-1 < end)
  435. s += format( buffer[s],len-s,"<div align=^"center^"><[ %L ]></div>^n", id, "CONS_ENTRIES", start+1,n-1,n-1)
  436. else
  437. s += format( buffer[s],len-s,"<div align=^"center^"><[ %L ]></div>^n", id, "CONS_ENTRIES", start+1,end,n-1)
  438.  
  439. if (end < n-1)
  440. s += format( buffer[s],len-s,"<div align=^"center^"><[ %L ]></div>", id, "USE_FOR_MORE", cmd,arg1,end+1)
  441. }
  442. else {
  443. start = arg1 ? str_to_num(arg1) : 1
  444. if (--start < 0) start = 0
  445. if (start >= TMaps) start = TMaps - 1
  446. end = start + MAPAMOUNT_MOTD
  447. if (end > TMaps) end = TMaps
  448. for (new i = start; i < end; i++){
  449. copy(tempmap[tmcount],31,MapList[i])
  450. tmcount++
  451. if (tmcount > 3) {
  452. tmcount = 0
  453. s += format( buffer[s],len-s,"%-20s %-20s %-20s %-20s^n",tempmap[0],tempmap[1],tempmap[2],tempmap[3])
  454. }
  455. }
  456.  
  457. if (tmcount != 0 ) {
  458. new z
  459. for (z = tmcount; z < 4; z++) {
  460. tempmap[z] = ""
  461. }
  462. s += format( buffer[s],len-s,"%-20s %-20s %-20s %-20s^n",tempmap[0],tempmap[1],tempmap[2],tempmap[3])
  463. }
  464.  
  465. s += copy( buffer[s],len-s,"^n")
  466. s += format( buffer[s],len-s,"<div align=^"center^"><[ %L ]></div>^n", id, "CONS_ENTRIES", start+1,end,TMaps)
  467.  
  468. if (end < TMaps) {
  469. s += format( buffer[s],len-s,"<div align=^"center^"><[ %L ]></div>^n", id, "USE_FOR_MORE2", cmd,end+1)
  470. }
  471. }
  472.  
  473. #if !defined NO_STEAM
  474. s += copy( buffer[s],len-s,"</pre></body></html>")
  475. #endif
  476.  
  477. if (equal(cmd,"listcyclem")) {
  478. show_motd(id,buffer ,"MapCycle Listing")
  479. }
  480. else {
  481. show_motd(id,buffer ,"Map Listing")
  482. }
  483.  
  484. return PLUGIN_HANDLED
  485. }
  486.  
  487. public get_listing() {
  488.  
  489. #if LOADFILE
  490. new linestr[32], filename[128], stextsize, numword
  491. new allmaps[128],mapchoice[128],configsdir[64]
  492. copy(filename,127,"null")
  493. get_configsdir(configsdir, 63)
  494. format(allmaps,127,"%s/map_manage/allmaps.txt",configsdir)
  495. format(mapchoice,127,"%s/map_manage/mapchoice.ini",configsdir)
  496.  
  497. if (file_exists(allmaps)) {
  498. copy(filename,127,allmaps)
  499. }
  500. else if (file_exists(mapchoice)) {
  501. copy(filename,127,mapchoice)
  502. }
  503. else if (file_exists("mapcycle.txt")) {
  504. copy(filename,127,"mapcycle.txt")
  505. }
  506. else {
  507. log_amx("No File found for reading map list, SearchMaps will not work.")
  508. }
  509.  
  510. if (!equal(filename,"null")) {
  511. while((numword = read_file(filename,numword,linestr,32,stextsize)) != 0) {
  512. strtolower(linestr)
  513. if(numword >= MAX_MAPS){
  514. log_amx("MAX_MAPS has been exceeded, not all maps are able to load for searching")
  515. break
  516. }
  517. if (!equali(linestr, "")) {
  518. copy(T_LMaps[totalmaps], 32, linestr)
  519. totalmaps++
  520. }
  521. }
  522. log_amx("Loaded %d maps for listmaps searching from %s",totalmaps,filename)
  523. }
  524.  
  525. #else
  526.  
  527. new data[64], temp, numword
  528.  
  529. while((numword = read_dir("maps",numword,data,63,temp)) != 0) {
  530. strtolower(data)
  531. if((contain(data,".bsp") != -1) && (containi(data,".ztmp") == -1)) {
  532. replace(data,63,".bsp","")
  533. if(totalmaps >= MAX_MAPS){
  534. log_amx("MAX_MAPS has been exceeded, not all maps are able to load for listmaps searching")
  535. break
  536. }
  537. copy(T_LMaps[totalmaps],31, data)
  538. totalmaps++
  539. }
  540. }
  541. log_amx("Loaded %d maps for searching from the maps folder",totalmaps)
  542. #endif
  543.  
  544. #if LISTCYCLE
  545. new linestrc[32], filenamec[16], stextsizec, numwordc
  546.  
  547. if (file_exists("mapcycle.txt")) {
  548. copy(filenamec,15,"mapcycle.txt")
  549. while(read_file(filenamec,numwordc,linestrc,32,stextsizec)) {
  550. strtolower(linestrc)
  551. if(numwordc >= MAX_CYCLE_MAPS){
  552. log_amx("MAX_CYCLE_MAPS has been exceeded, not all maps are able to load for listcycle searching")
  553. break
  554. }
  555. if (!equali(linestrc, "")) {
  556. copy(T_LCycle[totalmapsc], 32, linestrc)
  557. totalmapsc++
  558. }
  559. numwordc++
  560. }
  561. log_amx("Loaded %d maps for listcycle searching from %s",totalmapsc,filenamec)
  562. }
  563. else {
  564. log_amx("MapCycle file not found for reading, listcycle will not work.")
  565. }
  566. #endif
  567.  
  568. return PLUGIN_CONTINUE
  569. }
  570.  
  571. sort_maps() {
  572. new x,y,z,d
  573. new bool:swap
  574. new temp[32]
  575. for ( x = 0; x < totalmaps; x++ ) {
  576. for ( y = x + 1; y < totalmaps; y++ ) {
  577. swap = false
  578. for (z = 0; z < 32; z++) {
  579. if ( T_LMaps[x][z] != T_LMaps[y][z]) {
  580. if ( T_LMaps[x][z] > T_LMaps[y][z] ) swap = true
  581. break
  582. }
  583. }
  584. if (swap) {
  585. temp = T_LMaps[x]
  586. T_LMaps[x] = T_LMaps[y]
  587. T_LMaps[y] = temp
  588. }
  589. else if (equal(T_LMaps[x],T_LMaps[y])) {
  590. for ( d = y; d < totalmaps - 1; d++ ) {
  591. T_LMaps[d] = T_LMaps[d + 1]
  592. }
  593. y = totalmaps--
  594. x--
  595. }
  596. }
  597. }
  598. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement