This might be very confusing for the most people but it is alot easier than you think. This can be very important on EOserv. Imagine that you are coding for an Endless Online server and the owner asks you: Can you makeaserver message for me? Being read from a config. Than you would say alright i will do that. But than is the question: How? A string saves a certain amount of text. Sounds easy right? For example:
| This might be very confusing for the most people but it is alot easier than you think. This can be very important on EOserv. Imagine that you are coding for an Endless Online server and the owner asks you: Can you make a server message for me? Being read from a config. Than you would say alright i will do that. But than is the question: How? A string saves a certain amount of text. Sounds easy right? For example:
|
this->player->character->ServerMsg(static_cast<std::string>(this->server->world->message_config["ServerMsg"]));
| <pre>this->player->character->ServerMsg(static_cast<std::string>(this->server->world->message_config["ServerMsg"]));</pre>
|
EOserv/Data/Message.ini
ServerMsg = Hello world!
| <pre>EOserv/Data/Message.ini
ServerMsg = Hello world!</pre>
|
As you see there is a <std::string> after the static_cast. The std::string will make it read an amount of text. Which is NOT being used for ints (Numbers) Before i knew this i always failed in making configs... So it is pretty easy you just have to remind: If you makeaconfig for like a serverMsg or a #rules command or w/e use <std::string> and not: <int>
| As you see there is a <std::string> after the static_cast. The std::string will make it read an amount of text. Which is NOT being used for ints (Numbers) Before i knew this i always failed in making configs... So it is pretty easy you just have to remind: If you make a config for like a serverMsg or a #rules command or w/e use <std::string> and not: <int>
|
## Gambling ##
| <pre>## Gambling ##
|
Amount = 100
| Amount = 100</pre>
|
int Reward;
Reward = static_cast<int>(this->server->world->test_config[util::to_string(i+1) + ".Reward"]);
| <pre>int Reward;
Reward = static_cast<int>(this->server->world->test_config[util::to_string(i+1) + ".Reward"]);</pre>
|
Reward = 5412328508984
| <pre>Reward = 5412328508984</pre>
|
Static_cast<std::string>
| <pre>Static_cast<std::string></pre>
|
Reward = Hello my name is hollow
| <pre>Reward = Hello my name is hollow</pre>
|
if(this->player->character->HasItem(5))
| <pre>if(this->player->character->HasItem(5))
|
| </pre>
|
if(this->player->character->HasItem(CookID))
| <pre>if(this->player->character->HasItem(CookID))</pre>
|
intAmount;
int Reward;
| <pre>intAmount;
int Reward;</pre>
|