What's new

-Tibia 7.60 MC Checkall

Status
Not open for further replies.

Saelasti

Advanced User
Joined
Apr 1, 2014
Messages
192
Reaction score
25
Dalej.


Autor: Nieznany
Autor Monitoring Systemu: Blizzar?aviD
Modyfikacja (pl): Blizzar?aviD
Link ?rod?owy: LINK
Testowany na: YurOTS 0.4.9f
Opis: Jest to komenda pozwalaj?ca na jednoczesne sprawdzenie u wszystkich wlogowanych graczy u?ywania MultiClienta (MC). Wystarczy napisa? /checkall. Po tym wy?wietlona zostanie lista postaci u?ywaj?cych MC wraz z ich adresami IP. Dzi?ki adresom mo?na b?dzie rozr??ni?, kt?re postacie nale?? do danej osoby.
Jest to komenda bez crashowa, wi?c bezpieczna.


Kod:
1. w commands.cpp
pod:
[CPP]{"/closeserver",&Commands::closeServer},[/CPP]
dodaj:
[CPP]{"/checkall",&Commands::mcCheckall},[/CPP]

2. w commands.cpp
na samym dole pliku dodaj:
[CPP]// MC Check all
bool Commands::mcCheckall(Creature* creature, const std::string& cmd, const std::string& param)
{
Player *player = dynamic_cast<Player*>(creature);
std::stringstream info;
unsigned char ip[4];

if(player){
info << "Gracze uzywajacy MC: \n";
info << "Nick IP" << "\n";
for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++it){
Player* lol = (*it).second;
for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++it){
if((*it).second != lol && (*it).second->lastip == lol->lastip){
*(unsigned long*)&ip = (*it).second->lastip;

info << (*it).second->getName() << " " << (unsigned int)ip[0] << "." << (unsigned int)ip[1] <<
"." << (unsigned int)ip[2] << "." << (unsigned int)ip[3] << "\n";
}
}
}
player->sendTextMessage(MSG_RED_TEXT, info.str().c_str());

}
else{
return false;
}

return true;
}
[/CPP]

3. w commands.h
pod:
[CPP]bool closeServer(Creature* c, const std::string &cmd, const std::string &param);[/CPP]
dodaj:
[CPP]bool mcCheckall(Creature* creature, const std::string& cmd, const std::string& param);[/CPP]

4. w data\commands.xml
mi?dzy innymi linijkami dodaj:
[XML]<command cmd="/checkall" access="1" />[/XML]

Projekt przebudowa? (Ctrl+F11), zapisa? commands.xml i gotowe.


Dodatkowe opcje:
a) Je?eli chcemy, aby ka?de u?ycie tej komendy (przez postacie uprawnione do niej) by?o rejestrowane w pliku.log (Monitoring System),
1. w commands.cpp
zamie?:
[CPP]// MC Check all
bool Commands::mcCheckall(Creature* creature, const std::string& cmd, const std::string& param)
{
Player *player = dynamic_cast<Player*>(creature);
std::stringstream info;
unsigned char ip[4];

if(player){
info << "Gracze uzywajacy MC: \n";
info << "Nick IP" << "\n";
for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++it){
Player* lol = (*it).second;
for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++it){
if((*it).second != lol && (*it).second->lastip == lol->lastip){
*(unsigned long*)&ip = (*it).second->lastip;

info << (*it).second->getName() << " " << (unsigned int)ip[0] << "." << (unsigned int)ip[1] <<
"." << (unsigned int)ip[2] << "." << (unsigned int)ip[3] << "\n";
}
}
}
player->sendTextMessage(MSG_RED_TEXT, info.str().c_str());

}
else{
return false;
}

return true;
} [/CPP]
na:
[CPP]// MC Check all
bool Commands::mcCheckall(Creature* creature, const std::string& cmd, const std::string& param)
{
Player *player = dynamic_cast<Player*>(creature);
std::stringstream info;
unsigned char ip[4];

if(player){
info << "Gracze uzywajacy MC: \n";
info << "Nick IP" << "\n";
for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++it){
Player* lol = (*it).second;
for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++it){
if((*it).second != lol && (*it).second->lastip == lol->lastip){
*(unsigned long*)&ip = (*it).second->lastip;
//----------------- BDD Monitoring System ok -----------------------------------
{ char buf[64];
time_t ticks = time(0);
unsigned char ip[4];
#ifdef USING_VISUAL_2005
tm now;
localtime_s(&now, &ticks);
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M", &now);
#else
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M", localtime(&ticks));
#endif //USING_VISUAL_2005
std::eek:fstream out("uwagi/komendy/checkall.log", std::ios::app);
out << "[" << buf << "] " << player->getName() << ": /checkall (" << (*it).second->getName() << ") " << (unsigned int)ip[0] << "." << (unsigned int)ip[1] << "." << (unsigned int)ip[2] << "." << (unsigned int)ip[3] << std::endl;
out.close();}
//----------------- End BDD Monitoring System -----------------------------------
info << (*it).second->getName() << " " << (unsigned int)ip[0] << "." << (unsigned int)ip[1] <<
"." << (unsigned int)ip[2] << "." << (unsigned int)ip[3] << "\n";
}
}
}
player->sendTextMessage(MSG_RED_TEXT, info.str().c_str());

}
else{
return false;
}

return true;
} [/CPP]


2. utw?rz kolejno foldery: data\uwagi\komendy

Po dodaniu tego kodu i u?yciu tej komendy, w pliku data\uwagi\komendy\checkall.log pojawi si? wpis:
[RRRR-MM-DD gg:mm] Nick_1: /checkall (Nick_2) Adres_IP

,gdzie:
RRRR-MM-DD gg:mm - data i godzina, w kt?rej u?yto tej komendy,
Nick_1 - Nick postaci wpisuj?cej t? komend?,
Nick_2 - Nicki postaci korzystaj?cych z MC,
Adres_IP - Adres IP postaci korzystaj?cych z MC.

Jednocze?nie po jednorazowym u?yciu komendy pojawi si? kilka linijek w checkall.log, r??ni?cych si? od siebie tylko Nick'iem_2 i Adresem_IP. Powodem tego jest fakt, ?e na jedn? linijk? wpisu mo?e by? zarejestrowana tylko jedna posta?.

Uwaga, komenda nie b?dzie rejestrowana, gdy:
> nie ma ?adnych os?b korzystaj?cych z MC
> Nick_1 ma access ni?szy od wymaganego do u?ycia tej komendy.

b) Aby zmieni?, kto mo?e u?ywa? tej komendy (jest do niej upowa?niony),
w data\commands.xml, w linijce:
[XML]<command cmd="/checkall" access="1" />[/XML]
cyfr? 1 zamieni? na wybran? poni?ej:
[CPP]Accessy:
0 - P - Player (gracz)
1 - T - Tutor (tutor)
2 - S - Senior Tutor (starszy tutor)
3 - GM - GameMaster (mistrz gry)
4 - SGM - Senior GameMaster (starszy mistrz gry)
5 - God/H - God/Hoster (hoster)[/CPP]


Uwaga, ka?dy wy?szy access od ustalonego b?dzie m?g? u?ywa? tej komendy (np. je?eli ustawili?my na 1, czyli tutora, to gracz nie b?dzie jej m?g? u?ywa?, natomiast ST, GM, SGM i God/H ju? tak.
 
Status
Not open for further replies.
Top