• 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++ Help with Rule violation TFS-1.2

Manigold

Active Member
Joined
Nov 2, 2017
Messages
197
Solutions
8
Reaction score
47
Hello folks ,i'm trying to add a ruleviolation system in tfs 1.2 ,but i'm having two issues,the first one is when the gamemaster has the rule violation channel open and someone reports a rule violation the client crashes.(if i open the chanel before receiving a report works fine).
Crash report:
crashruleviolation.png

The second error happens when the gamemaster answer a report , when the gm process the report a chanell is opened to talk to the player, but when the gm speaks in this channel , the player receive a message on default (like a regular personal message) the channel doesn't open for the player(the channel should open for the player too).
GM answering in the right channel:
report answer.png
Player receiving on default:
report answer2.png

This is what i've changed in the sources:
Hope someone can help me ,thanks in advance.
 
Last edited:
Bump.
I'm trying to use the code from TwistedScorpio/Nostalrius (https://github.com/TwistedScorpio/Nostalrius) .But this part is diferent from mine(i don't have the AddCreatureSpeak part):
C++:
void ProtocolGame::AddCreatureSpeak(NetworkMessage& msg, const Creature* creature, SpeakClasses type, const std::string& text, uint16_t channelId, const Position* pos /*= nullptr*/)
{
    msg.addByte(0xAA);
    static uint32_t statementId = 0;
    msg.add<uint32_t>(++statementId);

    if (type != TALKTYPE_RVR_ANSWER) {
        if (type != TALKTYPE_CHANNEL_R2) {
            if (creature) {
                msg.addString(creature->getName());
            } else {
                msg.add<uint16_t>(0);
            }
        } else {
            msg.add<uint16_t>(0);
        }
    }

    msg.addByte(type);
    switch (type) {
    case TALKTYPE_SAY:
    case TALKTYPE_WHISPER:
    case TALKTYPE_YELL:
    case TALKTYPE_MONSTER_SAY:
    case TALKTYPE_MONSTER_YELL:
        if (!pos) {
            msg.addPosition(creature->getPosition());
        } else {
            msg.addPosition(*pos);
        }
        break;
    case TALKTYPE_CHANNEL_Y:
    case TALKTYPE_CHANNEL_R1:
    case TALKTYPE_CHANNEL_R2:
    case TALKTYPE_CHANNEL_O:
        msg.add<uint16_t>(channelId);
        break;
    case TALKTYPE_RVR_CHANNEL:
        msg.add<uint32_t>(0);
        break;
    default:
        break;
    }

    msg.addString(text);
}
My problem seems to be in this part (actually i realize that the client is also crashing when the monsters say something):
C++:
void ProtocolGame::sendCreatureSay(const Creature* creature, SpeakClasses type, const std::string& text, const Position* pos/* = nullptr*/)
{
    NetworkMessage msg;
    msg.addByte(0xAA);

    static uint32_t statementId = 0;
    msg.add<uint32_t>(++statementId);

    if (type != TALKTYPE_RVR_ANSWER) {
        if (type != TALKTYPE_CHANNEL_R2) {
            if (creature) {

                msg.addString(creature->getName());

                //Add level only for players
                if (const Player* speaker = creature->getPlayer()) {
                    msg.add<uint16_t>(speaker->getLevel());
                }
            } else {
                msg.add<uint16_t>(0x00);
            }
        } else {
            msg.add<uint16_t>(0x00);
        }
    }

    msg.addByte(type);
    if (pos) {
        msg.addPosition(*pos);
    } else {
        msg.addPosition(creature->getPosition());
    }

    msg.addString(text);
    writeToOutputBuffer(msg);
}

void ProtocolGame::sendToChannel(const Creature* creature, SpeakClasses type, const std::string& text, uint16_t channelId)
{
    NetworkMessage msg;
    msg.addByte(0xAA);

    static uint32_t statementId = 0;
    msg.add<uint32_t>(++statementId);

    if (type != TALKTYPE_RVR_ANSWER) {
        if (!creature) {
            msg.add<uint32_t>(0x00);
    } else if (type == TALKTYPE_CHANNEL_R2) {
            msg.add<uint32_t>(0x00);
            type = TALKTYPE_CHANNEL_R1;
    } else {
            msg.addString(creature->getName());
            //Add level only for players
            if (const Player* speaker = creature->getPlayer()) {
                msg.add<uint16_t>(speaker->getLevel());
        } else {
                msg.add<uint16_t>(0x00);
            }
        }
    }

    msg.addByte(type);
    msg.add<uint16_t>(channelId);
    msg.addString(text);
    writeToOutputBuffer(msg);
}


I hope someone can help me with this .
 
Back
Top