Best Studio 1
Best Studio
D 1
delimuratt
Aliyldrim 1
Aliyldrim
Mt2Hizmet 1
Mt2Hizmet
noisiv 1
noisiv
Manwe Work 1
Manwe Work
melankolıa18 1
melankolıa18
Agora Metin2 1
Agora Metin2
Cannn6161 1
Cannn6161
kralhakan2009 1
kralhakan2009
Vahsi Uzman 1
Vahsi Uzman
Hikaye Ekle
Reklam vermek için turkmmo@gmail.com

Cevaplanmadı language system

Black Jack36

Level 3
TM Üye
Üye
Katılım
30 May 2025
Konular
10
Mesajlar
180
Online süresi
6d 19h
Reaksiyon Skoru
59
Altın Konu
0
TM Yaşı
1 Yıl 4 Gün
Başarım Puanı
51
MmoLira
1,979
DevLira
12
Ticaret - 0%
0   0   0

ROHAN2 WORLD 1-120 TR TİPİ OFFICIAL YOHARA, BALATHOR VE AMON! 80. GÜNÜNDE! +10.000 ONLİNE! HİLE VE BOT %100 ENGELLİ HEMEN TIKLA!

Hello
I'm using this version and it's good, but I have one problem with its language system; it's very buggy.


The problem is that the locale_quest.txt file prints text literally. For example, if it finds text containing %d symbols, it prints the text exactly as it appears. For example:
6704 %d hediyeden %d hediye daha açabilirsin.

It appears in the chat like this:

%d hediyeden %d hediye daha açabilirsin.

Although the `%d` symbol is supposed to change the number of remaining occurrences, and the user does the same with the `%s` symbol, the symbol appears, but the time or the number that should be displayed is not. After some research and careful consideration, I discovered that I have to go to each task on the server side and add this command to every string containing the aforementioned symbols (`string.format`). However, it is extremely tedious to go to each task to add the text, and the command might work on one line but not another, unlike other programming languages where it works automatically.

I tried searching on the source server side and found functions responsible for the command, and I also searched on the client source side and found functions responsible for the command, but my mind went blank at that moment. When I asked the AI, it told me to modify the function on the server, then it told me not to modify anything on the server and to modify the function in the client source. I am confused. Therefore, I hope someone can help me with this matter. Thank you.

All the information I searched for and found

Kod:
bool CPythonNetworkStream::LoadLocaleQuestVnum(const char* c_szLocaleQuestFileName)
{
    CMappedFile file;
    const VOID* pvData;

    if (!CEterPackManager::Instance().Get(file, c_szLocaleQuestFileName, &pvData))
    {
        Tracef("CPythonNetworkStream::LoadLocaleQuestVnum(c_szLocaleQuestFileName=%s) - Load Error", c_szLocaleQuestFileName);
        return false;
    }

    CMemoryTextFileLoader kMemTextFileLoader;
    kMemTextFileLoader.Bind(file.Size(), pvData);

    m_kMap_dwID_strLocaleQuest.clear();

    CTokenVector TokenVector;
    for (DWORD i = 0; i < kMemTextFileLoader.GetLineCount(); ++i)
    {
        if (!kMemTextFileLoader.SplitLineByTab(i, &TokenVector))
            continue;

        const char* c_szComment = "#";
        if (TokenVector[0].compare(0, 1, c_szComment) == 0 || TokenVector.size() != 2)
            continue;

        m_kMap_dwID_strLocaleQuest.insert(std::make_pair(atoi(TokenVector[0].c_str()), TokenVector[1]));
    }

    return true;
}

const char* CPythonNetworkStream::GetLocaleQuestVnum(DWORD dwVnum)
{
    std::map<DWORD, std::string>::iterator it = m_kMap_dwID_strLocaleQuest.find(dwVnum);

    static char s_szChat[1024 + 1] = "";
    if (it != m_kMap_dwID_strLocaleQuest.end())
    {
        sprintf(s_szChat, "%s", it->second.c_str());
    }

    return s_szChat;
}

Kod:
void LoadLocaleQuest(const char* c_szFileName, BYTE bLocale)
{
    FILE* pFile = nullptr;
    if (nullptr == (pFile = fopen(c_szFileName, "r")))
        return;

    gLocaleQuestMapType[bLocale].clear(); // Support for resetting the map type.

    static SToken sToken = { 0, "" };
    BYTE bToken = 0;

    char szLine[BUFSIZ] = { 0 }, * pBuf = nullptr;
    while (fgets(szLine, BUFSIZ, pFile))
    {
        // Tokenise the read line, using "\" delimiter*/
        pBuf = strtok(szLine, "\t");
        sToken.dwVNum = std::atol(pBuf);

        while (nullptr != (pBuf = strtok(nullptr, "\n")))
        {
            bToken++;
            // Store the tokens as per structure members , where (i == 0) is first member and so on...
            if (bToken == 1)
                sToken.stString = pBuf;
        }

        gLocaleQuestMapType[bLocale].emplace(std::make_pair(sToken.dwVNum, sToken.stString));

        sToken.stString.clear(); // Clear last string.
        bToken = 0; // Reset token value of iToken.
    }
    fclose(pFile);
}
const char* FindLocaleQuest(DWORD dwVNum, BYTE bLocale)
{
    LocaleMapType::iterator it = gLocaleQuestMapType[bLocale].find(dwVNum);
    if (it != gLocaleQuestMapType[bLocale].end())
        return it->second.c_str();
    return c_stDefaultString.c_str();
}
 
From what you described, this does not look like a `locale_quest.txt` problem itself.

Most likely, `locale_quest.txt` is only used as a lookup table:
`id -> text template`

So if the stored text contains `%d` or `%s`, it will stay literal unless something else formats it with real values.

In other words:

- `locale_quest.txt` does not automatically replace `%d` / `%s`
- the function that reads it usually just returns the raw string
- formatting must happen where the real values are known

So in your case, if the system only does:
- read text from `locale_quest.txt`
- send/display that text directly

then `%d` will appear exactly as `%d`.

That is why `string.format(...)` works: it is the part that actually injects the numbers/strings.

So the likely answer is:
- not a client text bug by itself
- not a `locale_quest.txt` syntax bug by itself
- the missing part is formatting before sending/displaying

If your quest system supports it, the cleaner solution is usually to make a helper/wrapper such as:
`locale_quest_format(id, ...)`
which does:
1. get the text from `locale_quest`
2. apply `string.format`
3. return the final string

That way you do not have to manually rewrite everything in random places.

So yes: based on the code you posted, the issue is probably not “wrong text loading”, but “text is loaded, but never formatted”.
 
are you sending arguments from the serverside? if that that's why
 
From what you described, this does not look like a `locale_quest.txt` problem itself.

Most likely, `locale_quest.txt` is only used as a lookup table:
`id -> text template`

So if the stored text contains `%d` or `%s`, it will stay literal unless something else formats it with real values.

In other words:

- `locale_quest.txt` does not automatically replace `%d` / `%s`
- the function that reads it usually just returns the raw string
- formatting must happen where the real values are known

So in your case, if the system only does:
- read text from `locale_quest.txt`
- send/display that text directly

then `%d` will appear exactly as `%d`.

That is why `string.format(...)` works: it is the part that actually injects the numbers/strings.

So the likely answer is:
- not a client text bug by itself
- not a `locale_quest.txt` syntax bug by itself
- the missing part is formatting before sending/displaying

If your quest system supports it, the cleaner solution is usually to make a helper/wrapper such as:
`locale_quest_format(id, ...)`
which does:
1. get the text from `locale_quest`
2. apply `string.format`
3. return the final string

That way you do not have to manually rewrite everything in random places.

So yes: based on the code you posted, the issue is probably not “wrong text loading”, but “text is loaded, but never formatted”.
Indeed, it's as you explained in detail.

And the AI told me the same thing. Therefore, I want a quick solution, for example, modifying or adding a new function that automatically formats the sentence instead of going to each line containing %d, modifying its main text, and adding a string.format function. That's why I posted this; maybe someone has found a solution to this problem. For example, creating a new function that formats according to the main function that prints the text as is. I hope you understand me because if I continue with the current method, I have to go to each line that depends on %d and add a string.format. For example, the text in the previous task was like this: `syschat(locale_quest(6705, string.format("%d", 31 - t / 60)))`. I had to go to the text and modify it manually to become like this: `syschat(string.format(locale_quest(6705), math.floor(31 - t / 60)))

So I'm trying to find a way to do this without having to go through each task and edit it. Is that possible?
 

Şu an konuyu görüntüleyenler (Toplam : 0, Üye: 0, Misafir: 0)

Geri
Üst