Jump to content

Grzyb

Inactive Member
  • Posts

    8
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by Grzyb

  1. My new fix 100% work:

    	if (item->GetType() == ITEM_RING)
    	{
    		std::vector<LPITEM> FixByMuchomor = { GetWear(WEAR_RING1), GetWear(WEAR_RING2) };
    		const int FixByMuchomorSize = FixByMuchomor.size();
    
    		for (int i = 0; i < FixByMuchomorSize; i++)
    		{
    			if (FixByMuchomor[i])
    			{
    				if (FixByMuchomor[i]->GetVnum() == item->GetVnum() || FixByMuchomor[i]->GetSubType() == item->GetSubType())
    				{
    					ChatPacket(CHAT_TYPE_INFO, "Nie możesz założyć tego przedmiotu dwa razy!");
    					return false;
    				}
    			}
    		}
    	}

     

    • Not Good 1
    • Good 1
  2. My new fix 100% work:

    	if (item->GetType() == ITEM_RING)
    	{
    		std::vector<LPITEM> FixByMuchomor = { GetWear(WEAR_RING1), GetWear(WEAR_RING2) };
    		const int FixByMuchomorSize = FixByMuchomor.size();
    
    		for (int i = 0; i < FixByMuchomorSize; i++)
    		{
    			if (FixByMuchomor[i])
    			{
    				if (FixByMuchomor[i]->GetVnum() == item->GetVnum() || FixByMuchomor[i]->GetSubType() == item->GetSubType())
    				{
    					ChatPacket(CHAT_TYPE_INFO, "Nie możesz założyć tego przedmiotu dwa razy!");
    					return false;
    				}
    			}
    		}
    	}

     

    • Lmao 1
  3. Video:

    Code:
     

    # The script automatically translates the drop from mob_drop_item.txt and special_item_group.txt files, utilizing the information in the locale_name.txt file
    import chardet
    import codecs
    def detect_encoding(filename):
        with open(filename, 'rb') as f:
            result = chardet.detect(f.read())
        return result['encoding']
    with codecs.open('item_names.txt', 'r', encoding='cp1250') as source_file:
        contents = source_file.read()
    with codecs.open('item_names_utf8.txt', 'w', encoding='utf-8') as target_file:
        target_file.write(contents)
    with open('item_names_utf8.txt', 'r', encoding='utf-8') as f:
        item_names = {}
        for line in f:
            if 'VNUM' in line or 'LOCALE_NAME' in line:
                continue
            vnum, name = line.strip().split('\t')
            item_names[vnum] = name
    drop_cpp_encoding = detect_encoding('drop.txt')
    with open('drop.txt', 'r', encoding=drop_cpp_encoding) as f:
        lines = f.readlines()
    new_lines = []
    for line in lines:
        if line.startswith('Group') or 'exp' in line:
            new_lines.append(line)
        else:
            parts = line.split('\t')
            if len(parts) > 2 and parts[2] in item_names:
                line = line.rstrip() + ' // ' + item_names[parts[2]] + '\n'
            new_lines.append(line)
    with open('drop2.txt', 'w', encoding='utf-8') as f:
        f.writelines(new_lines)

     

    • Metin2 Dev 6
  4. Video:

    Code:

    def convert_to_quest(input_text, quest_name, state_name, npc_id, chat_option):
        quest_code = f"quest {quest_name} begin\n\tstate {state_name} begin\n\t\twhen {npc_id}.chat.\"{chat_option}\" begin\n"
    
        lines = input_text.split('\n')
        indentation_level = 0
        for line in lines:
            stripped_line = line.strip()
    
            if stripped_line.startswith("end"):
                indentation_level -= 1
    
            stripped_line = stripped_line.replace(" (", "(").replace(" )", ")")
            stripped_line = stripped_line.replace(" . ", ".")
            stripped_line = stripped_line.replace(' "', '"')
    
            indent = '\t' * (3 + indentation_level)
            quest_code += f"{indent}{stripped_line}\n"
    
            if stripped_line.startswith(("if", "while", "for")) and "end" not in stripped_line:
                indentation_level += 1
    
        quest_code += "\t\tend\n\tend\nend"
    
        return quest_code
    
    
    def process_script_file(script_file_name, quest_name, state_name, npc_id, chat_option):
        with open(script_file_name, 'r', encoding='latin1') as f:
            input_text = f.read()
    
        quest_code = convert_to_quest(input_text, quest_name, state_name, npc_id, chat_option)
    
        quest_file_name = script_file_name.replace('.script', '.quest')
        with open(quest_file_name, 'w', encoding='latin1') as f:
            f.write(quest_code)
    
    
    process_script_file('marriage_manage.start.0.script', 'weeding', 'start', 20358, 'Oldwoman')

     

  5. Video:

    Code:

    import os
    import shutil
    
    source_folder = '/txt/src'
    target_folder = '/txt/src2'
    
    if not os.path.exists(target_folder):
        os.makedirs(target_folder)
    
    ifdef = '#ifdef '
    ifndef = '#ifndef '
    define = 'ENABLE_SWITCHBOT'
    
    def process_files(source_folder, target_folder):
        for entry in os.scandir(source_folder):
            if entry.is_file() and entry.name.endswith(('.cpp', '.h')):
                with open(entry.path, 'r', encoding='latin1') as file:
                    new_file = None
                    copy = False
                    lines = file.readlines()
                    line_num = 0
                    for line in lines:
                        if ifdef + define in line or ifndef + define in line:
                            copy = True
                            if not new_file:
                                new_file = open(os.path.join(target_folder, entry.name), 'w', encoding='latin1')
                            for i in range(max(0, line_num - 30), line_num):
                                new_file.write(lines[i])
                        if copy:
                            new_file.write(line)
                        if '#endif' in line:
                            if copy:
                                new_file.write("\n // =================== INNA FUNKCJA ================= \n \n")
                                new_file.write("// ====== WYSZUKAJ: ")
                                new_file.write(define)
                                new_file.write("\n// Tutorial wygenerowany automatycznie przez Grzyb.ovh \n")
                                new_file.write("\n \n")
                            copy = False
                        line_num += 1
                    if new_file:
                        new_file.close()
            elif entry.is_dir():
                new_target_folder = os.path.join(target_folder, entry.name)
                if not os.path.exists(new_target_folder):
                    os.makedirs(new_target_folder)
                process_files(entry.path, new_target_folder)
    
    process_files(source_folder, target_folder)

     

    • Metin2 Dev 2
  6. Script for scanning and automatically removing definitions

    Remove.cpp

    import os
    
    folder_path = '/txt/src'
    
    encoding = 'latin1'
    
    definition_to_remove = '#ifdef __ENABLE_OFFLINE_SHOP__'
    
    for root, dirs, files in os.walk(folder_path):
        for file in files:
            if file.endswith('.cpp') or file.endswith('.h'):
                file_path = os.path.join(root, file)
                with open(file_path, 'r', encoding=encoding) as f:
                    lines = f.readlines()
                with open(file_path, 'w', encoding=encoding) as f:
                    remove_lines = False
                    for line in lines:
                        if definition_to_remove in line:
                            remove_lines = True
                        if remove_lines:
                            if '#endif' in line:
                                remove_lines = False
                            continue
                        f.write(line)

    Remove if app.

    import os
    
    directory = '/txt/src'
    
    encoding = 'latin1'
    
    target_if = 'if app.ENABLE_OFFLINE_SHOP:'
    
    for filename in os.listdir(directory):
        if filename.endswith('.py'):
            filepath = os.path.join(directory, filename)
            with open(filepath, 'r', encoding=encoding) as f:
                lines = f.readlines()
            with open(filepath, 'w', encoding=encoding) as f:
                in_target_block = False
                target_indent = 0
                for line in lines:
                    indent = len(line) - len(line.lstrip())
                    if target_if in line:
                        in_target_block = True
                        target_indent = indent
                    elif in_target_block and indent > target_indent:
                        continue
                    else:
                        in_target_block = False
                        f.write(line)

     

    • Metin2 Dev 1
×
×
  • 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.