Gag System [API] v1.1

Одобрените от нас плъгини. Моля, докладвайте ако забележите бъг с някой от плъгините в този раздел.
Аватар
TheRedShoko
Извън линия
Модератор
Модератор
Мнения: 1016
Регистриран на: 06 Окт 2016, 07:42
Местоположение: Бургас
Се отблагодари: 5 пъти
Получена благодарност: 84 пъти

Gag System v0.2 ALPHA Testing

Мнение от TheRedShoko » 13 Дек 2017, 14:05

Онлайн компилатора най-вероятно няма библиотеката. Изчакайте до довечера да пусна 1.8.2 версия или някой, който разбира от pawn нека го направи. Няма го лаптопа ми, за да го направя.

Аватар
Smiley
Извън линия
Foreigner
Foreigner
Мнения: 26
Регистриран на: 12 Дек 2017, 22:40

Gag System v0.2 ALPHA Testing

Мнение от Smiley » 13 Дек 2017, 14:29

You must to use some ' colorchat.inc ' what doesn't have buggs.
That isn't so popular, I think maybe is another better than.
Maybe that of OciXCrom is better, 'cromchat.inc'.Use something to not create chat bugs or another problems like that.
OciXCrom maybe knows when appear that buggs(if he still said it) or what colorchat includes isn't better to use.If is better that you used now, let it go but I don't know how to test it if isn't some problems from colorchat.inc

!! Then do not forget about what I wrote above, more exactly gags how to be saved without switched by cvar and that file words.ini to you add.
Another idea to can be use and for amxmodx 1.8.2 is to ported it to 1.8.2 and to can be used on both versions.I understand can be ported, I don't know if is the good way to load plugin with useless codes like porting.

I will test plugin when you make this updates.

Аватар
TheRedShoko
Извън линия
Модератор
Модератор
Мнения: 1016
Регистриран на: 06 Окт 2016, 07:42
Местоположение: Бургас
Се отблагодари: 5 пъти
Получена благодарност: 84 пъти

Gag System v0.2 ALPHA Testing

Мнение от TheRedShoko » 13 Дек 2017, 14:45

This include does not have problems. It doesn't matter what colorchat do I use if the person who compiles it has some buggy library. That's why I've decided to use this library. It's unique with one and only version. I'll think about the saving information. I'll leave it just by IP for now. I know about the problem with 1.8.2 and will be fixed later today. About the chat words filter, right now my goal is to make working gag plugin without bugs. I'm not going to add such feature for now. Maybe in future there may be some feature like that.

Аватар
Smiley
Извън линия
Foreigner
Foreigner
Мнения: 26
Регистриран на: 12 Дек 2017, 22:40

Gag System v0.2 ALPHA Testing

Мнение от Smiley » 13 Дек 2017, 15:30

Look attachments, maybe you make some ideas from this code.Plugin is incomplete, and have saves gags to Name, IP and SteamId.
Прикачени файлове
Gag.sma
(13.45 KiB) Свалено 175 пъти
Gag.sma
(13.45 KiB) Свалено 175 пъти

Аватар
OciXCrom
Извън линия
Администратор
Администратор
Мнения: 7206
Регистриран на: 06 Окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 117 пъти
Получена благодарност: 1295 пъти
Обратна връзка:

Gag System v0.2 ALPHA Testing

Мнение от OciXCrom » 13 Дек 2017, 20:21

@OciXCrom, your "cromchat.inc" does the same thing like "colorchat.inc" and this what be used in this plugin of gag?
All of them to the same thing - they send chat messages, but only colorchat.inc has bugs in it. WPMGPrintChatColor.inc and cromchat.inc don't have any problems. By the way, cromchat.inc is fully compatible with colorchat.inc, so you can directly change it in the #include line if you have any problems with it. A colorchat.inc problem was reported just a few hours ago - viewtopic.php?f=24&p=14853

Относно проблемът при компилация на 1.8.2 - функцията regex_compile_ex е достъпна само в AMXX 1.8.3 и трябва да се замени с regex_compile, която пък има различен синтаксис. Същото се отнася и за синтаксиса на regex_match_c. Ето работеща за 1.8.2 и 1.8.3 версия:

Код за потвърждение: Избери целия код

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <regex>
#include <nvault>
#include <WPMGPrintChatColor>

#define IP_PATTERN "([0-9]+.*[1-9][0-9]+.*[0-9]+.*[0-9])"
#define VERSION "0.2 ALPHA"

enum _:GagTimeData
{
    DISPLAY[64],
    MINUTES
};

new const g_GagTimes[][GagTimeData] =
{
    { "1 minute", 1 },
    { "5 minutes", 5 },
    { "10 minutes", 10 },
    { "15 minutes", 15 },
    { "20 minutes", 20 },
    { "30 minutes", 30 },
    { "1 hour", 60 },
    { "2 hours", 120 },
    { "6 hours", 360 },
    { "1 day", 1440 },
    { "1 week", 10080 },
    { "Permanent", 0 }
}

new const g_szVaultName[] = "gagsystem";
new const g_szChatPrefix[] = "[GagSystem]";
new const g_szLogFile[] = "addons/amxmodx/logs/gag_system.log";
new g_iNVaultHandle, Regex:g_iRegexIPPattern;
new g_iGagTimeIndex[33], g_iUserTarget[33], g_iUnused;

public plugin_init()
{
    register_plugin("Gag System", VERSION, "TheRedShoko @ AMXX-BG.info");
    register_cvar("gagsystem_shoko", VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED);

    register_clcmd("say", "CommandSayExecuted");
    register_clcmd("say_team", "CommandSayExecuted");

    register_forward(FM_Voice_SetClientListening, "PlayerVoiceSpeak", 0);

    register_clcmd("amx_gag", "CommandGag", ADMIN_SLAY, "<name | #id | ip> <time> <reason>");
    register_clcmd("amx_ungag", "CommandUngag", ADMIN_SLAY, "<name | #id | ip>");
    register_clcmd("amx_gagmenu", "CommandGagMenu", ADMIN_SLAY);
    register_clcmd("amx_TYPE_GAGREASON", "CommandGagReason", ADMIN_SLAY);
    //register_clcmd("amx_cleangags", "CommandCleanDB", ADMIN_RCON);

	#if AMXX_VERSION_NUM < 183
	g_iRegexIPPattern = regex_compile(IP_PATTERN, g_iUnused, "", 0);
	#else
	g_iRegexIPPattern = regex_compile_ex(IP_PATTERN);
	#endif
	
	//native Regex:regex_compile(const pattern[], &ret = 0, error[] = "", maxLen = 0, const flags[]="");
	//native Regex:regex_compile_ex(const pattern[], flags = 0, error[]= "", maxLen = 0, &errcode = 0);

    g_iNVaultHandle = nvault_open(g_szVaultName);

    if (g_iNVaultHandle == INVALID_HANDLE)
    {
        set_fail_state("Failed to open NVault DB!");
    }
}

public plugin_end()
{
    nvault_close(g_iNVaultHandle);
    regex_free(g_iRegexIPPattern);
}

public PlayerVoiceSpeak(receiver, id)
{
    if (receiver == id || !is_user_connected(id))
    {
        return FMRES_IGNORED;
    }

    if (IsUserGagged(id, false))
    {
        engfunc(EngFunc_SetClientListening, receiver, id, false);
        return FMRES_SUPERCEDE;
    }

    return FMRES_IGNORED;
}

public CommandSayExecuted(id)
{
    if (IsUserGagged(id))
    {
        return PLUGIN_HANDLED;
    }

    return PLUGIN_CONTINUE;
}

public CommandGag(id, iLevel, iCmdId)
{
    if (!cmd_access(id, iLevel, iCmdId, 4))
    {
        return PLUGIN_HANDLED;
    }

    new szTarget[33], szTargetIP[16], szTime[8], szReason[64];
    read_argv(1, szTarget, charsmax(szTarget));

    if (!regex_match_c(szTarget, g_iRegexIPPattern, g_iUnused))
    {
        new iTarget = cmd_target(id, szTarget);

        if (!iTarget)
        {
            return PLUGIN_HANDLED;
        }

        get_user_name(iTarget, szTarget, charsmax(szTarget));
        get_user_ip(iTarget, szTargetIP, charsmax(szTargetIP), 1);
    }
    else
    {
        copy(szTargetIP, charsmax(szTargetIP), szTarget);
    }

    read_argv(2, szTime, charsmax(szTime));
    read_argv(3, szReason, charsmax(szReason));
    new iTime = str_to_num(szTime);

    new szAdmin[32];
    get_user_name(id, szAdmin, charsmax(szAdmin));

    console_print(id, "%s", GagUser(szTarget, szTargetIP, iTime, szReason, szAdmin));

    return PLUGIN_HANDLED;
}

public CommandUngag(id, iLevel, iCmdId)
{
    if (!cmd_access(id, iLevel, iCmdId, 2))
    {
        return PLUGIN_HANDLED;
    }

    new szTarget[32], szTargetIP[16];
    read_argv(1, szTarget, charsmax(szTarget));

    if (!regex_match_c(szTarget, g_iRegexIPPattern, g_iUnused))
    {
        new iTarget = cmd_target(id, szTarget, CMDTARGET_ALLOW_SELF);

        if (!iTarget)
        {
            return PLUGIN_HANDLED;
        }

        get_user_name(iTarget, szTarget, charsmax(szTarget));
        get_user_ip(iTarget, szTargetIP, charsmax(szTargetIP), 1);
    }
    else
    {
        copy(szTargetIP, charsmax(szTargetIP), szTarget);
    }

    new szAdminName[32];
    get_user_name(id, szAdminName, charsmax(szAdminName));

    console_print(id, "%s", UngagUser(szTarget, szTargetIP, szAdminName));

    return PLUGIN_HANDLED;
}

public CommandGagMenu(id, iLevel, iCmdId)
{
    if (!cmd_access(id, iLevel, iCmdId, 1))
    {
        return PLUGIN_HANDLED;
    }

    g_iGagTimeIndex[id] = 0;
    g_iUserTarget[id] = 0;
    ShowGagMenu(id);

    return PLUGIN_HANDLED;
}

ShowGagMenu(id, page = 0)
{
    new iMenu = menu_create("\rGag Menu", "GagMenuHandler");

    new iPlayers[32], iPlayersNum;
    get_players(iPlayers, iPlayersNum);

    new szItem[64], szName[32], szIndex[8];
    new iPlayer;

    for (new i = 0; i < iPlayersNum; i++)
    {
        iPlayer = iPlayers[i];

        if (i % 6 == 0)
        {
            formatex(szItem, charsmax(szItem), "\yGag length \r[\w%s\r]^n", g_GagTimes[g_iGagTimeIndex[id]][DISPLAY]);
            menu_additem(iMenu, szItem, "time");
        }

        get_user_name(iPlayer, szName, charsmax(szName));
        num_to_str(iPlayer, szIndex, charsmax(szIndex));

        if (IsUserGagged(iPlayer, false))
        {
            formatex(szItem, charsmax(szItem), "\y%s \r[\wGagged\r]", szName);
        }
        else if (get_user_flags(iPlayer) & ADMIN_IMMUNITY)
        {
            formatex(szItem, charsmax(szItem), "\d%s \r[\wHas immunity\r]", szName);
        }
        else
        {
            copy(szItem, charsmax(szItem), szName);
        }

        menu_additem(iMenu, szItem, szIndex);
    }

    menu_display(id, iMenu, page);
}

public GagMenuHandler(id, iMenu, Item)
{
    if (Item == MENU_EXIT)
    {
        menu_destroy(iMenu);
        return;
    }

    new szInfo[8], iTemp;
    menu_item_getinfo(iMenu, Item, iTemp, szInfo, charsmax(szInfo), _, _, iTemp);

    if (equal(szInfo, "time"))
    {
        ++g_iGagTimeIndex[id];
        g_iGagTimeIndex[id] %= sizeof g_GagTimes;
        menu_destroy(iMenu);
        ShowGagMenu(id, Item / 7);
        return;
    }

    new iTarget = str_to_num(szInfo);

    if (IsUserGagged(iTarget, false))
    {
        new szName[32], szIP[16], szAdminName[32];
        get_user_name(id, szAdminName, charsmax(szAdminName));
        get_user_name(iTarget, szName, charsmax(szName));
        get_user_ip(iTarget, szIP, charsmax(szIP), 1);

        UngagUser(szName, szIP, szAdminName);

        menu_destroy(iMenu);
        return;
    }

    if (get_user_flags(iTarget) & ADMIN_IMMUNITY)
    {
        menu_destroy(iMenu);
        return;
    }

    g_iUserTarget[id] = iTarget;
    client_cmd(id, "messagemode amx_TYPE_GAGREASON");

    menu_destroy(iMenu);
}

public CommandGagReason(id, iLevel, iCmdId)
{
    if (!cmd_access(id, iLevel, iCmdId, 2) || !is_user_connected(g_iUserTarget[id]))
    {
        return PLUGIN_HANDLED;
    }

    new szReason[64], szName[32], szIP[16], szAdminName[32];
    read_argv(1, szReason, charsmax(szReason));

    get_user_name(id, szAdminName, charsmax(szAdminName));

    get_user_name(g_iUserTarget[id], szName, charsmax(szName));
    get_user_ip(g_iUserTarget[id], szIP, charsmax(szIP), 1);

    GagUser(szName, szIP, g_GagTimes[g_iGagTimeIndex[id]][MINUTES], szReason, szAdminName);

    ShowGagMenu(id);

    return PLUGIN_HANDLED;
}

UngagUser(szName[], szIP[], szAdmin[])
{
    new szResult[64], szTemp[3];

    if (!nvault_get(g_iNVaultHandle, szIP, szTemp, charsmax(szTemp)))
    {
        formatex(szResult, charsmax(szResult), "User with IP %s not found.", szIP);
        return szResult;
    }

    nvault_remove(g_iNVaultHandle, szIP);

    if (!equal(szName, szIP))
    {
        new iTarget = cmd_target(0, szName, 0);

        PrintChatColor(iTarget, PRINT_COLOR_PLAYERTEAM, "!g%s!y You have been ungagged by admin!t %s!y!", g_szChatPrefix, szAdmin);

        PrintChatColor(0, PRINT_COLOR_PLAYERTEAM, "!g%s!y Player!t %s!y has been ungagged by!g %s!y.", g_szChatPrefix, szName, szAdmin);
    }


    log_to_file(g_szLogFile, "[UNGAG] ADMIN: %s | TARGET_NAME: %s [IP: %s]", szAdmin, szName, szIP);

    copy(szResult, charsmax(szResult), "Player has been ungagged");
    return szResult;
}

GagUser(szName[], szIP[], iDuration, szReason[], szAdminName[])
{
    new iExpireTime = iDuration != 0 ? get_systime() + (iDuration * 60) : 0;

    new szResult[64];

    if (nvault_get(g_iNVaultHandle, szIP, szResult, charsmax(szResult)))
    {
        copy(szResult, charsmax(szResult), "Player is already gagged.");
        return szResult;
    }

    new szValue[512];
    formatex(szValue, charsmax(szValue), "^"%s^"#^"%s^"#%d#^"%s^"", szName, szReason, iExpireTime, szAdminName);

    if (iExpireTime == 0)
    {
        PrintChatColor(0, PRINT_COLOR_PLAYERTEAM, "!g%s!y Player!t %s!y has been gagged by!g %s!y. Reason: !t%s!y. Gag expires!t never!y.", g_szChatPrefix, szName, szAdminName, szReason);
    }
    else
    {
        PrintChatColor(0, PRINT_COLOR_PLAYERTEAM, "!g%s!y Player!t %s!y has been gagged by!g %s!y. Reason: !t%s!y. Gag expires!t %s", g_szChatPrefix, szName, szAdminName, szReason, GetTimeAsString(iDuration * 60));
    }

    log_to_file(g_szLogFile, "ADMIN: %s | PLAYER: %s [IP: %s] | REASON: %s | TIME: %s", szAdminName, szName, szIP, szReason, GetTimeAsString(iDuration * 60));

    nvault_set(g_iNVaultHandle, szIP, szValue);

    copy(szResult, charsmax(szResult), "Player successfully gagged.");
    return szResult;
}

bool:IsUserGagged(id, bool:print = true)
{
    new szIP[16], szVaultData[512];
    get_user_ip(id, szIP, charsmax(szIP), 1);

    if (!nvault_get(g_iNVaultHandle, szIP, szVaultData, charsmax(szVaultData)))
    {
        return false;
    }

    new szGaggedName[32], szReason[64], szExpireDate[32], szAdminName[32];
    replace_all(szVaultData, charsmax(szVaultData), "#", " ");
    parse(szVaultData, szGaggedName, charsmax(szGaggedName), szReason, charsmax(szReason), szExpireDate, charsmax(szExpireDate), szAdminName, charsmax(szAdminName));

    new iExpireTime = str_to_num(szExpireDate);

    if (get_systime() < iExpireTime || iExpireTime == 0)
    {
        if (print)
        {
            if (iExpireTime == 0)
            {
                PrintChatColor(id, PRINT_COLOR_PLAYERTEAM, "!g%s!y You are gagged! Your gag expires!t never!y.", g_szChatPrefix);
            }
            else
            {
                PrintChatColor(id, PRINT_COLOR_PLAYERTEAM, "!g%s!y You are gagged! Your gag expires in!t %s", g_szChatPrefix, GetTimeAsString(iExpireTime - get_systime()));
            }

            PrintChatColor(id, PRINT_COLOR_PLAYERTEAM, "!g%s!y Gagged by!g %s!y. Gagged nickname:!t %s!y. Gag reason:!t %s!y.", g_szChatPrefix, szAdminName, szGaggedName, szReason);
        }

        return true;
    }

    nvault_remove(g_iNVaultHandle, szIP);

    return false;
}

GetTimeAsString(seconds)
{
    new iYears = seconds / 31536000;
    seconds %= 31536000;

    new iMonths = seconds / 2592000;
    seconds %= 2592000;

    new iWeeks = seconds / 604800;
    seconds %= 604800;

    new iDays = seconds / 86400;
    seconds %= 86400;

    new iHours = seconds / 3600;
    seconds %= 3600;

    new iMinutes = seconds / 60;
    seconds %= 60;

    new szResult[256];

    if (iYears)
    {
        format(szResult, charsmax(szResult), "%s%d Year%s ", szResult, iYears, iYears == 1 ? "" : "s");
    }

    if (iMonths)
    {
        format(szResult, charsmax(szResult), "%s%d Month%s ", szResult, iMonths, iMonths == 1 ? "" : "s");
    }

    if (iWeeks)
    {
        format(szResult, charsmax(szResult), "%s%d Week%s ", szResult, iWeeks, iWeeks == 1 ? "" : "s");
    }

    if (iDays)
    {
        format(szResult, charsmax(szResult), "%s%d Day%s ", szResult, iDays, iDays == 1 ? "" : "s");
    }

    if (iHours)
    {
        format(szResult, charsmax(szResult), "%s%d Hour%s ", szResult, iHours, iHours == 1 ? "" : "s");
    }

    if (iMinutes)
    {
        format(szResult, charsmax(szResult), "%s%d Minute%s ", szResult, iMinutes, iMinutes == 1 ? "" : "s");
    }

    if (seconds)
    {
        format(szResult, charsmax(szResult), "%s%d Second%s", szResult, seconds, seconds == 1 ? "" : "s");
    }

    return szResult;
}

Аватар
Smiley
Извън линия
Foreigner
Foreigner
Мнения: 26
Регистриран на: 12 Дек 2017, 22:40

Gag System v0.2 ALPHA Testing

Мнение от Smiley » 15 Дек 2017, 12:18

@TheRedShoko, when will be the next update of this plugin?

Аватар
TheRedShoko
Извън линия
Модератор
Модератор
Мнения: 1016
Регистриран на: 06 Окт 2016, 07:42
Местоположение: Бургас
Се отблагодари: 5 пъти
Получена благодарност: 84 пъти

Gag System v0.2 ALPHA Testing

Мнение от TheRedShoko » 15 Дек 2017, 15:20

As soon as I've some free time. Btw the plugin you've given saves the gags just for the map. Anyway, I'm not going to implement the authid + ip checking since there may be problems. I'll leave it like that for now.

Аватар
deadlylord
Извън линия
Потребител
Потребител
Мнения: 572
Регистриран на: 04 Апр 2017, 16:35
Местоположение: Бургас, България
Получена благодарност: 2 пъти
Обратна връзка:

Gag System v0.2 ALPHA Testing

Мнение от deadlylord » 15 Дек 2017, 16:01

Then what is the point of having all of the gag times, when they don't matter and the gag expires after the map end, from the utility standpoint the plugin sucks and server no job, because even if the alternatives are worse written, you make sure that the players will remain gagged, thus making them way better

Аватар
Smiley
Извън линия
Foreigner
Foreigner
Мнения: 26
Регистриран на: 12 Дек 2017, 22:40

Gag System v0.2 ALPHA Testing

Мнение от Smiley » 15 Дек 2017, 17:36

Your plugin how it saves gags now?
Isn't so good to still switching, ip can be reseted if is routable, steamid is not better for non-steam servers.
You must to do something with this problem, if not exist a lot plugins of gag what do the same things...

Аватар
TheRedShoko
Извън линия
Модератор
Модератор
Мнения: 1016
Регистриран на: 06 Окт 2016, 07:42
Местоположение: Бургас
Се отблагодари: 5 пъти
Получена благодарност: 84 пъти

Gag System v0.2 ALPHA Testing

Мнение от TheRedShoko » 15 Дек 2017, 21:58

deadlylord написа: 15 Дек 2017, 16:01 Then what is the point of having all of the gag times, when they don't matter and the gag expires after the map end, from the utility standpoint the plugin sucks and server no job, because even if the alternatives are worse written, you make sure that the players will remain gagged, thus making them way better
Изобщо направи ли си труда да прочетеш като хората мнението ми? Става въпрос за плъгина, който той е дал, а не който аз съм качил.
Smiley написа: 15 Дек 2017, 17:36 Your plugin how it saves gags now?
Isn't so good to still switching, ip can be reseted if is routable, steamid is not better for non-steam servers.
You must to do something with this problem, if not exist a lot plugins of gag what do the same things...
It saves them by IP. Both steamid and IP are not reliable enough. I've no idea what can be done to fix this. As I see neither you have idea about that.

Публикувай отговор
  • Подобни теми
    Отговори
    Преглеждания
     Последно мнение

Обратно към “Одобрени плъгини”

Кой е на линия

Потребители разглеждащи този форум: 0 регистрирани и 9 госта