Register environment based on server time

Închis
Avatar utilizator
LuciMld
Utilizator interzis !

Utilizator interzis !
Mesaje: 285
Membru din: 11 Oct 2016, 19:06
Regat: Jinno
Aprecieri: 21  
Mulţumiri: 39  
 Contact:
Medalii

Inainte De a posta tin sa anunt ca autorul este vegas.

Cod: Selectaţi tot

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
			background.SetEnvironmentData(0)
I didn't tested in client, i just write for one friend long time ago.
You can execute the function in two parts for loaded automatically.
File: root/game.py

Cod: Selectaţi tot

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.
Avatar utilizator
r_tw1x1
Membru Club

Membru Club
Mesaje: 2278
Membru din: 06 Mar 2015, 18:33
Server: Nirvana3
Regat: Jinno
Aprecieri: 228  
Mulţumiri: 3790  
  Rezolvări prob.: 1
Discord: Copiază ID
Medalii

Mai este postat odată: http://just4metin.ro/topic56784.html. Rog un moderator să închidă topicul.
Imagine
Imagine
Afișează semnătura
Avatar utilizator
Ionuț Daniel
Nivel 8

Nivel 8
Mesaje: 1724
Membru din: 19 Noi 2016, 14:52
Aprecieri: 156  
Mulţumiri: 135  
 Contact:
Medalii

Arhivat.
Închis

Înapoi la “Arhivă”

  • Informaţie
  • Cine este conectat

    Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 1 vizitator