Autor: Blizzar?aviD
Opis:
Kod przez kt?ry mo?emy pisa? na czerwono do gracza, a reszta tego nie widzi. Dzia?a to tak: /msg Nick, Tre?? np. /msg Typek, Elo
Tylko gracz o nicku Typek b?dzie widzia? wiadomo?? na czerwono. Wa?ny jest ten przecinek po nicku, bo inaczej wiadomo?? nie zostanie wys?ana.
Kod:
W commands.cpp pod:
[CPP] {"/reload",&Commands::reloadInfo},[/CPP]
Dodaj:
[CPP] {"/msg",&Commands::gadkaBDD},[/CPP]
W commands.cpp na samym dole dodaj:
[CPP]bool Commands::gadkaBDD(Creature* c, const std::string &cmd, const std::string ¶m)
{
std::string tmp = param;
std::string::size_type pos;
std::string message;
pos = tmp.find(",");
std::string name = tmp.substr(0, pos).c_str();
tmp.erase(0, pos+1);
message = tmp;
Creature* creature = game->getCreatureByName(name);
Player* target = creature? dynamic_cast<Player*>(creature) : NULL;
Player* player = dynamic_cast<Player*>(c);
if(target){
target->sendTextMessage(MSG_RED_TEXT, message.c_str());
}else{
player->sendTextMessage(MSG_SMALLINFO, "Gracz nie jest wlogowany.");}
return true;
}[/CPP]
W commands.h pod:
[CPP] bool kickPlayer(Creature* c, const std::string &cmd, const std::string ¶m);[/CPP]
dodaj:
[CPP] bool gadkaBDD(Creature* c, const std::string &cmd, const std::string ¶m);[/CPP]
Przebudowa? projekt i gotowe.
Testowany na YurOTS 0.9.4f, dzia?a bezproblemowo.
Opis:
Kod przez kt?ry mo?emy pisa? na czerwono do gracza, a reszta tego nie widzi. Dzia?a to tak: /msg Nick, Tre?? np. /msg Typek, Elo
Tylko gracz o nicku Typek b?dzie widzia? wiadomo?? na czerwono. Wa?ny jest ten przecinek po nicku, bo inaczej wiadomo?? nie zostanie wys?ana.
Kod:
W commands.cpp pod:
[CPP] {"/reload",&Commands::reloadInfo},[/CPP]
Dodaj:
[CPP] {"/msg",&Commands::gadkaBDD},[/CPP]
W commands.cpp na samym dole dodaj:
[CPP]bool Commands::gadkaBDD(Creature* c, const std::string &cmd, const std::string ¶m)
{
std::string tmp = param;
std::string::size_type pos;
std::string message;
pos = tmp.find(",");
std::string name = tmp.substr(0, pos).c_str();
tmp.erase(0, pos+1);
message = tmp;
Creature* creature = game->getCreatureByName(name);
Player* target = creature? dynamic_cast<Player*>(creature) : NULL;
Player* player = dynamic_cast<Player*>(c);
if(target){
target->sendTextMessage(MSG_RED_TEXT, message.c_str());
}else{
player->sendTextMessage(MSG_SMALLINFO, "Gracz nie jest wlogowany.");}
return true;
}[/CPP]
W commands.h pod:
[CPP] bool kickPlayer(Creature* c, const std::string &cmd, const std::string ¶m);[/CPP]
dodaj:
[CPP] bool gadkaBDD(Creature* c, const std::string &cmd, const std::string ¶m);[/CPP]
Przebudowa? projekt i gotowe.
Testowany na YurOTS 0.9.4f, dzia?a bezproblemowo.