slaw
Software Developer
There is already /ghost command but working only on 8.1, i have server on 8.0 so i needed somethink for this protocol which make me invisible to players.
Tested only on TFS.
commands.cpp
after
add
in end of the file, after
add
commands.h
after
add
creature.cpp
after
add
game.cpp
after
add
creature.h
after
add
tile.h
cut out
from private
And add 6 lines above. After this:
protocol80.cpp or protocolgame.cpp (if using last sources)
After
add
It will be good, if someone will test it, becouse i'm not 100% sure that i added here all what is needed.
Tested only on TFS.
commands.cpp
after
Code:
{"/ghost", &Commands::ghost},
Code:
{"/invisible", &Commands::setInvisible},
Code:
bool Commands::ghost(Creature* creature, const std::string& cmd, const std::string& param)
{
Player* player = creature->getPlayer();
if(player)
{
player->ghostMode = !player->ghostMode;
char buffer[60];
sprintf(buffer, "You have switched ghost mode mode to: %s.", (player->ghostMode ? "enabled" : "disabled"));
if(player->ghostMode)
{
const int32_t invisibleOutfit = 280;
g_game.internalCreatureChangeOutfit(creature, (const Outfit_t&)invisibleOutfit);
}
player->sendTextMessage(MSG_INFO_DESCR, buffer);
return true;
}
return false;
}
Code:
bool Commands::setInvisible(Creature* creature, const std::string &cmd, const std::string ¶m)
{
Player* gm = creature->getPlayer();
Outfit_t outfit;
if(!gm)
return false;
if (gm->gmInvisible) {
outfit.lookType = 75;
g_game.internalCreatureChangeOutfit(gm, outfit);
gm->gmInvisible = false;
gm->sendTextMessage(MSG_EVENT_ADVANCE,"You are Visible again.");
creature->getTile()->onUpdateTile();
}
else
{
Outfit_t outfit;
outfit.lookTypeEx = 4390;
g_game.internalCreatureChangeOutfit(gm, outfit);
gm->gmInvisible = true;
gm->sendTextMessage(MSG_EVENT_ADVANCE,"You are Invisible.");
creature->getTile()->onUpdateTile();
}
return true;
}
after
Code:
bool ghost(Creature* creature, const std::string& cmd, const std::string& param);
Code:
bool setInvisible(Creature* creature, const std::string &cmd, const std::string ¶m);
after
Code:
scriptEventsBitField = 0;
Code:
gmInvisible = false;
after
Code:
Thing* thing = internalGetThing(player, pos, stackPos, spriteId, STACKPOS_LOOK);
if(!thing)
{
player->sendCancelMessage(RET_NOTPOSSIBLE);
return false;
}
Code:
if(Creature* lookCreature = thing->getCreature()){
Player* lookPlayer = lookCreature->getPlayer();
if(lookCreature->gmInvisible){
player->sendCancelMessage(RET_NOTPOSSIBLE);
lookPlayer->sendTextMessage(MSG_INFO_DESCR, "Someone try to look at You.");
return false;
}
}
after
Code:
bool registerCreatureEvent(const std::string& name);
Code:
bool gmInvisible;
cut out
Code:
void onUpdateTile()
And add 6 lines above. After this:
Code:
virtual bool isRemoved() const {return false;}
After
Code:
void ProtocolGame::AddCreature(NetworkMessage* msg, const Creature* creature, bool known, uint32_t remove)
{
if(known)
{
msg->AddU16(0x62);
msg->AddU32(creature->getID());
}
else
{
msg->AddU16(0x61);
msg->AddU32(remove);
msg->AddU32(creature->getID());
msg->AddString(creature->getName());
}
Code:
if(creature->gmInvisible)
msg->AddByte(0);
else
Last edited by a moderator: