EOSERV Wiki > Page: Adding Commands to your Server by Lolss > History > Revision Diff

Revision Diff: Adding Commands to your Server by Lolss

Revision by at 15th Jan 2012 12:26 pm
DeletionsAdditions
ORIGINAL POST: http://eoserv.net/forum/topic/13664
First of all I would like to say that this guide is for REV 196 and below. I might update it later on for revs 229+!
This is a quick guide on how to add player commands to your server. First thing you will need to do :
Open your trunk folder.
Now click on Project folder. Then there should be a few files inside that folder. The one you want to click on is "mingw".
Once you click on it, many of your src files will be opening. Once it is fully loaded what you are wanting to do is click on "Sources" then click on "handlers" then click on "Talk.cpp".
Now that your Talk.cpp is open you can search for certain codes:
Press CTRL + F and type in "up" and then thats around where you should be adding your code.
Your code should be directly under neith the following code:
this->player->character->ServerMsg(buffer);
}
For example you want to add a title command you will want to make it look like this:
else if (command.length() >= 2 && command.compare(0,2,"up") == 0 && this->player->character->admin >= static_cast<int>(this->server->world->admin_config["uptime"]))
{
std::string buffer = "Server started ";
buffer += util::timeago(this->server->start, Timer::GetTime());
this->player->character->ServerMsg(buffer);
}
if (command.length() >= 5 && command.compare(0,5,"title") == 0 && arguments.size() >= 1)
{
std::string ntitle;
std::transform(arguments[0].begin(), arguments[0].end(), arguments[0].begin(), static_cast<int(*)(int)>(std::tolower));
for(int i = 0;i<arguments.size();i++)
{
if(ntitle == "")
{
ntitle = arguments[i];
}
else
{
ntitle += " " + arguments[i];
}
if (ntitle.length() > 32)
{
ntitle = ntitle.substr(0, 32);
}
this->player->character->title = ntitle;
}
}
You can find a list of player commands here. And once you are done adding what you like it is time to compile and then once it is all compiled it is ready to play your game withthecommands!
EOSERV Wiki > Page: Adding Commands to your Server by Lolss > History > Revision Diff