HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. //Magyar fordítás: sNaiL
  2. //Plugin készítõje: pizzahut
  3. //Weboldal: www.netmaffia.hu
  4.  
  5. #include <amxmodx>
  6. #include <amxmisc>
  7.  
  8. #define Plugin "Time left in hostname"
  9. #define Version "1.3.6"
  10. #define Author "Doombringer,pizzahut"
  11. #define CVARNAME "amx_hostname_update"
  12.  
  13. new g_old_hostname[64]
  14. new g_mp_timelimit
  15.  
  16. public plugin_init()
  17. {
  18. register_plugin(Plugin,Version,Author)
  19. register_cvar(CVARNAME,"1.0")
  20. g_mp_timelimit = get_cvar_pointer("mp_timelimit")
  21. set_task(2.0,"check_time")
  22. }
  23.  
  24. // Check cvar for valid values, correct if needed, update hostname now and set
  25. // up a task.
  26.  
  27. public check_time()
  28. {
  29. new Float:time = get_cvar_float(CVARNAME)
  30. if(time != 0.0)
  31. {
  32. time = floatabs(time)
  33. if(time < 1.0)
  34. time = 1.0
  35. get_cvar_string("hostname",g_old_hostname,63)
  36. if(strlen(g_old_hostname))
  37. {
  38. update_time()
  39. set_task(time,"update_time",1,"",0,"b")
  40. }
  41. }
  42. }
  43.  
  44. // Update hostname.
  45.  
  46. public update_time()
  47. {
  48. static new_hostname[64]
  49. static h,m,s
  50.  
  51. if(strlen(g_old_hostname))
  52. {
  53. if(get_pcvar_float(g_mp_timelimit))
  54. {
  55. s = get_timeleft()
  56. m = s/60
  57. h = m/60
  58. s = s-m*60
  59. m = m-h*60
  60. if(h)
  61. format(new_hostname,63,"%s (Hatramaradt ido %d:%02d:%02d)",g_old_hostname,h,m,s)
  62. else
  63. format(new_hostname,63,"%s (Hatramaradt ido %d:%02d)", g_old_hostname,m,s)
  64. }
  65. else
  66. format(new_hostname,63,"%s (No time limit)",g_old_hostname)
  67. set_cvar_string("hostname",new_hostname)
  68. }
  69. }
  70.  
  71. // Restoring hostname in case it's not reset in server.cfg.
  72.  
  73. public plugin_end()
  74. {
  75. if(task_exists(1))
  76. {
  77. remove_task(1)
  78. if(strlen(g_old_hostname))
  79. set_cvar_string("hostname", g_old_hostname)
  80. }
  81. }
  82.