• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[TFS] /invisible 8.0

slaw

Software Developer
Joined
Aug 27, 2007
Messages
3,663
Solutions
125
Reaction score
1,109
Location
Germany
GitHub
slawkens
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
Code:
{"/ghost", &Commands::ghost},
add
Code:
{"/invisible", &Commands::setInvisible},
in end of the file, after
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;
}
add
Code:
bool Commands::setInvisible(Creature* creature, const std::string &cmd, const std::string &param)
{
    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;
}
commands.h
after
Code:
bool ghost(Creature* creature, const std::string& cmd, const std::string& param);
add
Code:
bool setInvisible(Creature* creature, const std::string &cmd, const std::string &param);
creature.cpp
after
Code:
scriptEventsBitField = 0;
add
Code:
gmInvisible = false;
game.cpp
after
Code:
    Thing* thing = internalGetThing(player, pos, stackPos, spriteId, STACKPOS_LOOK);
    if(!thing)
    {
        player->sendCancelMessage(RET_NOTPOSSIBLE);
        return false;
    }
add
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;
        }
    }
creature.h
after
Code:
    bool registerCreatureEvent(const std::string& name);
add
Code:
    bool gmInvisible;
tile.h
cut out
Code:
void onUpdateTile()
from private
And add 6 lines above. After this:
Code:
virtual bool isRemoved() const {return false;}
protocol80.cpp or protocolgame.cpp (if using last sources)
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());
    }
add
Code:
    if(creature->gmInvisible)
        msg->AddByte(0);
    else
It will be good, if someone will test it, becouse i'm not 100% sure that i added here all what is needed.
 
Last edited by a moderator:
Works but you forgot

commands.h
Code:
bool setInvisible(Creature* creature, const std::string &cmd, const std::string &param);

and I had to change
tile.h
Code:
void onUpdateTile();

from private to public, 6 rows above
under:
Code:
virtual bool isRemoved() const {return false;}




One bug only, the name and HP bar is still shown
 
Sure, i just forgot about it ;)

@1 post edited.

Hmm HP bar and name isnt show if you're using official client. But if you using any edited with mc and other tools then yes..
 
Last edited:
I cant belive. 8.0? So if i don't see then you should too don't see. I will check later, meybe i didn't give here some lines.
 
I cant belive. 8.0? So if i don't see then you should too don't see. I will check later, meybe i didn't give here some lines.

You forgot the protocolgame.cpp part, you have to send 0 instead of players health points percent.
 
Working now, thanks! :)
(a minor bug is that I appear with a different outfit after being visible again, but it's not important)

So code it and include to the TFS official sources :p

Yes plx ^^

@slawkens
Alright then :)
 
Last edited:
I'll give, but i'm not 100% sure it was made by him. It is in Devland yes, but we don't know that he coded it.

@SaLeM
It is specially for 8.0, for 8.1 is new thing - invisible outfits so there is easiest way to do it, and i quess it won't be included to TFS.
 
Nice one, but since I use 2 monster functions such as showHealth I use that one in protocol :p
 
Does it work for the latest revision? I mean especially this name and hp bar. (on 8.0) Is it already solved or not yet?
 
Rev is actually not important. It will work for 8.0 :) (hp bar solved)
 
The server crashes when I go into invisible.

I also did as drosah said since it said targePlayer is not declared anywhere.
 
same like Lejjo i get debug and i did same as drosah said coz i got a bug when i had
else
EDIT #1 : is it for 8.0 only? nor 8.1 nor 8.11
 
Last edited:
It's for 8.0 like Slawkens told before, but there is a invisble mode already build in tfs for 8.1~
 
Back
Top