SHARE
TWEET

NightMapChange

a guest Mar 24th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <amxmodx>
  2.  
  3. #if !defined MAX_NAME_LENGTH
  4.     #define MAX_NAME_LENGTH 32
  5. #endif
  6.  
  7. #define HUD_COLOR 127, 212, 255
  8. #define HUD_POSITION  0.02, 0.20
  9. #define HUD_DURATION  7.0
  10.  
  11. enum _:Cvar
  12. {
  13.     amx_night_time_start,
  14.     amx_night_time_end,
  15.     amx_night_time_map,
  16.     amx_night_time_timelimit,
  17.     amx_night_time_extend_map
  18. }
  19.  
  20. new g_pCvar[Cvar], g_szNightMap[MAX_NAME_LENGTH], g_szCurrentMap[MAX_NAME_LENGTH]
  21.  
  22. public plugin_init()
  23. {
  24.     register_plugin("Night Map Change","1.0","hackera457")
  25.     register_cvar("hackera457_nightmapchange","1.0",FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
  26.    
  27.     g_pCvar[amx_night_time_start] = register_cvar("amx_night_time_start","00")
  28.     g_pCvar[amx_night_time_end] = register_cvar("amx_night_time_end","10")
  29.     g_pCvar[amx_night_time_map] = register_cvar("amx_night_time_map","de_dust2")
  30.     g_pCvar[amx_night_time_timelimit] = register_cvar("amx_night_time_timelimit","540")
  31.     g_pCvar[amx_night_time_extend_map] = register_cvar("amx_night_time_extend_map","10")
  32. }
  33.  
  34. public plugin_cfg()
  35. {
  36.     get_pcvar_string(g_pCvar[amx_night_time_map], g_szNightMap,charsmax(g_szNightMap))
  37.     get_mapname(g_szCurrentMap,charsmax(g_szCurrentMap))
  38.    
  39.     set_task(1.0,"CheckNightTime",.flags="b")
  40.  
  41.     if(is_night() && equali(g_szCurrentMap,g_szNightMap))
  42.     {
  43.         set_cvar_num("mp_timelimit",get_pcvar_num(g_pCvar[amx_night_time_timelimit]))
  44.         set_cvar_num("amx_extendmap_max", get_pcvar_num(g_pCvar[amx_night_time_extend_map]))
  45.     }
  46. }
  47.  
  48. public client_putinserver(id)
  49. {
  50.     if (is_night())
  51.     {
  52.         set_task(5.0, "Task_DelayedInfo", id)
  53.     }
  54. }
  55.  
  56. public Task_DelayedInfo(id)
  57. {
  58.     set_hudmessage(HUD_COLOR,HUD_POSITION,.holdtime=HUD_DURATION)
  59.     show_hudmessage(id, "Night MAP: START from %i:00 to %i:00 - Map %s",get_pcvar_num(g_pCvar[amx_night_time_start]),get_pcvar_num(g_pCvar[amx_night_time_end]), g_szNightMap)
  60. }
  61.  
  62. public CheckNightTime()
  63. {
  64.     if(is_night() && !equali(g_szCurrentMap,g_szNightMap))
  65.         engine_changelevel(g_szNightMap)
  66. }
  67.  
  68. bool:is_night()
  69. {
  70.     static iHour, iStart, iEnd
  71.     time(iHour)
  72.    
  73.     iStart = get_pcvar_num(g_pCvar[amx_night_time_start])
  74.     iEnd = get_pcvar_num(g_pCvar[amx_night_time_end])
  75.    
  76.     return bool:(iStart < iEnd ? (iStart <= iHour < iEnd) : (iStart <= iHour || iHour < iEnd))
  77. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top