HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #define PLUGIN_NAME "Mapconfig Extended"
  2. #define PLUGIN_VERSION "1.0.3"
  3. #define PLUGIN_AUTHORS "_KaszpiR_"
  4.  
  5. /* AMX Mod X script.
  6. *
  7. * Mapconfig Extended 1.0.3
  8. * Execute map config depending on the defined prefix found in name of the map.
  9. * by _KaszpiR_ http://hlds.pl #hlds.pl @ quakenet.org
  10. *
  11. * Based on plugin by JustinHoMi (justin@justinmitchell.net)
  12. * http://www.modkillers.com #modkillers in irc.gamesnet.net
  13. *
  14. *
  15. * Changelog:
  16. * 1.0.3 - added cvar amx_mce_cfg that defines the file containing prefixess (default mapconfig.ini)
  17.   - added cvar amx_mce_dir that defines the directory cintaining the configg files with prefixes by default 'maps' that is
  18. later finned to addons/amxmodx/configs/maps. Do not add any beginning or ending slashes.
  19. - changed the configs naming to load fies with _prefix.cfg where prefix is changed to the found text, like de_ cs_ etc
  20. so now for de_ prefix it loads _de_.cfg file
  21. - prefixes occurence in mapconfig.ini is important.
  22. - i suggest not to use more than 5 prefixes per map (in example if you got map named de_dust_blow2.cfg and you got the following prefixes
  23. de_
  24. de_dust
  25. de_dust_blow
  26. then all of them will be executerd if the config files exist, respectively
  27. _de_.cfg
  28. _de_dust.cfg
  29. _de_dust_blow.cf
  30.  
  31. - optimizations suggested by Zenith77 and Xanimos
  32. - on map load i suggest looking at server status window via rcon to find any errors and warnings
  33.  
  34. * 1.0.2 - Complete change, it loads prefixes form file named addons/amxmodx/configs/mapconfig.ini and loads only prefix files
  35. * the custom map configs are not executed cause the amdin.sma allready do it.
  36. * 1.0.1 - Modified to support general map prefix configs like de_ aim_ fy_ - you must have de_.cfg aim_.cfg fy_.cfg
  37. * files in addons/amxmodx/configs/maps/ (modification by _KaszpiR_)
  38. * 1.0.0 - Ported to AMX MOD X (without translations)
  39. * 0.9.9 - Added translations support for AMX Mod 0.9.9
  40. * 0.61 - Changes load delay to 6s (to work better with SQL ServerCfg)
  41. * 0.6 - Execs configs rather than loading file
  42. * - Delays execution for 5s after map changes
  43. * 0.5 - Initial release
  44. *
  45. */
  46.  
  47. #define PLUGIN_MOD "[AMXX] [MCE]"
  48. #define MAX_WORD_LENGTH 16
  49. //#define DEBUG 1
  50. #include <amxmodx>
  51. #include <amxmisc>
  52.  
  53. new currentmap[32]
  54. public plugin_init(){
  55. register_plugin(PLUGIN_NAME,PLUGIN_VERSION,PLUGIN_AUTHORS)
  56. register_cvar("amx_mce_cfg","mapconfig.ini")
  57. register_cvar("amx_mce_dir","maps")
  58.  
  59. new filename[128], filepath[64], filename_cfg[128], filepath_dir[64]
  60. get_configsdir( filepath, 63 )
  61. get_cvar_string("amx_mce_cfg", filename, 31) // we read to the currentmap cvar the cvar that defines name of file containing proexies
  62. format(filename_cfg,127,"%s/%s", filepath, filename) // filename contains full path to the maps.ini
  63. get_cvar_string("amx_mce_dir", filename, 31) // we read to the currentmap cvar the cvar that defines direcotry for custom map configs
  64. format(filepath_dir, 63, "%s/%s", filepath, filename) //set porper file path
  65.  
  66. get_mapname(currentmap, 31) //set proper map name to the cvar
  67. ///////////////////
  68. if( !file_exists( filename_cfg ) )
  69. {
  70. server_print("%s HIBA: File %s nemletezik, nincs mit tenni.", PLUGIN_MOD, filename_cfg)
  71. }
  72. else
  73. {
  74. new Float:f = 0.1
  75. new i = 0, l = 0, pos = 0
  76. new prefix[MAX_WORD_LENGTH]
  77. while( read_file( filename_cfg, pos++, prefix, MAX_WORD_LENGTH-1, l ) )
  78. {
  79. if( prefix[0] == ';' || !l ) continue // skip comments and empty lines
  80. parse( prefix, prefix, MAX_WORD_LENGTH-1 )
  81. #if defined DEBUG
  82. server_print("%s HIBAELHARITAS: '%s'", PLUGIN_MOD ,prefix)
  83. #endif
  84. if(containi(currentmap,prefix) == 0 ) {
  85. #if defined DEBUG
  86. server_print("%s DEBUG: %i, %s ? %s ", PLUGIN_MOD , i, currentmap, prefix )
  87. #endif
  88. filename[0] = '^0' // clear string
  89. new len = format(filename, 127, "%s/_%s.cfg", filepath_dir, prefix)
  90. if(file_exists(filename)) {
  91. set_task(5.5 + f, "delayed_load", 14114 + i++, filename, len+1)
  92. #if defined DEBUG
  93. server_print("%s HIBAELHARITAS: tennivalo hozzaadva %f, %i, %s ", PLUGIN_MOD , f , i, filename)
  94. #endif
  95. f += 0.1
  96.  
  97. }
  98. else
  99. {
  100. server_print("%s VIGYAZAT: Elotag %s eszlelve de a %s file nem letezik", PLUGIN_MOD, prefix, filename)
  101. }
  102. }
  103. }
  104. }
  105.  
  106. ///////////////////
  107.  
  108. }
  109.  
  110. public delayed_load(filename[])
  111. {
  112. server_print("%s Egyedi Map Bealitasok Betoltese A %s-hoz (%s)",PLUGIN_MOD, currentmap, filename)
  113. server_cmd("exec %s",filename)
  114. }
  115.  
  116. // end of file