• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

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

SixNine

Active Member
Joined
Dec 12, 2018
Messages
407
Reaction score
33
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...

kor

PHP ziom
Premium User
Joined
Jul 12, 2008
Messages
205
Solutions
13
Reaction score
316
Location
Bialystok, Poland
GitHub
rookgaard
YouTube
Rookgaard
@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
OP
OP
SixNine

SixNine

Active Member
Joined
Dec 12, 2018
Messages
407
Reaction score
33
@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>
 
Top