SF Plugin [All Servers] ChatHook

jenekkkkkkkkkkkkkkkk

Администратор
Сообщения
1.031
Репутация
2.063
команды:
/mute [ID] - Выдать мут игроку (замутить можно только 1го игрока)
/unmute - Снять мут
/adchat - выключить объявления в чате (для SRP\ERP)
/fchat - Выключить/включить [F] чат (для SRP\ERP)
/chat - Выключить/включить чат (проще говоря занопить)
/admchat - Выключить/включить Adm-Chat чат (Для SRP\ERP) (подойдет для адм. стримов к примеру)


Код:
#include "main.h"

#define    INI_FILE            "SAMPFUNCS\\ChatHook.ini"
#define COLOR_ADMCHAT        0xFFFFF82B
#define COLOR_ADCHAT        0xD900C8
#define COLOR_FCHAT            0x1FCFFC8
#define COLOR_GREY            0xFFCACACA
#define CONVERT_COLOR        D3DCOLOR_XRGB    ((color & 0xFF000000) >> 24, (color & 0x00FF0000) >> 16, (color & 0x0000FF00) >> 8)

SAMPFUNCS    *SF = new SAMPFUNCS();

bool            AdmChat;
bool            AdChat;
bool            Fchat;
bool            AllChat;
bool            ChatID;
bool            ColorMsg;
bool            LongChat;
bool            AntiFlood;
int                MutePlayerID[SAMP_MAX_PLAYERS];
CHAR            StringMessageAntiFlood[MAX_PATH];

enum DialogsChatHookItem
{
    ADM_CHAT    =    0,
    AD_CHAT        =    1,
    F_CHAT        =    2,
    ALL_CHAT    =    3,
    CHAT_ID        =    4,
    COLOR_MSG    =    5,
    LONG_CHAT    =    6,
    ANTI_FLOOD    =    7,
};

bool CALLBACK IncRpc(stRakNetHookParams *pr)
{
    switch (pr->packetId)
    {
    case ScriptRPCEnumeration::RPC_ScrClientMessage: {

        uint32_t        len, color;
        char            msg[256];

        pr->bitStream->ResetReadPointer();
        pr->bitStream->Read(color);
        pr->bitStream->Read(len);
        pr->bitStream->Read(msg, len);
        msg[len] = '\0';

        if (AllChat)
            return false;

        if (AdmChat && strstr(msg, " <ADM-CHAT>") || AdmChat && strstr(msg, "<ADM-CHAT>"))
            return false;

        if (AdChat && color == COLOR_ADCHAT && strstr(msg, "Объявление:") || AdChat && color == COLOR_ADCHAT && strstr(msg, "сотрудник"))
            return false;

        if (Fchat && color == COLOR_FCHAT)
            return false;

        if (AntiFlood && strcmp(msg, StringMessageAntiFlood) == NULL)
            return false;

        sprintf(StringMessageAntiFlood, "%s", msg);

        for (int findMutePed = NULL; findMutePed < SAMP_MAX_PLAYERS; findMutePed++)
        {
            if (MutePlayerID[findMutePed] != -1)
            {
                if (SF->getSAMP()->getPlayers()->iIsListed[findMutePed] == TRUE && strstr(msg, SF->getSAMP()->getPlayers()->GetPlayerName(MutePlayerID[findMutePed])))
                    return false;
            }
        }

        if (ChatID)
        {
            for (int findPlayer = NULL; findPlayer < SAMP_MAX_PLAYERS; findPlayer++)
            {
                if (SF->getSAMP()->getPlayers()->iIsListed[findPlayer] == TRUE && strstr(msg, SF->getSAMP()->getPlayers()->GetPlayerName(findPlayer)))
                {
                    char ID[15];
                    sprintf(ID, "[%d]", findPlayer);
                    if (strstr(msg, ID))
                        return true;

                    std::string nick = SF->getSAMP()->getPlayers()->GetPlayerName(findPlayer);
                    std::string MSG = msg;
                    MSG.replace(MSG.find(nick), nick.length(), nick + "[" + std::to_string(findPlayer) + "]");

                    sprintf(msg, "%s", MSG.c_str());
                    len = strlen(msg);

                    pr->bitStream->ResetWritePointer();
                    pr->bitStream->Write(color);
                    pr->bitStream->Write(len);
                    pr->bitStream->Write(msg, len);
                }
            }
        }

        if (ColorMsg)
        {
            char text[256];
            sprintf(text, "  //  0x%x  (0x%x)", CONVERT_COLOR, color);
            strcat(msg, text);
            len = strlen(msg);

            pr->bitStream->ResetWritePointer();
            pr->bitStream->Write(color);
            pr->bitStream->Write(len);
            pr->bitStream->Write(msg, len);
        }

        }
    case ScriptRPCEnumeration::RPC_ScrServerQuit: {

        short int playerId;
        byte Reason;

        pr->bitStream->ResetReadPointer();
        pr->bitStream->Read(playerId);
        pr->bitStream->Read(Reason);

        for (int tmp = NULL; tmp < SAMP_MAX_PLAYERS; tmp++)
        {
            if (playerId == MutePlayerID[tmp] && MutePlayerID[tmp] != -1)
            {
                SF->getSAMP()->getChat()->AddChatMessage(-1, "Игрок %s[%d] отключился, мут снят",
                    SF->getSAMP()->getPlayers()->GetPlayerName(tmp), tmp);
                MutePlayerID[tmp] = -1;
            }
        }
        }
    case ScriptRPCEnumeration::RPC_ScrChatBubble: {

        if (!LongChat)
            return true;

        short int ID;
        int color, time;
        float distance;
        byte sizeOfText;
        char Text[256];

        pr->bitStream->ResetReadPointer();
        pr->bitStream->Read(ID);
        pr->bitStream->Read(color);
        pr->bitStream->Read(distance);
        pr->bitStream->Read(time);
        pr->bitStream->Read(sizeOfText);
        pr->bitStream->Read(Text, sizeOfText);
        Text[sizeOfText] = '\0';

        if (strstr(Text, "AFK") || !SF->getSAMP()->getPlayers()->IsPlayerDefined(ID, true))
            return true;

        /*  а это косяк альберта а.к.а разработчика эвольве рп, во время выхода игрока к нам приходит это рпц с пустым текстом */
        if (strlen(Text) == NULL)
            return true;

        // хуй знает либо мой косяк либо уже сервер присылает нам корявую инфу
        if (ID < NULL || ID > SAMP_MAX_PLAYERS)
            return true;

        SF->getSAMP()->getChat()->AddChatMessage(CONVERT_COLOR, "[LongChat] <%s>[%d]: %s",
            SF->getSAMP()->getPlayers()->GetPlayerName(ID), ID, Text);
        }
    }
    return true;
}

void CALLBACK chathook_dialogcmd(std::string)
{
    char    info[1000];

    sprintf(
        info,
        "{cacaca}[1] {ffffff}Nop Adm-Chat \t\t\t\t\t\t %s\n"
        "{cacaca}[2] {ffffff}Nop Ad-Chat(Объявления) \t\t\t\t %s\n"
        "{cacaca}[3] {ffffff}Nop [F]-Chat \t\t\t\t\t\t %s\n"
        "{cacaca}[4] {ffffff}Nop All Chat \t\t\t\t\t\t %s\n"
        "{cacaca}[5] {ffffff}ChatID \t\t\t\t\t\t\t %s\n"
        "{cacaca}[6] {ffffff}ColorMessageChat \t\t\t\t\t\t %s\n"
        "{cacaca}[7] {ffffff}Long-Chat \t\t\t\t\t\t\t %s\n"
        "{cacaca}[8] {ffffff}AntiFlood \t\t\t\t\t\t\t %s",
        AdmChat ? "{4cff29}[TRUE]" : "{bc3939}[FALSE]",
        AdChat ? "{4cff29}[TRUE]" : "{bc3939}[FALSE]",
        Fchat ? "{4cff29}[TRUE]" : "{bc3939}[FALSE]",
        AllChat ? "{4cff29}[TRUE]" : "{bc3939}[FALSE]",
        ChatID ? "{4cff29}[TRUE]" : "{bc3939}[FALSE]",
        ColorMsg ? "{4cff29}[TRUE]" : "{bc3939}[FALSE]",
        LongChat ? "{4cff29}[TRUE]" : "{bc3939}[FALSE]",
        AntiFlood ? "{4cff29}[TRUE]" : "{bc3939}[FALSE]");

    return SF->getSAMP()->getDialog()->ShowDialog(16, 2, "\t{ffffff}ChatHook by {3ef1b2}Jenek Bueno", info, "Enter", "");
}

void addchatmessage(uint32_t type)
{
    switch (type)
    {
    case DialogsChatHookItem::ADM_CHAT: {
        AdmChat ^= true;
        SF->getSAMP()->getChat()->AddChatMessage(COLOR_ADMCHAT, "<Nop is ADM-CHAT> {ffffff}%s", AdmChat ? "enabled" : "disabled");
        set_string_to_ini(INI_FILE, "StatusFuncs", "NOP Adm-Chat", AdmChat ? "true" : "false");
        return;
    }
    case DialogsChatHookItem::AD_CHAT: {
        AdChat ^= true;
        set_string_to_ini(INI_FILE, "StatusFuncs", "NOP Ad-Chat", AdChat ? "true" : "false");
        SF->getSAMP()->getChat()->AddChatMessage(COLOR_ADCHAT, "<Nop is Ad-Chat> {ffffff}%s", AdChat ? "enabled" : "disabled");
        return;
    }
    case DialogsChatHookItem::F_CHAT: {
        Fchat ^= true;
        set_string_to_ini(INI_FILE, "StatusFuncs", "NOP F-Chat", Fchat ? "true" : "false");
        SF->getSAMP()->getChat()->AddChatMessage(COLOR_FCHAT, "<Nop is F Chat> {ffffff}%s", Fchat ? "enabled" : "disabled");
        return;
    }
    case DialogsChatHookItem::ALL_CHAT: {
        AllChat ^= true;
        set_string_to_ini(INI_FILE, "StatusFuncs", "NOP All-Chat", AllChat ? "true" : "false");
        SF->getSAMP()->getChat()->AddChatMessage(COLOR_GREY, "<Nop is F All-Chat> {ffffff}%s", AllChat ? "enabled" : "disabled");
        return;
    }
    case DialogsChatHookItem::CHAT_ID: {
        ChatID ^= true;
        set_string_to_ini(INI_FILE, "Functions", "ChatID", ChatID ? "true" : "false");
        SF->getSAMP()->getChat()->AddChatMessage(COLOR_GREY, "<ChatID> {ffffff}%s", ChatID ? "enabled" : "disabled");
        return;
    }
    case DialogsChatHookItem::COLOR_MSG: {
        ColorMsg ^= true;
        set_string_to_ini(INI_FILE, "Functions", "ColorMsg", ColorMsg ? "true" : "false");
        SF->getSAMP()->getChat()->AddChatMessage(COLOR_GREY, "<ColorMessageChat> {ffffff}%s", ColorMsg ? "enabled" : "disabled");
        return;
    }
    case DialogsChatHookItem::LONG_CHAT: {
        LongChat ^= true;
        set_string_to_ini(INI_FILE, "Functions", "LongChat", LongChat ? "true" : "false");
        SF->getSAMP()->getChat()->AddChatMessage(COLOR_GREY, "<LongChat> {ffffff}%s", LongChat ? "enabled" : "disabled");
        return;
    }
    case DialogsChatHookItem::ANTI_FLOOD: {
        AntiFlood ^= true;
        set_string_to_ini(INI_FILE, "Functions", "AntiFlood", AntiFlood ? "true" : "false");
        SF->getSAMP()->getChat()->AddChatMessage(COLOR_GREY, "<AntiFlood> {ffffff}%s", AntiFlood ? "enabled" : "disabled");
        return;
        }
    }
}

void CALLBACK dialogHook(int dialogId, int buttonId, int listItem, const char *input)
{
    if (dialogId == 16 && buttonId == 1)
    {
        switch (listItem)
        {
        case DialogsChatHookItem::ADM_CHAT:            return addchatmessage(DialogsChatHookItem::ADM_CHAT);
        case DialogsChatHookItem::AD_CHAT:            return addchatmessage(DialogsChatHookItem::AD_CHAT); 
        case DialogsChatHookItem::F_CHAT:            return addchatmessage(DialogsChatHookItem::F_CHAT); 
        case DialogsChatHookItem::ALL_CHAT:            return addchatmessage(DialogsChatHookItem::ALL_CHAT); 
        case DialogsChatHookItem::CHAT_ID:            return addchatmessage(DialogsChatHookItem::CHAT_ID); 
        case DialogsChatHookItem::COLOR_MSG:        return addchatmessage(DialogsChatHookItem::COLOR_MSG); 
        case DialogsChatHookItem::LONG_CHAT:        return addchatmessage(DialogsChatHookItem::LONG_CHAT);
        case DialogsChatHookItem::ANTI_FLOOD:        return addchatmessage(DialogsChatHookItem::ANTI_FLOOD);
        }
    }
}


void CALLBACK admchat_cmd(std::string)    { return addchatmessage(DialogsChatHookItem::ADM_CHAT); }

void CALLBACK colormsg_cmd(std::string)    { return addchatmessage(DialogsChatHookItem::COLOR_MSG); }

void CALLBACK adchat_cmd(std::string)    { return addchatmessage(DialogsChatHookItem::AD_CHAT); }

void CALLBACK fchat_cmd(std::string)    { return addchatmessage(DialogsChatHookItem::F_CHAT); }

void CALLBACK chatid_cmd(std::string)    { return addchatmessage(DialogsChatHookItem::CHAT_ID); }

void CALLBACK allchat_cmd(std::string)    { return addchatmessage(DialogsChatHookItem::ALL_CHAT); }

void CALLBACK longchat_cmd(std::string)    { return addchatmessage(DialogsChatHookItem::LONG_CHAT);}

void CALLBACK antiflood_cmd(std::string) { return addchatmessage(DialogsChatHookItem::ANTI_FLOOD); }

void CALLBACK pmute_cmd(std::string param)
{
    if (param.empty()) 
        return;

    uint32_t num = NULL;
    if (sscanf(param.c_str(), "%d", &num) && num < SAMP_MAX_PLAYERS)
    {
        if (MutePlayerID[num] >= NULL && MutePlayerID[num] < SAMP_MAX_PLAYERS)
        {
            SF->getSAMP()->getChat()->AddChatMessage(-1, "Сняли мут с игрока %s[%d]",
                SF->getSAMP()->getPlayers()->GetPlayerName(num), num);
            MutePlayerID[num] = -1;
        }
        else if (SF->getSAMP()->getPlayers()->iIsListed[num])
        {
            SF->getSAMP()->getChat()->AddChatMessage(-1, "Замутили игрока %s[%d]",
                SF->getSAMP()->getPlayers()->GetPlayerName(num), num);
            MutePlayerID[num] = num;
        }
    }
}


void CheckIniFile()
{
    if (ini_file_exist(INI_FILE))
    {
        AdmChat = get_bool_from_ini(INI_FILE, "StatusFuncs", "NOP Adm-Chat");
        AdChat = get_bool_from_ini(INI_FILE, "StatusFuncs", "NOP Ad-Chat");
        Fchat = get_bool_from_ini(INI_FILE, "StatusFuncs", "NOP Fchat");
        AllChat = get_bool_from_ini(INI_FILE, "StatusFuncs", "NOP All-Chat");
        ColorMsg = get_bool_from_ini(INI_FILE, "Functions", "ColorMsg");
        ChatID = get_bool_from_ini(INI_FILE, "Functions", "ChatID");
        LongChat = get_bool_from_ini(INI_FILE, "Functions", "LongChat");
        AntiFlood = get_bool_from_ini(INI_FILE, "Functions", "AntiFlood");
    }
    else
    {
        if (!create_ini_file(INI_FILE))
        {
            AdmChat = false, AdChat = false, AllChat = false, ColorMsg = false, ChatID = false, LongChat = false, AntiFlood = true;
            return;
        }
        set_string_to_ini(INI_FILE, "StatusFuncs", "NOP Adm-Chat", "false");
        set_string_to_ini(INI_FILE, "StatusFuncs", "NOP Ad-Chat", "false");
        set_string_to_ini(INI_FILE, "StatusFuncs", "NOP Fchat", "false");
        set_string_to_ini(INI_FILE, "StatusFuncs", "NOP All-Chat", "false");
        set_string_to_ini(INI_FILE, "Functions", "ColorMsg", "false");
        set_string_to_ini(INI_FILE, "Functions", "ChatID", "false");
        set_string_to_ini(INI_FILE, "Functions", "LongChat", "false");
        set_string_to_ini(INI_FILE, "Functions", "AntiFlood", "true");
        SF->getSAMP()->getChat()->AddChatMessage(COLOR_GREY, "[ChatHook] {ffffff}Set to default INI-settings");
    }
}

void CALLBACK mainloop()
{
    static bool init = false;
    if (!init)
    {
        if (GAME == nullptr || GAME->GetSystemState() != eSystemState::GS_PLAYING_GAME || !SF->getSAMP()->IsInitialized())
            return;
        SF->getSAMP()->getChat()->AddChatMessage(-1, "ChatHook {ffffff}by {3ef1b2}Jenek Bueno{ffffff} loaded");
        SF->getRakNet()->registerRakNetCallback(RakNetScriptHookType::RAKHOOK_TYPE_INCOMING_RPC, IncRpc);
        memset(&StringMessageAntiFlood, NULL, sizeof(StringMessageAntiFlood));
        SF->getSAMP()->registerChatCommand("chathook", chathook_dialogcmd);
        SF->getSAMP()->registerChatCommand("antiflood", antiflood_cmd);
        SF->getSAMP()->registerChatCommand("colormsg", colormsg_cmd);
        SF->getSAMP()->registerChatCommand("longchat", longchat_cmd);
        SF->getSAMP()->registerChatCommand("admchat", admchat_cmd);
        SF->getSAMP()->registerChatCommand("nopchat", allchat_cmd);
        SF->getSAMP()->registerChatCommand("adchat", adchat_cmd);
        SF->getSAMP()->registerChatCommand("chatid", chatid_cmd);
        SF->getSAMP()->registerChatCommand("fchat", fchat_cmd);
        SF->getSAMP()->registerChatCommand("pmute", pmute_cmd);
        SF->getSAMP()->registerDialogCallback(dialogHook);
        //memset ne robit sore
        //memset(&MutePlayerID, ERROR_VAR, sizeof(MutePlayerID));
        for (int tmp = NULL; tmp < SAMP_MAX_PLAYERS; tmp++)
            MutePlayerID[tmp] = -1;
        CheckIniFile();
        init = true;
    }
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
{
    if (dwReasonForCall == DLL_PROCESS_ATTACH) 
        SF->initPlugin(mainloop, hModule);
    return TRUE;
}
 

Вложения

Последнее редактирование:

gvmbl3z

Пользователь
Сообщения
28
Репутация
1
поч не работает на срп?
 

Panasonic

ананасик
Саппорт
Сообщения
224
Репутация
63
команды:
/mute [ID] - Выдать мут игроку (замутить можно только 1го игрока)
/unmute - Снять мут
/adchat - выключить объявления в чате (для SRP\ERP)
/fchat - Выключить/включить [F] чат (для SRP\ERP)
/chat - Выключить/включить чат (проще говоря занопить)
/admchat - Выключить/включить Adm-Chat чат (Для SRP\ERP) (подойдет для адм. стримов к примеру)


Код:
#include "main.h"

#define    INI_FILE            "SAMPFUNCS\\ChatHook.ini"
#define COLOR_ADMCHAT        0xFFFFF82B
#define COLOR_ADCHAT        0xD900C8
#define COLOR_FCHAT            0x1FCFFC8
#define COLOR_GREY            0xFFCACACA
#define CONVERT_COLOR        D3DCOLOR_XRGB    ((color & 0xFF000000) >> 24, (color & 0x00FF0000) >> 16, (color & 0x0000FF00) >> 8)

SAMPFUNCS    *SF = new SAMPFUNCS();

bool            AdmChat;
bool            AdChat;
bool            Fchat;
bool            AllChat;
bool            ChatID;
bool            ColorMsg;
bool            LongChat;
bool            AntiFlood;
int                MutePlayerID[SAMP_MAX_PLAYERS];
CHAR            StringMessageAntiFlood[MAX_PATH];

enum DialogsChatHookItem
{
    ADM_CHAT    =    0,
    AD_CHAT        =    1,
    F_CHAT        =    2,
    ALL_CHAT    =    3,
    CHAT_ID        =    4,
    COLOR_MSG    =    5,
    LONG_CHAT    =    6,
    ANTI_FLOOD    =    7,
};

bool CALLBACK IncRpc(stRakNetHookParams *pr)
{
    switch (pr->packetId)
    {
    case ScriptRPCEnumeration::RPC_ScrClientMessage: {

        uint32_t        len, color;
        char            msg[256];

        pr->bitStream->ResetReadPointer();
        pr->bitStream->Read(color);
        pr->bitStream->Read(len);
        pr->bitStream->Read(msg, len);
        msg[len] = '\0';

        if (AllChat)
            return false;

        if (AdmChat && strstr(msg, " <ADM-CHAT>") || AdmChat && strstr(msg, "<ADM-CHAT>"))
            return false;

        if (AdChat && color == COLOR_ADCHAT && strstr(msg, "Объявление:") || AdChat && color == COLOR_ADCHAT && strstr(msg, "сотрудник"))
            return false;

        if (Fchat && color == COLOR_FCHAT)
            return false;

        if (AntiFlood && strcmp(msg, StringMessageAntiFlood) == NULL)
            return false;

        sprintf(StringMessageAntiFlood, "%s", msg);

        for (int findMutePed = NULL; findMutePed < SAMP_MAX_PLAYERS; findMutePed++)
        {
            if (MutePlayerID[findMutePed] != -1)
            {
                if (SF->getSAMP()->getPlayers()->iIsListed[findMutePed] == TRUE && strstr(msg, SF->getSAMP()->getPlayers()->GetPlayerName(MutePlayerID[findMutePed])))
                    return false;
            }
        }

        if (ChatID)
        {
            for (int findPlayer = NULL; findPlayer < SAMP_MAX_PLAYERS; findPlayer++)
            {
                if (SF->getSAMP()->getPlayers()->iIsListed[findPlayer] == TRUE && strstr(msg, SF->getSAMP()->getPlayers()->GetPlayerName(findPlayer)))
                {
                    char ID[15];
                    sprintf(ID, "[%d]", findPlayer);
                    if (strstr(msg, ID))
                        return true;

                    std::string nick = SF->getSAMP()->getPlayers()->GetPlayerName(findPlayer);
                    std::string MSG = msg;
                    MSG.replace(MSG.find(nick), nick.length(), nick + "[" + std::to_string(findPlayer) + "]");

                    sprintf(msg, "%s", MSG.c_str());
                    len = strlen(msg);

                    pr->bitStream->ResetWritePointer();
                    pr->bitStream->Write(color);
                    pr->bitStream->Write(len);
                    pr->bitStream->Write(msg, len);
                }
            }
        }

        if (ColorMsg)
        {
            char text[256];
            sprintf(text, "  //  0x%x  (0x%x)", CONVERT_COLOR, color);
            strcat(msg, text);
            len = strlen(msg);

            pr->bitStream->ResetWritePointer();
            pr->bitStream->Write(color);
            pr->bitStream->Write(len);
            pr->bitStream->Write(msg, len);
        }

        }
    case ScriptRPCEnumeration::RPC_ScrServerQuit: {

        short int playerId;
        byte Reason;

        pr->bitStream->ResetReadPointer();
        pr->bitStream->Read(playerId);
        pr->bitStream->Read(Reason);

        for (int tmp = NULL; tmp < SAMP_MAX_PLAYERS; tmp++)
        {
            if (playerId == MutePlayerID[tmp] && MutePlayerID[tmp] != -1)
            {
                SF->getSAMP()->getChat()->AddChatMessage(-1, "Игрок %s[%d] отключился, мут снят",
                    SF->getSAMP()->getPlayers()->GetPlayerName(tmp), tmp);
                MutePlayerID[tmp] = -1;
            }
        }
        }
    case ScriptRPCEnumeration::RPC_ScrChatBubble: {

        if (!LongChat)
            return true;

        short int ID;
        int color, time;
        float distance;
        byte sizeOfText;
        char Text[256];

        pr->bitStream->ResetReadPointer();
        pr->bitStream->Read(ID);
        pr->bitStream->Read(color);
        pr->bitStream->Read(distance);
        pr->bitStream->Read(time);
        pr->bitStream->Read(sizeOfText);
        pr->bitStream->Read(Text, sizeOfText);
        Text[sizeOfText] = '\0';

        if (strstr(Text, "AFK") || !SF->getSAMP()->getPlayers()->IsPlayerDefined(ID, true))
            return true;

        /*  а это косяк альберта а.к.а разработчика эвольве рп, во время выхода игрока к нам приходит это рпц с пустым текстом */
        if (strlen(Text) == NULL)
            return true;

        // хуй знает либо мой косяк либо уже сервер присылает нам корявую инфу
        if (ID < NULL || ID > SAMP_MAX_PLAYERS)
            return true;

        SF->getSAMP()->getChat()->AddChatMessage(CONVERT_COLOR, "[LongChat] <%s>[%d]: %s",
            SF->getSAMP()->getPlayers()->GetPlayerName(ID), ID, Text);
        }
    }
    return true;
}

void CALLBACK chathook_dialogcmd(std::string)
{
    char    info[1000];

    sprintf(
        info,
        "{cacaca}[1] {ffffff}Nop Adm-Chat \t\t\t\t\t\t %s\n"
        "{cacaca}[2] {ffffff}Nop Ad-Chat(Объявления) \t\t\t\t %s\n"
        "{cacaca}[3] {ffffff}Nop [F]-Chat \t\t\t\t\t\t %s\n"
        "{cacaca}[4] {ffffff}Nop All Chat \t\t\t\t\t\t %s\n"
        "{cacaca}[5] {ffffff}ChatID \t\t\t\t\t\t\t %s\n"
        "{cacaca}[6] {ffffff}ColorMessageChat \t\t\t\t\t\t %s\n"
        "{cacaca}[7] {ffffff}Long-Chat \t\t\t\t\t\t\t %s\n"
        "{cacaca}[8] {ffffff}AntiFlood \t\t\t\t\t\t\t %s",
        AdmChat ? "{4cff29}[TRUE]" : "{bc3939}[FALSE]",
        AdChat ? "{4cff29}[TRUE]" : "{bc3939}[FALSE]",
        Fchat ? "{4cff29}[TRUE]" : "{bc3939}[FALSE]",
        AllChat ? "{4cff29}[TRUE]" : "{bc3939}[FALSE]",
        ChatID ? "{4cff29}[TRUE]" : "{bc3939}[FALSE]",
        ColorMsg ? "{4cff29}[TRUE]" : "{bc3939}[FALSE]",
        LongChat ? "{4cff29}[TRUE]" : "{bc3939}[FALSE]",
        AntiFlood ? "{4cff29}[TRUE]" : "{bc3939}[FALSE]");

    return SF->getSAMP()->getDialog()->ShowDialog(16, 2, "\t{ffffff}ChatHook by {3ef1b2}Jenek Bueno", info, "Enter", "");
}

void addchatmessage(uint32_t type)
{
    switch (type)
    {
    case DialogsChatHookItem::ADM_CHAT: {
        AdmChat ^= true;
        SF->getSAMP()->getChat()->AddChatMessage(COLOR_ADMCHAT, "<Nop is ADM-CHAT> {ffffff}%s", AdmChat ? "enabled" : "disabled");
        set_string_to_ini(INI_FILE, "StatusFuncs", "NOP Adm-Chat", AdmChat ? "true" : "false");
        return;
    }
    case DialogsChatHookItem::AD_CHAT: {
        AdChat ^= true;
        set_string_to_ini(INI_FILE, "StatusFuncs", "NOP Ad-Chat", AdChat ? "true" : "false");
        SF->getSAMP()->getChat()->AddChatMessage(COLOR_ADCHAT, "<Nop is Ad-Chat> {ffffff}%s", AdChat ? "enabled" : "disabled");
        return;
    }
    case DialogsChatHookItem::F_CHAT: {
        Fchat ^= true;
        set_string_to_ini(INI_FILE, "StatusFuncs", "NOP F-Chat", Fchat ? "true" : "false");
        SF->getSAMP()->getChat()->AddChatMessage(COLOR_FCHAT, "<Nop is F Chat> {ffffff}%s", Fchat ? "enabled" : "disabled");
        return;
    }
    case DialogsChatHookItem::ALL_CHAT: {
        AllChat ^= true;
        set_string_to_ini(INI_FILE, "StatusFuncs", "NOP All-Chat", AllChat ? "true" : "false");
        SF->getSAMP()->getChat()->AddChatMessage(COLOR_GREY, "<Nop is F All-Chat> {ffffff}%s", AllChat ? "enabled" : "disabled");
        return;
    }
    case DialogsChatHookItem::CHAT_ID: {
        ChatID ^= true;
        set_string_to_ini(INI_FILE, "Functions", "ChatID", ChatID ? "true" : "false");
        SF->getSAMP()->getChat()->AddChatMessage(COLOR_GREY, "<ChatID> {ffffff}%s", ChatID ? "enabled" : "disabled");
        return;
    }
    case DialogsChatHookItem::COLOR_MSG: {
        ColorMsg ^= true;
        set_string_to_ini(INI_FILE, "Functions", "ColorMsg", ColorMsg ? "true" : "false");
        SF->getSAMP()->getChat()->AddChatMessage(COLOR_GREY, "<ColorMessageChat> {ffffff}%s", ColorMsg ? "enabled" : "disabled");
        return;
    }
    case DialogsChatHookItem::LONG_CHAT: {
        LongChat ^= true;
        set_string_to_ini(INI_FILE, "Functions", "LongChat", LongChat ? "true" : "false");
        SF->getSAMP()->getChat()->AddChatMessage(COLOR_GREY, "<LongChat> {ffffff}%s", LongChat ? "enabled" : "disabled");
        return;
    }
    case DialogsChatHookItem::ANTI_FLOOD: {
        AntiFlood ^= true;
        set_string_to_ini(INI_FILE, "Functions", "AntiFlood", AntiFlood ? "true" : "false");
        SF->getSAMP()->getChat()->AddChatMessage(COLOR_GREY, "<AntiFlood> {ffffff}%s", AntiFlood ? "enabled" : "disabled");
        return;
        }
    }
}

void CALLBACK dialogHook(int dialogId, int buttonId, int listItem, const char *input)
{
    if (dialogId == 16 && buttonId == 1)
    {
        switch (listItem)
        {
        case DialogsChatHookItem::ADM_CHAT:            return addchatmessage(DialogsChatHookItem::ADM_CHAT);
        case DialogsChatHookItem::AD_CHAT:            return addchatmessage(DialogsChatHookItem::AD_CHAT);
        case DialogsChatHookItem::F_CHAT:            return addchatmessage(DialogsChatHookItem::F_CHAT);
        case DialogsChatHookItem::ALL_CHAT:            return addchatmessage(DialogsChatHookItem::ALL_CHAT);
        case DialogsChatHookItem::CHAT_ID:            return addchatmessage(DialogsChatHookItem::CHAT_ID);
        case DialogsChatHookItem::COLOR_MSG:        return addchatmessage(DialogsChatHookItem::COLOR_MSG);
        case DialogsChatHookItem::LONG_CHAT:        return addchatmessage(DialogsChatHookItem::LONG_CHAT);
        case DialogsChatHookItem::ANTI_FLOOD:        return addchatmessage(DialogsChatHookItem::ANTI_FLOOD);
        }
    }
}


void CALLBACK admchat_cmd(std::string)    { return addchatmessage(DialogsChatHookItem::ADM_CHAT); }

void CALLBACK colormsg_cmd(std::string)    { return addchatmessage(DialogsChatHookItem::COLOR_MSG); }

void CALLBACK adchat_cmd(std::string)    { return addchatmessage(DialogsChatHookItem::AD_CHAT); }

void CALLBACK fchat_cmd(std::string)    { return addchatmessage(DialogsChatHookItem::F_CHAT); }

void CALLBACK chatid_cmd(std::string)    { return addchatmessage(DialogsChatHookItem::CHAT_ID); }

void CALLBACK allchat_cmd(std::string)    { return addchatmessage(DialogsChatHookItem::ALL_CHAT); }

void CALLBACK longchat_cmd(std::string)    { return addchatmessage(DialogsChatHookItem::LONG_CHAT);}

void CALLBACK antiflood_cmd(std::string) { return addchatmessage(DialogsChatHookItem::ANTI_FLOOD); }

void CALLBACK pmute_cmd(std::string param)
{
    if (param.empty())
        return;

    uint32_t num = NULL;
    if (sscanf(param.c_str(), "%d", &num) && num < SAMP_MAX_PLAYERS)
    {
        if (MutePlayerID[num] >= NULL && MutePlayerID[num] < SAMP_MAX_PLAYERS)
        {
            SF->getSAMP()->getChat()->AddChatMessage(-1, "Сняли мут с игрока %s[%d]",
                SF->getSAMP()->getPlayers()->GetPlayerName(num), num);
            MutePlayerID[num] = -1;
        }
        else if (SF->getSAMP()->getPlayers()->iIsListed[num])
        {
            SF->getSAMP()->getChat()->AddChatMessage(-1, "Замутили игрока %s[%d]",
                SF->getSAMP()->getPlayers()->GetPlayerName(num), num);
            MutePlayerID[num] = num;
        }
    }
}


void CheckIniFile()
{
    if (ini_file_exist(INI_FILE))
    {
        AdmChat = get_bool_from_ini(INI_FILE, "StatusFuncs", "NOP Adm-Chat");
        AdChat = get_bool_from_ini(INI_FILE, "StatusFuncs", "NOP Ad-Chat");
        Fchat = get_bool_from_ini(INI_FILE, "StatusFuncs", "NOP Fchat");
        AllChat = get_bool_from_ini(INI_FILE, "StatusFuncs", "NOP All-Chat");
        ColorMsg = get_bool_from_ini(INI_FILE, "Functions", "ColorMsg");
        ChatID = get_bool_from_ini(INI_FILE, "Functions", "ChatID");
        LongChat = get_bool_from_ini(INI_FILE, "Functions", "LongChat");
        AntiFlood = get_bool_from_ini(INI_FILE, "Functions", "AntiFlood");
    }
    else
    {
        if (!create_ini_file(INI_FILE))
        {
            AdmChat = false, AdChat = false, AllChat = false, ColorMsg = false, ChatID = false, LongChat = false, AntiFlood = true;
            return;
        }
        set_string_to_ini(INI_FILE, "StatusFuncs", "NOP Adm-Chat", "false");
        set_string_to_ini(INI_FILE, "StatusFuncs", "NOP Ad-Chat", "false");
        set_string_to_ini(INI_FILE, "StatusFuncs", "NOP Fchat", "false");
        set_string_to_ini(INI_FILE, "StatusFuncs", "NOP All-Chat", "false");
        set_string_to_ini(INI_FILE, "Functions", "ColorMsg", "false");
        set_string_to_ini(INI_FILE, "Functions", "ChatID", "false");
        set_string_to_ini(INI_FILE, "Functions", "LongChat", "false");
        set_string_to_ini(INI_FILE, "Functions", "AntiFlood", "true");
        SF->getSAMP()->getChat()->AddChatMessage(COLOR_GREY, "[ChatHook] {ffffff}Set to default INI-settings");
    }
}

void CALLBACK mainloop()
{
    static bool init = false;
    if (!init)
    {
        if (GAME == nullptr || GAME->GetSystemState() != eSystemState::GS_PLAYING_GAME || !SF->getSAMP()->IsInitialized())
            return;
        SF->getSAMP()->getChat()->AddChatMessage(-1, "ChatHook {ffffff}by {3ef1b2}Jenek Bueno{ffffff} loaded");
        SF->getRakNet()->registerRakNetCallback(RakNetScriptHookType::RAKHOOK_TYPE_INCOMING_RPC, IncRpc);
        memset(&StringMessageAntiFlood, NULL, sizeof(StringMessageAntiFlood));
        SF->getSAMP()->registerChatCommand("chathook", chathook_dialogcmd);
        SF->getSAMP()->registerChatCommand("antiflood", antiflood_cmd);
        SF->getSAMP()->registerChatCommand("colormsg", colormsg_cmd);
        SF->getSAMP()->registerChatCommand("longchat", longchat_cmd);
        SF->getSAMP()->registerChatCommand("admchat", admchat_cmd);
        SF->getSAMP()->registerChatCommand("nopchat", allchat_cmd);
        SF->getSAMP()->registerChatCommand("adchat", adchat_cmd);
        SF->getSAMP()->registerChatCommand("chatid", chatid_cmd);
        SF->getSAMP()->registerChatCommand("fchat", fchat_cmd);
        SF->getSAMP()->registerChatCommand("pmute", pmute_cmd);
        SF->getSAMP()->registerDialogCallback(dialogHook);
        //memset ne robit sore
        //memset(&MutePlayerID, ERROR_VAR, sizeof(MutePlayerID));
        for (int tmp = NULL; tmp < SAMP_MAX_PLAYERS; tmp++)
            MutePlayerID[tmp] = -1;
        CheckIniFile();
        init = true;
    }
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
{
    if (dwReasonForCall == DLL_PROCESS_ATTACH)
        SF->initPlugin(mainloop, hModule);
    return TRUE;
}
чини чит блятб
 

nikon.

Читер
Сообщения
33
Репутация
5
srp fix, поменяли цвета наверное.
Почини пж <3
 

Ford

Знающий пользователь
Сообщения
115
Репутация
11
Можешь убрать флуд SLEEP из лонгчата?
 
Сверху