VegaS1234

[Python] Register environment based on server time

May 2nd, 2017
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. def getModule():
  2.     EnvironmentData = {
  3.         # Explanation:
  4.             # 16 - (16:00:00 - 16:59:59)
  5.             # "d:/ymir work/environment/capedragonhead.msenv" - Environment what will be set on this time.
  6.         # You can add how many environments you want.
  7.         4:  "d:/ymir work/environment/metin2_map_n_flame_dragon_01.msenv",
  8.         8:  "d:/ymir work/environment/mtthunder.msenv",
  9.         12: "d:/ymir work/environment/bayblacksand.msenv",
  10.         16: "d:/ymir work/environment/capedragonhead.msenv",
  11.         20: "d:/ymir work/environment/snowm02.msenv",
  12.         22: "d:/ymir work/environment/trent02.msenv"
  13.     }
  14.     return EnvironmentData # Returns the dict with all items
  15.            
  16. def getHour():
  17.     return ((app.GetGlobalTimeStamp() / 60) / 60 % 24) # Returns the hour from server timestamp (loaded by TPacketGCTime)
  18.  
  19. def Main():
  20.     for key, c_pszName in getModule().iteritems():
  21.         if getHour() is key and app.IsExistFile(c_pszName): # Checks if current hour is equal with index from dict EnvironmentData and it checks if environment exists (file .msenv) in pack.
  22.             background.RegisterEnvironmentData(0, c_pszName) # Set the environment
  23.             background.SetEnvironmentData(0)
Advertisement
Add Comment
Please, Sign In to add comment