Jump to content

pixelshasHUN

Inactive Member
  • Posts

    10
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by pixelshasHUN

  1. 1 minute ago, V0lvox said:

    If you declare item2 as LPITEM then at this point it is empty.
    When you call item2->GetVnum() on an empty variable, then Server will crash.
    You need to define, what item2 is.
     

    e.g. do it like this
     

    	if (!IsValidItemPosition(DestCell) || !(item2 = GetInventoryItem(wDestCell)))
    					return false;

    this will define item2.

    Oh i see. Thanks for the help!

    • Good 1
  2. I want to block add attribute to a specified item but when I'm testing it the server is going to close.

    					case USE_PUT_INTO_BELT_SOCKET:
    					case USE_PUT_INTO_RING_SOCKET:
    					case USE_PUT_INTO_ACCESSORY_SOCKET:
    					case USE_ADD_ACCESSORY_SOCKET:
    					case USE_CLEAN_SOCKET:
    					case USE_CHANGE_ATTRIBUTE:
    					case USE_CHANGE_ATTRIBUTE2 :
    					case USE_ADD_ATTRIBUTE:
    					case USE_ADD_ATTRIBUTE2:
    						{
    							LPITEM item2;
    							if (item2->GetVnum() == 53030)
    								return false;

    What am i doing wrong?

     

  3. This is an other cipher method what you wrote. Your method is XOR, but yeah XOR is shorter than Vigenère.  Thanks, I think i will use this method for make Vigenère harder.

    The big difference between the two methods that Vigenère cant encrypt and decrypt the text with the same function.

  4. I made a low cipher for my autologin system to encrypt user passwords.

    I will make it harder to decrypt with autokey methods etc.

    Feel free to use this version if you want.:

    class VIGENERE:
        def __init__(self):
            self.table = []
    
        def CreateTable(self, start_char="a", end_char="z", shift=0):
            try:
                ord(start_char)
            except:
                start_char = chr(start_char)
            try:
                ord(end_char)
            except:
                end_char = chr(end_char)
            start, end = ord(start_char)-(shift+1), ord(end_char)+1
            for j in range(end-start):
                j += shift
                self.table.append([])
                for i in range(start+1, end):
                    self.table[j-shift].append(chr(i+j if i+j < end else i+j-(end-start)))
                    #print(chr(i+j if i+j < end else i+j-(end-start)), end=" ")
                    #print("")
    
        def Check(self, value, row):
            for j in enumerate(row):
                if j[1] == value:
                    return j[0]
            else:
                return False
    
        def CreateKey(self, data, key):
            long_key = ""
            x = -1
            #print("Creating long key from '{0}' to '{1}'...".format(key, data))
            for k in range(len(data)):
                x += 1
                try:
                    long_key += key[x]
                except:
                    x = 0
                    long_key += key[x]
    
            #print("Created long key : '{0}'".format(long_key))
            return long_key
    
        def Encrypt(self, data, key):
            encrypted = ""
            err = ""
            key = self.CreateKey(data, key)
            for char in enumerate(data):
                col_char_pos = self.Check(char[1], self.table[0])
                row_char_pos = self.Check(key[char[0]], self.table[0])
                if col_char_pos != None and row_char_pos != None:
                    #print("Encrypting '{0}' to '{1}'...".format(char[1], self.table[row_char_pos][col_char_pos]))
                    encrypted += self.table[col_char_pos][row_char_pos]
                else:
                    if not col_char_pos:
                        err += "This character: '{0}' is not in this row: '{1}'".format(char[1], self.table[0]) + "\n"
                    if not row_char_pos:
                        err += "This character: '{0}' is not in this row: '{1}'".format(key[char[0]], self.table[0]) + "\n"
                    return err
                    
            return encrypted
    
    
        def Decrypt(self, data, key):
            decrypted = ""
            err = ""
            key = self.CreateKey(data, key)
            for char in enumerate(data):
                col_char_pos = self.Check(char[1], self.table[0])
                row_char_pos = self.Check(key[char[0]], self.table[0])
                if col_char_pos != None and row_char_pos != None:
                    #print("Decrypting '{0}' to '{1}'".format(char[1], self.table[0][self.Check(self.table[row_char_pos][self.Check(char[1], self.table[row_char_pos])], self.table[row_char_pos])]))
                    decrypted += self.table[0][self.Check(self.table[row_char_pos][self.Check(char[1], self.table[row_char_pos])], self.table[row_char_pos])]
                else:
                    if not col_char_pos:
                        err += "This character: '{0}' is not in this row: '{1}'".format(char[1], self.table[0]) + "\n"
                    if not row_char_pos:
                        err += "This character: '{0}' is not in this row: '{1}'".format(key[char[0]], self.table[0]) + "\n"
                    return err
            return decrypted
    
    if __name__ == "__main__":
        cipher = VIGENERE()
        cipher.CreateTable("a", "z", 70)
        encrypted = cipher.Encrypt("abcdyz", "tfkusgfhzenmaue")
        decrypted = cipher.Decrypt(encrypted, "tfkusgfhzenmaue")
        print(encrypted, decrypted)

     

  5. I solved the problem that how to get the vid from player name if the player is on other map.

    Its a python-quest communication. 

     

    quest:

    quest send_vid begin
    	state start begin			
    		function GetPlayerName()			
    			cmdchat("init_getInfo")			
    			local name = input(cmdchat("getInfo"))
    			cmdchat("ignore_getInfo")	
    			return name		
    		end		
    		
    		when button or info begin
    			local vid = find_pc_by_name(send_vid.GetPlayerName())
    			cmdchat("sendInfo "..vid)
    		
    		end		
    		when login begin			
    			cmdchat("saveInfo "..q.getcurrentquestindex())		
    		end		
    	end
    end

    python(game.py):

    	#GET PLAYER VID FROM SERVER
    	def InitPlayerNameInfo(self):
    		constInfo.IGNORE_SEND_PLAYER_NAME = 1
    	def IgnorePlayerNameInfo(self):
    		constInfo.IGNORE_SEND_PLAYER_NAME = 0
    	def SendPlayerNameInfo(self):
    		net.SendQuestInputStringPacket(constInfo.PLAYER_NAME)
    	def GetPlayerVIDInfo(self, vid):
    		constInfo.PLAYER_VID = vid
    	def SavePlayerVIDInfo(self, value):
    		constInfo.get_vid = value
    	#END OF GET PLAYER VID FROM SERVER

    for example i used this for whisper trade

    python(uiwhisper.py):

    	def StartExchange(self):
    		constInfo.PLAYER_NAME = self.targetName
    		event.QuestButtonClick(int(constInfo.get_vid))
    		vid = int(constInfo.PLAYER_VID)
    		if vid != 0:
    			chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.EXCHANGE_TARGET.format(self.targetName)) #if player is online
    			net.SendExchangeStartPacket(vid)
    			self.interface.StartExchange(self.targetName)
    		else:
    			chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.EXCHANGE_NO_TARGET.format(self.targetName)) #if player is offline
    
    	def EndExchange(self):
    		self.interface.EndExchange()
            
       	def RefreshExchange(self):
    		self.interface.RefreshExchange()

    and of course i connected a button for the function:

    self.tradeButton.SetEvent(ui.__mem_func__(self.StartExchange))

     

     

    • Metin2 Dev 2
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.