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

C++ [c++][1.5] Function only applicable to OTC

kaincer

Member
Joined
Jun 28, 2010
Messages
44
Reaction score
5
How can I make an if function so that it can only be seen in OTC(if I don't have player or creature as argument)?
networkmessage.cpp
in this example void NetworkMessage::addItem(const Item* item)
I don't have the creature or player argument

my goal is that
C++:
void NetworkMessage::addItem(const Item* item)
{
const ItemType& it = Item::items[item->getID()];
    //if Cliente otc {
                           addString(item->getShader()); // ONLY can applicable to OTC. why? Oldclient crash
    //}

👇only apply in OTC
C++:
                           addString(item->getShader());




------------------------------------------------------------- Me fails------------------------------------------
Fail Number 1 : Creature is undefined
C++:
void NetworkMessage::addItem(const Item* item)
{
const ItemType& it = Item::items[item->getID()];
const Player* player = creature->getPlayer();

    if (player->getOperatingSystem() >= CLIENTOS_OTCLIENT_LINUX) {
        addString(item->getShader());
    }


Fail Number 2 : does not print anything
C++:
void NetworkMessage::addItem(const Item* item)
{
   const ItemType& it = Item::items[item->getID()];
   SpectatorVec spectators;
    g_game.map.getSpectators(spectators, getPosition(), false, true, 1, 1, 1, 1);
    for (Creature* spectator : spectators) {
        std::cout << "Client is: " << spectator->getPlayer()->getOperatingSystem() << std::endl;
        if (spectator->getPlayer()->getOperatingSystem() >= CLIENTOS_OTCLIENT_LINUX) {
            addString(item->getShader());
        }
    }
Fail Number 3 : does not print anything

C++:
void NetworkMessage::addItem(const Item* item)
{
const ItemType& it = Item::items[item->getID()];
OperatingSystem_t operatingSystem = static_cast<OperatingSystem_t>(get<uint16_t>());
std::cout << "Client is: " <<operatingSystem << std::endl;
       if (operatingSystem >= CLIENTOS_OTCLIENT_LINUX) {

               addString(item->getShader());

      }
Fail Number 4
C++:
 #include "player.h"
void NetworkMessage::addItem(const Item* item)
{
const ItemType& it = Item::items[item->getID()];
if (getOperatingSystem >= CLIENTOS_OTCLIENT_LINUX) {
               addString(item->getShader());
}
 
Last edited:
Lol i did read it wrong nvm 😁

Wait, but is this a new function you are developing or does addItem already exists? How should the engine know "where" to add the item if the only param is item
 
Back
Top