• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

Questions about the C++

Status
Not open for further replies.

Come2WoW

Respected Member
How can we do that in the script System_Censure when Censure send warning for GM's ?

script :
Code:
    #include "ScriptPCH.h"
    #include "Channel.h"
     
    class System_Censure : public PlayerScript
    {
    public:
            System_Censure() : PlayerScript("System_Censure") {}
     
            void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg)
            {
                    CheckMessage(player, msg, lang, NULL, NULL, NULL, NULL);
            }
     
            void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Player* receiver)
            {
                    CheckMessage(player, msg, lang, receiver, NULL, NULL, NULL);
            }
     
            void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Group* group)
            {
                    CheckMessage(player, msg, lang, NULL, group, NULL, NULL);
            }
     
            void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Guild* guild)
            {
                    CheckMessage(player, msg, lang, NULL, NULL, guild, NULL);
            }
     
            void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Channel* channel)
            {
                    CheckMessage(player, msg, lang, NULL, NULL, NULL, channel);
            }
     
    void CheckMessage(Player* player, std::string& msg, uint32 lang, Player* /*receiver*/, Group* /*group*/, Guild* /*guild*/, Channel* channel)
    {
        //if (player->isGameMaster() || lang == LANG_ADDON)
                //return;
     
        // transform to lowercase (for simpler checking)
        std::string lower = msg;
        std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
     
        uint8 cheksSize = 27;
        std::string checks[27];
        checks[0] ="http://";
        checks[1] =".com";
        checks[2] =".www";
        checks[3] =".net";
        checks[4] =".org";
        checks[5] =".ru";
        checks[6] ="www.";
        checks[7] ="wow-";
        checks[8] ="-wow";
        checks[9] ="rondor";
        checks[10] ="no-ip";
        checks[11] =".zapto";
        checks[12] ="wow-cool";
        checks[13] ="elgracia";
        checks[14] ="spzone";
        checks[15] ="fakewow";
        checks[16] ="deathside";
        checks[17] ="warsong";
        checks[18] ="RiverRise";
        checks[19] ="air-world";
        checks[20] =".lt";
        checks[21] ="sirus";
        checks[22] ="backkor";
        checks[23] ="isengard";
        checks[24] ="wowcircle";
        checks[25] ="izbooshka";
        checks[26] ="magic";
        for (int i = 0; i < cheksSize; ++i)
            if (lower.find(checks[i]) != std::string::npos)
            {
                msg = "";
                ChatHandler(player).PSendSysMessage("Реклама запрещена!");        
                return;
            }
    }
    };
     
    void AddSC_System_Censure()
    {
        new System_Censure();
    }
 

Hamar

BETA Tester
What i understand is that you want to send a warning message to a gamemaster if someone is using these censure words?
 

Hamar

BETA Tester
try this:

Code:
    #include "ScriptPCH.h"
    #include "Channel.h"
     
    class System_Censure : public PlayerScript
    {
    public:
            System_Censure() : PlayerScript("System_Censure") {}
     
            void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg)
            {
                    CheckMessage(player, msg, lang, NULL, NULL, NULL, NULL);
            }
     
            void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Player* receiver)
            {
                    CheckMessage(player, msg, lang, receiver, NULL, NULL, NULL);
            }
     
            void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Group* group)
            {
                    CheckMessage(player, msg, lang, NULL, group, NULL, NULL);
            }
     
            void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Guild* guild)
            {
                    CheckMessage(player, msg, lang, NULL, NULL, guild, NULL);
            }
     
            void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Channel* channel)
            {
                    CheckMessage(player, msg, lang, NULL, NULL, NULL, channel);
            }
     
    void CheckMessage(Player* player, std::string& msg, uint32 lang, Player* /*receiver*/, Group* /*group*/, Guild* /*guild*/, Channel* channel)
    {
        //if (player->isGameMaster() || lang == LANG_ADDON)
                //return;
     
        // transform to lowercase (for simpler checking)
        std::string lower = msg;
        std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
     
        uint8 cheksSize = 27;
        std::string checks[27];
        checks[0] ="http://";
        checks[1] =".com";
        checks[2] =".www";
        checks[3] =".net";
        checks[4] =".org";
        checks[5] =".ru";
        checks[6] ="www.";
        checks[7] ="wow-";
        checks[8] ="-wow";
        checks[9] ="rondor";
        checks[10] ="no-ip";
        checks[11] =".zapto";
        checks[12] ="wow-cool";
        checks[13] ="elgracia";
        checks[14] ="spzone";
        checks[15] ="fakewow";
        checks[16] ="deathside";
        checks[17] ="warsong";
        checks[18] ="RiverRise";
        checks[19] ="air-world";
        checks[20] =".lt";
        checks[21] ="sirus";
        checks[22] ="backkor";
        checks[23] ="isengard";
        checks[24] ="wowcircle";
        checks[25] ="izbooshka";
        checks[26] ="magic";
        for (int i = 0; i < cheksSize; ++i)
            if (lower.find(checks[i]) != std::string::npos)
            {
                msg = "";
                ChatHandler(player).PSendSysMessage("Реклама запрещена!");
				
				std::string str = player->GetName() + " used censored word: + checks[i];
				WorldPacket data(SMSG_NOTIFICATION, (str.size()+1));
				data << str;
				sWorld->SendGlobalGMMessage(&data);
				return;
            }
    }
    };
     
    void AddSC_System_Censure()
    {
        new System_Censure();
    }

Not sure if it'll work haven't tested it.
 

Tommy

Founder
Put the global GM message inside of the if statement when someone writes whatever...

Code:
            if (lower.find(checks[i]) != std::string::npos)
            {
                msg = "";
                ChatHandler(player).PSendSysMessage("Реклама запрещена!");
                [COLOR=#00ff00]sWorld->SendGMText(TEXTID, ...);  [/COLOR]      
                return;
            }


We've went over this before, you can't really censor the chat. I'm sure there will be issues regarding this and it will be complete spam to the GM's if you make it so they receive a message after someone wrote a specific word.
 

Come2WoW

Respected Member
Tested :D

source\src\server\scripts\Custom\System_Censure.cpp(76): error C2228: left of '.PSendSysMessage' must have class/struct/union
source\src\server\scripts\Custom\System_Censure.cpp(79): error C2146: syntax error : missing ';' before identifier 'WorldPacket'
source\src\server\scripts\Custom\System_Censure.cpp(79): error C2146: syntax error : missing ';' before identifier 'data'
source\src\server\scripts\Custom\System_Censure.cpp(79): error C2275: 'WorldPacket' : illegal use of this type as an expression
source\src\server\shared\Packets\WorldPacket.h(25) : see declaration of 'WorldPacket'
source\src\server\scripts\Custom\System_Censure.cpp(79): error C3861: 'data': identifier not found
source\src\server\scripts\Custom\System_Censure.cpp(80): error C2065: 'data' : undeclared identifier
source\src\server\scripts\Custom\System_Censure.cpp(81): error C2065: 'data' : undeclared identifier

Tommy Your method does not work.
 

Tommy

Founder
Tested :D



Tommy Your method does not work.

Pay attention. My method retrieves the data from a database table (You have to make a new row and do it yourself), a lot better than sending a packet when all you do is put the textID in, along with the arguments. If you read your errors they are from Hammer's example, not mine.
 

Darthye

Enthusiast
Nice if it worked. Here you have the script obtained from GaryMoveOut source with more checks (if it helps):

Code:
#include "ScriptPCH.h"
#include "Channel.h"

class System_Censure : public PlayerScript
{
    public:
        System_Censure() : PlayerScript("System_Censure") {}

        void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg)
        {
            CheckMessage(player, msg, lang, NULL, NULL, NULL, NULL);
        }

        void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Player* receiver)
        {
            CheckMessage(player, msg, lang, receiver, NULL, NULL, NULL);
        }

        void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Group* group)
        {
            CheckMessage(player, msg, lang, NULL, group, NULL, NULL);
        }

        void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Guild* guild)
        {
            CheckMessage(player, msg, lang, NULL, NULL, guild, NULL);
        }

        void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Channel* channel)
        {
            CheckMessage(player, msg, lang, NULL, NULL, NULL, channel);
        }

    void CheckMessage(Player* player, std::string& msg, uint32 lang, Player* /*receiver*/, Group* /*group*/, Guild* /*guild*/, Channel* channel)
    {
        if (player->IsGameMaster() || lang == LANG_ADDON)
            return;

        // transform to lowercase (for simpler checking)
        std::string lower = msg;
        std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);

        const uint8 cheksSize = 38;
        std::string checks[cheksSize];
        // Strony (Sites)
        checks[0] ="http://";
        checks[1] =".com";
        checks[2] =".www";
        checks[3] =".net";
        checks[4] =".org";
        checks[5] =".ru";
        checks[6] ="www.";
        checks[7] ="wow-";
        checks[8] ="-wow";
        checks[9] =".pl";
        // Polskie przekleñstwa (Polish curses)
        checks[10] ="chuj";
        checks[11] ="huj";
        checks[12] ="kurw";
        checks[13] ="jeba";
        checks[14] ="cipa";
        checks[15] ="gej";
        checks[16] ="cwel";
        checks[17] ="pizd";
        checks[18] ="pierdo";
        checks[19] ="spierd";
        checks[20] ="zjeb";
        checks[21] ="wypierdalaj";
        checks[22] ="kutas";
        // English curses
        checks[23] ="bitch";
        checks[24] ="clit";
        checks[25] ="cock";
        checks[26] ="cum";
        checks[27] ="cunt";
        checks[28] ="dick";
        checks[29] ="faggot";
        checks[30] ="fuck";
        checks[31] ="gay";
        checks[32] ="lesbian";
        checks[33] ="penis";
        checks[34] ="prick";
        checks[35] ="slut";
        checks[36] ="twat";
        checks[37] ="whore";

        for (int i = 0; i < cheksSize; ++i)
             if (lower.find(checks[i]) != std::string::npos)
             {
                 msg = "";
                 ChatHandler(player->GetSession()).PSendSysMessage("Advertising and vulgar behavior is not allowed!");
				 sWorld->SendGMText(TEXTID, ...);
                 return;
             }
    }
};

void AddSC_System_Censure()
{
    new System_Censure();
}
 
Last edited:
Status
Not open for further replies.
Top