• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.2 game.cpp "Expected ')' before 'minimumLevel' "

SixNine

Active Member
Joined
Dec 12, 2018
Messages
442
Reaction score
40
TFS 1.2 game.cpp

C++:
player->sendTextMessage(MESSAGE_STATUS_SMALL, "You may not send private messages unless you have reached level {:d} or have a premium account." minimumLevel);

tried adding , before minimumLevel but gives even more errors, then though about using different way of sending message but not sure if its correct way
C++:
                    std::ostringstream ss;
                    ss << "You may not send private messages unless you have reached level " << minimumLevel<< " or have a premium account.";
                    player->sendTextMessage(MESSAGE_STATUS_SMALL, ss.str());
Post automatically merged:

Nvm this option
C++:
                    std::ostringstream ss;                    ss << "You may not send private messages unless you have reached level " << minimumLevel<< " or have a premium account.";                    player->sendTextMessage(MESSAGE_STATUS_SMALL, ss.str());
does work. You can close thread
 
Last edited:
Solution
@SixNine It's because you're not using this properly. It should be
C++:
player->sendTextMessage(MESSAGE_STATUS_SMALL, fmt::format("You may not send private messages unless you have reached level {:d} or have a premium account.", minimumLevel));

similar to this line for example forgottenserver/chat.cpp at master · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/master/src/chat.cpp#L54)

Using ostringstream is older and longer approach (3 lines vs 1 line). Also, remember to add #include <fmt/format.h> in file where you will use fmt::format like here forgottenserver/chat.cpp at master · otland/forgottenserver...
@SixNine It's because you're not using this properly. It should be
C++:
player->sendTextMessage(MESSAGE_STATUS_SMALL, fmt::format("You may not send private messages unless you have reached level {:d} or have a premium account.", minimumLevel));

similar to this line for example forgottenserver/chat.cpp at master · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/master/src/chat.cpp#L54)

Using ostringstream is older and longer approach (3 lines vs 1 line). Also, remember to add #include <fmt/format.h> in file where you will use fmt::format like here forgottenserver/chat.cpp at master · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/master/src/chat.cpp#L27).
 
Solution
@SixNine It's because you're not using this properly. It should be
C++:
player->sendTextMessage(MESSAGE_STATUS_SMALL, fmt::format("You may not send private messages unless you have reached level {:d} or have a premium account.", minimumLevel));

similar to this line for example forgottenserver/chat.cpp at master · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/master/src/chat.cpp#L54)

Using ostringstream is older and longer approach (3 lines vs 1 line). Also, remember to add #include <fmt/format.h> in file where you will use fmt::format like here forgottenserver/chat.cpp at master · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/master/src/chat.cpp#L27).
Thanks, yea i was getting error related to fmt::format, didnt knew that it needs too use #include <fmt/format.h>
 
Back
Top