HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <amxmisc>
  3.  
  4. #define PLUGIN "custom sky"
  5. #define VERSION "1.1"
  6. #define AUTHOR "cheap_suit"
  7.  
  8. #define max_suffix 6
  9. new g_suffix[max_suffix][3] = { "up", "dn", "ft", "bk", "lf", "rt" }
  10.  
  11. public plugin_precache()
  12. {
  13. register_plugin(PLUGIN, VERSION, AUTHOR)
  14. register_cvar(PLUGIN, VERSION, FCVAR_SPONLY|FCVAR_SERVER)
  15.  
  16. register_cvar("sv_customsky", "1")
  17. register_cvar("sv_customskyname", "test_")
  18.  
  19. switch(get_cvar_num("sv_customsky"))
  20. {
  21. case 1:
  22. {
  23. static configsdir[32]
  24. get_configsdir(configsdir, 31)
  25.  
  26. static file[64]
  27. formatex(file, 63, "%s/custom_sky.cfg", configsdir)
  28.  
  29. static mapname[32]
  30. get_mapname(mapname, 31)
  31.  
  32. if(!file_exists(file))
  33. {
  34. write_file(file, "; Egyedi palya, egbolt konfiguracio.")
  35. write_file(file, "; Formatum: <palyaneve> <egboltneve>")
  36. }
  37.  
  38. new line = 0, length = 0
  39. static text[64], maptext[32], tgatext[32]
  40. while(read_file(file, line++, text, 127, length))
  41. {
  42. if((text[0] == ';') || !length)
  43. continue
  44.  
  45. parse(text, maptext, 31, tgatext, 31)
  46. if(equal(maptext, mapname))
  47. {
  48. precache_sky(tgatext)
  49. break
  50. }
  51. }
  52. }
  53. case 2:
  54. {
  55. static cvar_skyname[32]
  56. get_cvar_string("sv_customskyname", cvar_skyname, 31)
  57.  
  58. if(strlen(cvar_skyname) > 0)
  59. precache_sky(cvar_skyname)
  60. }
  61. }
  62. }
  63.  
  64. public precache_sky(const skyname[])
  65. {
  66. new bool:found = true
  67. static tgafile[35]
  68.  
  69. for(new i = 0; i < max_suffix; ++i)
  70. {
  71. formatex(tgafile, 34, "gfx/env/%s%s.tga", skyname, g_suffix[i])
  72. if(file_exists(tgafile))
  73. precache_generic(tgafile)
  74. else
  75. {
  76. log_amx("Nem talalom ezt a fajlt '%s'", tgafile)
  77. found = false
  78. break
  79. }
  80. }
  81.  
  82. if(found)
  83. set_cvar_string("sv_skyname", skyname)
  84. }