Request edit gag plugin

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
137
Реакции
23
Помог
2 раз(а)
Hello, i want to add function for permanent gag example amx_gag "nick" "time 0" "reason", also i want add function gagged player to unable talk in amx_chat (admin chat). And if possible to load spam words from .ini file

Код:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <regex>

#define GAG_DEFAULT_TIME    2
#define TASK                12830
#define EXCLUDE_GAG            ADMIN_IMMUNITY
#define G_A_G                60

#define REGEX_IP_PATTERN "\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
#define IsIP(%1) (regex_match_c(%1, g_IP_pattern, g_regex_return) > 0)

new Regex:g_IP_pattern
new g_regex_return
new DataDir[64]
new gagIp[512][32]
new gagDetails[512][256]
new gagPlayer[33]=false

new SERVERNAME  [] = "";

new const bChat [][] = {
// SPAM
    ":27015"    ,
    "www."        ,
    ".ro"        ,
    ".info"        ,
    ".ws"        ,
    ".biz"        ,
    ".com"        ,
    ".org"        ,
    ".net"        ,
    ". ro"        ,
    ".ro"        ,
    ". info"    ,
    ". ws"        ,
    ". biz"        ,
    ". com"        ,
    ". org"        ,
    ". net"        ,
    ".r.o"        ,
    ".c.o.m"    ,
    ".i.n.f.o"    ,
    ".n.e.t"    ,
    "jb ."    ,
    "jb."    ,
    "cs16"    ,
    "alphacs"    ,
    "jbx."    ,
    "VIP GRATIS",
    "C  O  N  E  C  T  - J  B  .  C  S  1  6  .  R  O",
    "C  O  N  E  C  T",
    "J  B  .  C  S  1  6  .  R  O",
    "VIP GRATIS",
    "PB.READFEAR.RO",
    "C  O  N  E  C  T  - J  B  .  C  S  1  6  .  R  O -",
    "C  O  N  E  C  T  - J  B  .  C  S  1  6  .  R  O -VIP GRATIS",
    "C  O  N  E  C  T  - J  B  .  C  S  1  6  .  R  O -VIP SI DETINATOR GRATIS",
    "jb.cs16.ro",
    "C  O  N  E  C  T  -   J  B  .  C  S  1  6  .  R  O   - A D MINE FREE",
    "C , O , N , E , C , T , -  , J , B , . , C , S , 1 , 6 , . , R , O ",
    "C  O  N  E  C  T",
    "J B . FIORIGINAL . R0 CEL MAI TARE SERVER GO GO GO VA ASTEPTAM GO !",
    "J B . FIORIGINAL . R0",
    "J ]B . FIORIGINAL . R 0 GO GO GO CEL MAI TARE SV VA ASTEPTAM CU DRAG!",
    "INTRA PE ZOMBIE[.]FRAGBITE[.]RO BEST SERVER FOREVER",
    "ZOMBIE[.]FRAGBITE[.]RO",
    "FRAGBITE[.]RO",
    "fragbite.ro",
    "zm.",
    "INTRA PE ZOMBIE[.]FRAGBITE[.]RO BEST SERVER ZOMBIE XP",
    "HAI PE CEL MAI BUN SERVER DE ZM [89.40.104.98] INTRA SI NU ITI VA PAREA RAU",
    "INTRA PE ZOMBIE[.]FRAGBITE[.]RO BEST SERVER ZOMBIE XP",
    "C / O / N / E / C / T  -   J / B / . / C / S / 1 / 6 / . / R / O   - A D MINE FREE",
    "ADMINE FREE",
    "C / O / N / E / C / T",
    "INTRA PE ZOMBIE[.]FRAGBITE[.]RO BEST SERVER ZOMBIE XP",
    "J B . FIORIGINAL . R0 CEL MAI TARE SERVER GO GO GO VA ASTEPTAM GO !",
    "GO GO GO CEL MAI TARE!",
    "JB . FIORIGINAL . RO",
    "fioriginal",
    "indungi",
    "jb.indungi.ro",
    "J b . i n d u n g i . r o",
    "cs.viparena.ro",
    "viparena",
    "cs viparena ro",
    "DOBS",
    "jb.dobs.ro",
    "jb dobs ro",
    "JB.,FIORIGILAL. RO",
    "WWW.ESPORTSKOSOVA.COM",
    "ESPORTSKOSOVA",
    "CON NECT",
    "CS . UDP . RO",
    "cs.udp.ro",
    "GO TO CS.VIPARENA.RO",
    "JB--ALPHA--CS--RO",
    "ALPHA",
    "JB-",
    "majku",
    "picku",
    "jebem",
    "sestru",
    "familiju",
    "nabijem",
    "kurac",
    "mamu",
    "AVALA"
}

public plugin_init() {
    register_plugin("GAG Plugin", "0.1", "")

    register_clcmd("say", "vSay")
    register_clcmd("say_team", "vSay")
    register_clcmd("amx_gag", "cAmxGag", ADMIN_KICK, "- <Name> <duration> <reason>")
    register_clcmd("amx_ungag", "cAmxUnGag", ADMIN_KICK, "<Name>")

    get_datadir(DataDir, charsmax(DataDir))
    new error[2]
    g_IP_pattern = regex_compile(REGEX_IP_PATTERN, g_regex_return, error, sizeof(error) - 1)
}

public vSay(id) {
    new sText[256]
    read_args(sText, 255)
    remove_quotes(sText)
    if (equali(sText, "/scoategagbot"))
    {
        new hGag = CheckPlayerGag(id)
        RemoveIp(hGag)
        gagPlayer[id]=false
        remove_task(hGag+TASK)
        client_print_color(id, id, "^4[GAG]^1 Welcome to the server")
        return PLUGIN_HANDLED
    }
    if (gagPlayer[id]) {
        new slot = CheckPlayerGag(id)
        new dName[32], dTime[32], dDurate[10], dReason[126], transTime[2]
        parse(gagDetails[slot], dName, 31, dTime, 31, dDurate, 9, dReason, 125)
        fTransformSec((str_to_num(dTime) + (str_to_num(dDurate) * G_A_G) - time()), transTime)
        client_print_color(id, id, "^4[GAG]^1 Admin ^4%s^1 Gag you. Reason:^4 %s^1. Time left:^4 %d^1 minute%s ^4%d^1 second%s", dName, dReason, transTime[0], transTime[0]==1 ? "" : "s", transTime[1], transTime[1]==1 ? "s" : "s")
        return PLUGIN_HANDLED
    } else {
        new nSay[32], whyGag[64]
        if (!strlen(sText))
            return PLUGIN_CONTINUE
        strtoupper(sText)
        if (VerifySayIP(sText, nSay, 31)) {
            format(whyGag, 63, "You spammed the IP [%s]", nSay)
            ActGagJucator(0, id, time(), GAG_DEFAULT_TIME, whyGag)
            client_print_color(id, id, "^4[GAG]^1 Gagged automatically because you spammed an ip:^4 %s", nSay)
            return PLUGIN_HANDLED
        }
        for (new i=0; i < sizeof(bChat);i++) {
            strtoupper(bChat[i])
            if (contain(sText, bChat[i]) !=-1) {
                if (get_user_flags(id) & ADMIN_RESERVATION) {
                    format(whyGag, 63, "Blocked word [%s]", bChat[i])
                    client_print_color(id, id, "^4[GAG]^1 The message was not sent because it contains:^4 %s.", bChat[i])
                    return PLUGIN_HANDLED
                } else {
                    format(whyGag, 63, "Blocked word [%s]", bChat[i])
                    client_print_color(id, id, "^4[GAG]^1 The message was not sent because it contains:^4 %s.", bChat[i])
                    return PLUGIN_HANDLED
                }
            }
        }
    }
    return PLUGIN_CONTINUE
}

public client_disconnected(id) {
    gagPlayer[id]=false
    new slot = CheckPlayerGag(id)
    new pName[32]
    get_user_name(id, pName, 31)
    if (slot != 0)
        client_print_color(0, 0, "^4[GAG]^1 The gagged player^4 %s^1 has disconnected", pName)
}

public client_putinserver(id) {
    new slot = CheckPlayerGag(id)
    new pName[32], dName[32], dTime[32], dDurate[10], dReason[126], transTime[2]
    get_user_name(id, pName, 31)
    if (slot != 0) {
        parse(gagDetails[slot], dName, 31, dTime, 31, dDurate, 9, dReason, 125)
        fTransformSec((str_to_num(dTime) + (str_to_num(dDurate) * G_A_G) - time()), transTime)
        client_print_color(0, 0, "^4[GAG]^1 The gaged player^4 %s^1 has reconnected. Time left:^4 %d^1 minute%s^4 %d^1 second%s", pName, transTime[0], transTime[0]==1 ? "" : "s", transTime[1], transTime[1]==1 ? "s" : "s")
        set_speak(id, SPEAK_MUTED)
        gagPlayer[id]=true
    }
}


public cAmxUnGag(id, level, cid) {
    if(!cmd_access (id, level, cid, 1))
        return PLUGIN_HANDLED

    new Victim[32], aName[32], pName[32]
    get_user_name(id, aName, 31)
    read_argv(1,Victim,31)
    new id2 = cmd_target(id, Victim, 8)
    if (!id2)
        return PLUGIN_HANDLED
    get_user_name(id2, pName, 31)
    new hGag = CheckPlayerGag(id2)
    if (hGag != 0) {
        remove_task(hGag+TASK)
        RemoveIp(hGag)
        gagPlayer[id2]=false
        client_print_color(0, 0, "^4[GAG]^1 Admin ^4%s^1 has ungagged^4 %s.", aName, pName)
    } else 
        console_print(id, "The Player %s is no longer gagged.", pName)

    return PLUGIN_HANDLED    
}

public cAmxGag(id, level, cid) {
    if(!cmd_access (id, level, cid, 1))
        return PLUGIN_HANDLED
        
    new Victim[32], pName[32], transTime[2], aName[32], Temp[10], gTime[10], gReason[126]
    get_user_name(id, aName, 31)
    read_argv(1,Victim,31)
    read_argv(2, gTime, 31)
    read_argv(3, gReason, 125)
    new gagTime = str_to_num(gTime)
    if (!gagTime)
        gagTime = GAG_DEFAULT_TIME
    if (gagTime < 1) {
        console_print(id, "You can gag him for at least 2 minutes")
        return PLUGIN_CONTINUE
    }
    if (strlen(gReason) < 1)
        format(gReason, 125, "Unknown")
    
    new id2 = cmd_target(id, Victim, 8)
    if (!id2)
        return PLUGIN_HANDLED
    get_user_name(id2, pName, 31)
    new hGag = CheckPlayerGag(id2)
    if (hGag != 0) {
        new dName[32], dTime[32], dDurate[10], dReason[126]
        parse(gagDetails[hGag], dName, 31, dTime, 31, dDurate, 9, dReason, 125)
        fTransformSec((str_to_num(dTime) + (str_to_num(dDurate) * G_A_G) - time()), transTime)
        console_print(id, "#########################################")
        console_print(id, "## Player [%s] Gagged ##", pName)
        console_print(id, "# Admin: %s", dName)
        console_print(id, "# Duration: %d minute%s", str_to_num(dDurate), str_to_num(dDurate)==1 ? "" : "s")
        console_print(id, "# Have passed: %d minutes%s y %d second%s", transTime[0], transTime[0]==1 ? "" : "s", transTime[1], transTime[1]==1 ? "s" : "s")
        console_print(id, "# Reason: %s", dReason)
        console_print(id, "#########################################")
    } else {
        new gStatus = ActGagJucator(id, id2, time(), gagTime, gReason)
        if (gStatus != 0) {
            format(Temp, 9, "%d", gagTime * G_A_G)
            new Float:gagTask = floatstr(Temp)
            set_task(gagTask, "TaskUnGag", gStatus+TASK)
            client_print_color(0, 0, "^4[GAG]^1 Admin ^4%s^1: has gagged^4 %s^1 [Duration:^4%d^1 minute%s] [Reason: ^4%s^1]", aName, pName, gagTime, gagTime==1 ? "" : "s", gReason)
            console_print(id, "#########################################")
            console_print(id, "## Player %s Gagged", pName)
            console_print(id, "# Duration: %d minutes%s", gagTime, gagTime==1 ? "" : "s")
            console_print(id, "# Reason: %s", gReason)
            console_print(id, "#########################################")
        } else
            console_print(id, "You can't gag %s", pName)
    }

    return PLUGIN_HANDLED
}

public TaskUnGag2(s) {
    new sIp = s-TASK
    new id    = IsIidline(gagIp[sIp])
    if (id != 0) {
        new pName[32]
        get_user_name(id, pName, 31)
        gagPlayer[id]=false
    }
    RemoveIp(sIp)
}

public TaskUnGag(s) {
    new sIp = s-TASK
    new id    = IsIidline(gagIp[sIp])
    if (id != 0) {
        new pName[32]
        get_user_name(id, pName, 31)
        gagPlayer[id]=false
        client_print_color(id, id, "^4[GAG]^1 Player ^4%s^1 can talk now.", pName)
    }
    RemoveIp(sIp)
}

IsIidline(ip[]) {
    new xP[32], xN, uIp[32]
    get_players(xP, xN, "c")
    for (new i=0; i < xN; i++) {
        get_user_ip(xP[i], uIp, 31, 1)
        if (equal(uIp, ip))
            return xP[i]    
    }
    return 0
}

ActGagJucator(id, id2, xTime, xDurate, xReason[]) {
    new Ip[32], aNume[32]
    if (id != 0)
        get_user_name(id, aNume, 31)
    else
        format(aNume, 31, "%s",SERVERNAME)
    get_user_ip(id2, Ip, 31, 1)
    for (new i=1; i < sizeof(gagIp); i++)
        if (equal(gagIp[i], "")) {
            copy(gagIp[i], charsmax(gagIp[]), Ip)
            format(gagDetails[i], charsmax(gagDetails[]), "^"%s^" ^"%d^" ^"%d^" ^"%s^"", aNume, xTime, xDurate, xReason)
            gagPlayer[id2]=true
            set_speak(id2, SPEAK_MUTED)
            return i
        }
    return 0
}
 
RemoveIp(slot) {
    format(gagIp[slot], charsmax(gagIp[]), "")
    format(gagDetails[slot], charsmax(gagDetails[]), "")
}

fTransformSec(sec, xBack[]) {
    xBack[0] = (sec / 60) % 60        // minuta
    xBack[1] = sec % 60                // secunda
}

CheckPlayerGag(id) {
    new Ip[32]
    get_user_ip(id, Ip, 31, 1)
    for (new i=1; i < sizeof(gagIp); i++)
        if (equal(gagIp[i], Ip))
            return i
    return 0
}

VerifySayIP(sText[], nSay[], max) {
    if (strlen(sText) > 10) {
        new xC=50, xT1[126], xT2[125]
        for (new i=0; i < xC; i++) {
            if (i==0)
                argbreak(sText, xT1, 31, xT2, 31)
            else
                argbreak(xT2, xT1, 31, xT2, 31)
                
            if (IsIP(xT1)) {
                copy(nSay, max, xT1)
                return true
            }
        }
    }
    return false
}
 
Сообщения
1,293
Реакции
2,295
Помог
57 раз(а)
Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу