• 🎉 Hey there! I've just launched my brand new server voting platform — Metin2 P Servers 🚀

Member
Jul
Threads
0
42
0
6
HubMoney
471
UPDATE **

if app.ENABLE_SAVE_LAST_WINDOW_POSITION:
import player, wndMgr
pos_filename = "inventory"
def SetLastPosition(self):
import os
dir_path = "wndconf/" + player.GetName()
file_path = os.path.join(dir_path, self.pos_filename + ".pos")
if not os.path.exists(file_path):
return
# else:
file = open("wndconf/" + player.GetName() + "/"+ self.pos_filename + ".pos", 'r')
line = file.read().split(",")
pos_x, pos_y = int(line[0]), int(line[1])
file.close()
if pos_x > wndMgr.GetScreenWidth() or pos_y > wndMgr.GetScreenHeight():
return
if pos_x < 0:
pos_x = 0
if pos_y < 0:
pos_y = 0
self.SetPosition(pos_x, pos_y);

def SaveLastPosition(self):
pos_x, pos_y = self.GetGlobalPosition()
file = open("wndconf/" + player.GetName() + "/"+ self.pos_filename + ".pos","w")
file.write(str(pos_x)+","+str(pos_y))
file.close()


Added file existence check to avoid first time opening errors