Jump to content

[Python] Register environment based on server time


Recommended Posts

def getModule():
	EnvironmentData = {
		# Explanation:
			# 16 - (16:00:00 - 16:59:59)
			# "d:/ymir work/environment/capedragonhead.msenv" - Environment what will be set on this time.
		# You can add how many environments you want.
		4:	"d:/ymir work/environment/metin2_map_n_flame_dragon_01.msenv",
		8:	"d:/ymir work/environment/mtthunder.msenv",
		12:	"d:/ymir work/environment/bayblacksand.msenv",
		16:	"d:/ymir work/environment/capedragonhead.msenv",
		20:	"d:/ymir work/environment/snowm02.msenv",
		22:	"d:/ymir work/environment/trent02.msenv"
	return EnvironmentData # Returns the dict with all items
def getHour():
	return ((app.GetGlobalTimeStamp() / 60) / 60 % 24) # Returns the hour from server timestamp (loaded by TPacketGCTime) 

def Main():
	for key, c_pszName in getModule().iteritems():
		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.
			background.RegisterEnvironmentData(0, c_pszName) # Set the environment

You can execute the function in two parts for loaded automatically.

File: root/game.py

On function:

  • def OnUpdate(self): - Check every time hour and inserted environment, you should add a break to stop condition after check is true.
  • def Open(self): - Check on every start the client / teleport - Much better optimization.
Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...