• 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!

OTClient Can someone explain me how I send information from server to OTC?

Marko999x

999x era
Premium User
Joined
Dec 14, 2017
Messages
2,864
Solutions
82
Reaction score
1,967
Location
Germany
I can not find any right tutorial at all so im asking you :D

Lets say I got as example a function called player:getReborn()
How can I send this to the client?
Or do I have to create a extra function for that in OTC?
Im kinda confused
 
this is the best tutorial

1712469710688.png
ignore creature.h . creature.cpp


You can also use the typical opcode.
 
Last edited:
I can not find any right tutorial at all so im asking you :D

Lets say I got as example a function called player:getReborn()
How can I send this to the client?
Or do I have to create a extra function for that in OTC?
Im kinda confused
I'd go with something like using opcodes or sending requests from the client and receiving them using the protocol behavior, I suppose
 
Also as example Im using this system:

How do I send in that case now the information to the client about the monster level?
Im pretty new if it comes to otclient and its a little bit confusing for me to be honest :D
 
Also as example Im using this system:

How do I send in that case now the information to the client about the monster level?
Im pretty new if it comes to otclient and its a little bit confusing for me to be honest :D
it would be sent in ProtocolGame::AddCreature server side
and received in ProtocolGame::getCreature on client side
 
it would be sent in ProtocolGame::AddCreature server side
and received in ProtocolGame::getCreature on client side

Isn't it easier to print it somehow as example
I got function to see the monster level which is creature:getMonsterLevel()
then send this as extenenOpCode?
As example
Lua:
function creatureEvent.onExtendedOpcode(creature, opcode, buffer)
    local monsterLvl = creature:getMonsterLevel()
    creature:sendExtendedOpcode(52, monsterLvl)
    return true
end
Maybe I understand this whole system wrong lol :D
 
Isn't it easier to print it somehow as example
I got function to see the monster level which is creature:getMonsterLevel()
then send this as extenenOpCode?
As example
Lua:
function creatureEvent.onExtendedOpcode(creature, opcode, buffer)
    local monsterLvl = creature:getMonsterLevel()
    creature:sendExtendedOpcode(52, monsterLvl)
    return true
end
Maybe I understand this whole system wrong lol :D
are you trying to send monster level to use as a title?
 
this should do it,

C++:
void ProtocolGame::AddCreature(NetworkMessage& msg, const Creature* creature, bool known, uint32_t remove)
{
    CreatureType_t creatureType = creature->getType();

    const Player* otherPlayer = creature->getPlayer();

    if (known) {
        msg.add<uint16_t>(0x62);
        msg.add<uint32_t>(creature->getID());
    } else {
        msg.add<uint16_t>(0x61);
        msg.add<uint32_t>(remove);
        msg.add<uint32_t>(creature->getID());
        msg.addByte(creatureType);
        const Monster* monster = creature->getMonster();
        if (monster && monster->getLevel() > 0) {
            msg.addString(creature->getName() + " [" + std::to_string(monster->getLevel()) + "]");
            msg.add<uint32_t>(monster->getLevel());
        }
        else {
            msg.addString(creature->getName());
            msg.add<uint32_t>(0);
        }
    }


now on client side

C++:
            std::string name = g_game.formatCreatureName(msg->getString());
            uint levelMob = msg->getU32(); // getMobLevel

            if (creature) {
                creature->setName(name);
            } else {
                if (id == m_localPlayer->getId())
                    creature = m_localPlayer;
                else if (creatureType == Proto::CreatureTypePlayer) {
                    // fixes a bug server side bug where GameInit is not sent and local player id is unknown
                    if (m_localPlayer->getId() == 0 && name == m_localPlayer->getName())
                        creature = m_localPlayer;
                    else
                        creature = PlayerPtr(new Player);
                } else if (creatureType == Proto::CreatureTypeMonster)
                    creature = MonsterPtr(new Monster);
                else if (creatureType == Proto::CreatureTypeNpc)
                    creature = NpcPtr(new Npc);
                else if (creatureType == Proto::CreatureTypeSummonOwn) {
                    creature = MonsterPtr(new Monster);
                } else
                    g_logger.traceError("creature type is invalid");

                if (creature) {
                    creature->setId(id);
                    creature->setName(name);
                    if (levelMob > 0) {
                        Color color("#34ebe8");
                        creature->setTitle(std::to_string(levelMob), "verdana-11px-rounded", color);
                    }

                    g_map.addCreature(creature);
                }
            }
        }


you can also add a method to send title color from server side
another way can be to make a module that will remove level from name and convert it to a title for example
Post automatically merged:

1712632739667.png
tested and works
 
Last edited:
Back
Top