Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #include <engine>
- #include <regex>
- #define TAG "PLAY-ARENA"
- #define GAG_DEFAULT_TIME 5
- #define TASK 12830
- #define EXCLUDE_GAG ADMIN_IMMUNITY
- #define G_A_G 60
- // Regex
- #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 LogMsg[126]
- new LogAdminMsg[126]
- new gagIp[512][32]
- new gagDetails[512][256]
- new gagPlayer[33]=false
- /*********************/
- new gagMultiple=false
- new const bChat [][] = {
- // Reclama
- ":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",
- "89.40.104.98",
- "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 , ESTE EVENT V.I.P FREE ! DUREAZA DOAR O ORA ASA CA GRABESTE-TE!!!",
- "CON NECT",
- "CS . UDP . RO",
- "cs.udp.ro",
- "GO TO CS.VIPARENA.RO",
- "JB--ALPHA--CS--RO",
- "ALPHA",
- "JB-",
- "AVALA",
- // Other
- // Prescurtari
- "fmm" ,
- // Injuraturi
- "pula" ,
- "pizda" ,
- "ma-ta" ,
- "muie" ,
- "fut"
- }
- public plugin_init()
- {
- register_plugin("Gag", "www.play-arena.ro/forum", "PedoBear")
- register_concmd("say", "vSay")
- register_concmd("say_team", "vSay")
- register_concmd("amx_gag", "cAmxGag", ADMIN_KICK, "<nume | @ALL> <durata> <motiv>")
- register_concmd("amx_ungag", "cAmxUnGag", ADMIN_KICK, "<nume | @ALL>")
- get_datadir(DataDir, charsmax(DataDir))
- new error[2]
- g_IP_pattern = regex_compile(REGEX_IP_PATTERN, g_regex_return, error, sizeof(error) - 1)
- cFile()
- }
- cFile() {
- new fDir[126], Data[64]
- get_time("%d.%m.%Y", Data, 63)
- format(fDir, 125, "%s/chatlog", DataDir)
- // Create dir
- if (!dir_exists(fDir))
- mkdir(fDir)
- format(fDir, 125, "%s/chatlog/%s.log", DataDir, Data)
- if (!file_exists(fDir))
- write_file(fDir, "- START LOG - by PedoBear -", -1)
- format(LogAdminMsg, 125, "%s/chatlog/Admin_Special_Say.log", DataDir)
- if (!file_exists(LogAdminMsg))
- write_file(LogAdminMsg, "- LOG - Cuvinte Blocate - by PedoBear -", -1)
- copy(LogMsg, 125, fDir)
- }
- public vSay(id) {
- new sText[256]
- read_args(sText, 255)
- remove_quotes(sText)
- if (equali(sText, "/scoategagbot"))
- {
- new hGag = VerificaGagJucator(id)
- RemoveIp(hGag)
- gagPlayer[id]=false
- remove_task(hGag+TASK)
- xColor(id, "PedoBear -> Te saluta serverul :).")
- return PLUGIN_HANDLED
- }
- if (gagPlayer[id]) {
- new slot = VerificaGagJucator(id)
- new dName[32], dTime[32], dDurata[10], dReason[126], transTime[2]
- parse(gagDetails[slot], dName, 31, dTime, 31, dDurata, 9, dReason, 125)
- fTransformSec((str_to_num(dTime) + (str_to_num(dDurata) * G_A_G) - time()), transTime)
- xColor(id, "!g%s!n ti-a dat gag. Motiv:!g %s!n. Timp ramas:!g %d!n minut%s si!g %d!n secund%s", dName, dReason, transTime[0], transTime[0]==1 ? "" : "e", transTime[1], transTime[1]==1 ? "a" : "e")
- return PLUGIN_HANDLED
- } else {
- new nSay[32], whyGag[64]
- if (!strlen(sText))
- return PLUGIN_CONTINUE
- strtoupper(sText)
- // Verify is IP Say
- if (VerifySayIP(sText, nSay, 31)) {
- format(whyGag, 63, "Reclama la IP [%s]", nSay)
- ActGagJucator(0, id, time(), GAG_DEFAULT_TIME, whyGag)
- xColor(id, "Ai primit gag deoarece ai facut reclama la IP:!g %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) {
- xlogAdminMsg(id, i, sText)
- format(whyGag, 63, "Cuvant blocat [%s]", bChat[i])
- // xColor(id, "Mesajul nu a fost trimis deoarece contine:!g %s!n.", bChat[i])
- return PLUGIN_HANDLED
- } else {
- xlogMsg(id, i, sText)
- format(whyGag, 63, "Cuvant blocat [%s]", bChat[i])
- // xColor(id, "Mesajul nu a fost trimis deoarece contine:!g %s!n.", bChat[i])
- return PLUGIN_HANDLED
- }
- }
- }
- xlogMsg(id, -1, sText)
- }
- return PLUGIN_CONTINUE
- }
- public client_disconnect(id) {
- gagPlayer[id]=false
- new slot = VerificaGagJucator(id)
- new pName[32]
- get_user_name(id, pName, 31)
- if (slot != 0)
- xColor(0, "Jucatorul!g %s!n avea gag si s-a deconectat", pName)
- }
- public client_putinserver(id) {
- new slot = VerificaGagJucator(id)
- new pName[32], dName[32], dTime[32], dDurata[10], dReason[126], transTime[2]
- get_user_name(id, pName, 31)
- if (slot != 0) {
- parse(gagDetails[slot], dName, 31, dTime, 31, dDurata, 9, dReason, 125)
- fTransformSec((str_to_num(dTime) + (str_to_num(dDurata) * G_A_G) - time()), transTime)
- xColor(0, "Jucatorul!g %s!n s-a reconectat cand avea gag. Timp ramas gag:!g %d!n minut%s si!g %d!n secund%s", pName, transTime[0], transTime[0]==1 ? "" : "e", transTime[1], transTime[1]==1 ? "a" : "e")
- 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)
- if (equal(Victim, "@ALL")) {
- new xP[32], xN
- get_players(xP, xN, "c")
- for (new i=0; i < xN; i++)
- gagPlayer[xP[i]]=false
- RemoveAllIp()
- gagMultiple=false
- remove_task(TASK+TASK)
- console_print(id, "Ai scos gagul la toti jucatorii")
- xColor(0, "!g%s!n scoate gag la toti jucatorii.", aName)
- } else {
- new id2 = cmd_target(id, Victim, 8)
- if (!id2)
- return PLUGIN_HANDLED
- get_user_name(id2, pName, 31)
- new hGag = VerificaGagJucator(id2)
- if (hGag != 0) {
- remove_task(hGag+TASK)
- RemoveIp(hGag)
- gagPlayer[id2]=false
- xColor(0, "!g%s!n ia scos gagul lui!g %s!n.", aName, pName)
- } else
- console_print(id, "Jucatorul %s nu are gag.", 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, "# Poti sa-i dai gag minim 1 minut")
- return PLUGIN_CONTINUE
- }
- if (strlen(gReason) < 1)
- format(gReason, 125, "Fara Motiv")
- if (equal(Victim, "@ALL")) {
- new xP[32], xN
- get_players(xP, xN, "c")
- format(Temp, 9, "%d", gagTime * G_A_G)
- new Float:gagTask = floatstr(Temp)
- for (new i=0; i < xN; i++) {
- new slot = VerificaGagJucator(xP[i])
- if (gagPlayer[xP[i]]) {
- remove_task(slot+TASK)
- RemoveIp(slot)
- gagPlayer[xP[i]]=false
- }
- if (gagMultiple) {
- console_print(id, "Jucatorii au deja gag.")
- return PLUGIN_HANDLED
- }
- if (get_user_flags(xP[i]) & EXCLUDE_GAG)
- continue
- new gStatus = ActGagJucator(id, xP[i], time(), gagTime, gReason)
- set_task(gagTask, "TaskUnGag2", gStatus+TASK)
- }
- gagMultiple=true
- set_task(gagTask, "TaskMultiple", TASK+TASK)
- console_print(id, "Ai dat gag la toti jucatorii.")
- xColor(0, "!g%s!n da gag la toti jucatorii. [Durata:!g%d!n minut%s] [Motiv:!g%s!n]", aName, gagTime, gagTime==1 ? "" : "e", gReason)
- } else {
- new id2 = cmd_target(id, Victim, 8)
- if (!id2)
- return PLUGIN_HANDLED
- get_user_name(id2, pName, 31)
- new hGag = VerificaGagJucator(id2)
- if (hGag != 0) {
- new dName[32], dTime[32], dDurata[10], dReason[126]
- parse(gagDetails[hGag], dName, 31, dTime, 31, dDurata, 9, dReason, 125)
- fTransformSec((str_to_num(dTime) + (str_to_num(dDurata) * G_A_G) - time()), transTime)
- console_print(id, "## Jucatorul [%s] are deja gag ##", pName)
- console_print(id, "# Admin: %s", dName)
- console_print(id, "# Durata: %d minut%s", str_to_num(dDurata), str_to_num(dDurata)==1 ? "" : "e")
- console_print(id, "# Ramas: %d minut%s si %d secund%s", transTime[0], transTime[0]==1 ? "" : "e", transTime[1], transTime[1]==1 ? "a" : "e")
- console_print(id, "# Motiv: %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)
- xColor(0, "!g%s!n: Ii da gag lui!g %s!n.[Durata:!g%d!n minut%s] [Motiv:!g%s!n]", aName, pName, gagTime, gagTime==1 ? "" : "e", gReason)
- console_print(id, "## Jucatorul %s a primit gag", pName)
- console_print(id, "# Durata: %d minut%s", gagTime, gagTime==1 ? "" : "e")
- console_print(id, "# Motiv: %s", gReason)
- console_print(id, "#########################################")
- } else
- console_print(id, "Nu ii pot da gag lui %s", pName)
- }
- }
- return PLUGIN_HANDLED
- }
- /***************************** FUNCTII *****************************/
- /* UnGag2 Task */
- public TaskUnGag2(s) {
- new sIp = s-TASK
- new pOn = IsIpOnline(gagIp[sIp])
- if (pOn != 0) {
- new pName[32]
- get_user_name(pOn, pName, 31)
- gagPlayer[pOn]=false
- }
- RemoveIp(sIp)
- }
- /* UnGag Task */
- public TaskUnGag(s) {
- new sIp = s-TASK
- new pOn = IsIpOnline(gagIp[sIp])
- if (pOn != 0) {
- new pName[32]
- get_user_name(pOn, pName, 31)
- gagPlayer[pOn]=false
- xColor(pOn, "Jucatorul!g %s!n poate sa vorbeasca.", pName)
- }
- RemoveIp(sIp)
- }
- /* Task Multiple */
- public TaskMultiple() {
- xColor(0, "Toti jucatorii pot vorbi acum.")
- gagMultiple=false
- }
- /* Verifica daca IP-ul este conectat */
- IsIpOnline(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
- }
- /* Gag jucator */
- ActGagJucator(id, id2, xTime, xDurata, xMotiv[]) {
- new Ip[32], aNume[32]
- if (id != 0)
- get_user_name(id, aNume, 31)
- else
- format(aNume, 31, "HNS.CSPLAY.RO")
- 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, xDurata, xMotiv)
- gagPlayer[id2]=true
- set_speak(id2, SPEAK_MUTED)
- return i
- }
- return 0
- }
- /* Remove IP */
- RemoveIp(slot) {
- format(gagIp[slot], charsmax(gagIp[]), "")
- format(gagDetails[slot], charsmax(gagDetails[]), "")
- }
- /* Remove All IP */
- RemoveAllIp() {
- for (new i=1; i < sizeof(gagIp); i++)
- RemoveIp(i)
- }
- /* Transform sec to min/sec */
- fTransformSec(sec, xBack[]) {
- xBack[0] = (sec / 60) % 60 // Minute
- xBack[1] = sec % 60 // Secunde
- }
- /* Verifica daca jucatorul are sau nu gag */
- VerificaGagJucator(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
- }
- /* Verifica daca jucatorul a scris vreun IP in chat */
- VerifySayIP(sText[], nSay[], max) {
- if (strlen(sText) > 10) {
- new xC=50, xT1[126], xT2[125]
- for (new i=0; i < xC; i++) {
- // First
- if (i==0)
- strbreak(sText, xT1, 31, xT2, 31)
- else
- strbreak(xT2, xT1, 31, xT2, 31)
- if (IsIP(xT1)) {
- copy(nSay, max, xT1)
- return true
- }
- }
- }
- return false
- }
- /* Log msg */
- stock xlogMsg(id, b, msg[]) {
- if (!file_exists(LogMsg))
- cFile()
- new Data[64], fLog[256], xName[32]
- get_user_name(id, xName, 31)
- get_time("%H:%M:%S", Data, 63)
- if (b != -1) {
- write_file(LogMsg, "[ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ]", -1)
- format(fLog, 255, "[%s] [%s] -> %s -> [%s]", Data, xName, msg, bChat[b])
- write_file(LogMsg, fLog, -1)
- write_file(LogMsg, "[ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ]", -1)
- }
- else {
- format(fLog, 255, "[%s] [%s]: %s", Data, xName, msg)
- write_file(LogMsg, fLog, -1)
- }
- }
- /* Log admin msg */
- stock xlogAdminMsg(id, b, msg[]) {
- if (!file_exists(LogAdminMsg))
- cFile()
- new Data[64], fLog[256], xName[32]
- get_user_name(id, xName, 31)
- get_time("%d.%m.%Y %H:%M:%S", Data, 63)
- format(fLog, 255, "[%s] [%s] -> %s -> [%s]", Data, xName, msg, bChat[b])
- write_file(LogAdminMsg, fLog, -1)
- }
- /* */
- stock xColor(const id, const input[], any:...)
- {
- new count = 1, players[32]
- static msg[320], msg2[320]
- vformat(msg, 190, input, 3)
- formatex(msg2, 190, "!n[!g%s!n] %s", TAG, msg)
- replace_all(msg2, 190, "!g", "^4")
- replace_all(msg2, 190, "!n", "^1")
- replace_all(msg2, 190, "!t", "^3")
- replace_all(msg2, 190, "!t2", "^0")
- if (id) players[0] = id; else get_players(players, count, "ch")
- {
- for (new i = 0; i < count; i++)
- {
- if (is_user_connected(players[i]))
- {
- message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
- write_byte(players[i])
- write_string(msg2)
- message_end()
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment