Русское сообщество по скриптингу

Help edit gag Manager

Scripting help for english speaking users. While not very active, you still have a chance to get help here.
Правила форума
We cannot maintain english version version of our forum rules, but shortly (it's simple) - Don't be a dick. If you really want to know our rules you should check appropriate thread.

Help edit gag Manager

Сообщение VenomIvanof » 03 апр 2016, 13:13

Can someone help me or teach me how to add a gag menu and reason?
I want to add a /gagmenu (when you write /gagmenu to show players > next gag min > next reason) and reason / for example: amx_gag "name" "time "reason"
here is a plugin like that i want, but it gag by IP .. i don't want to gag by IP.
Код: Выделить всё
//nVault version by carbonated @ amxxbg.org

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <unixtime>

//#define SQL

#if defined SQL
#include <sqlx>
#else
#include <nvault>
#endif

#pragma semicolon 0

#if defined SQL
#define PLUGIN   "Gag System [SQLx]"
#else
#define PLUGIN   "Gag System [nVault]"
#endif
#define AUTHOR   "kostov"
#define VERSION   "1.0"

#if defined SQL
new Handle:g_iSqlX, Handle:g_iSqlConn;
new iError[512]
#else
new iVaultHandle;
#endif
new MsgHudSync, SayText, iTime;
new iCacheUserName[34], bool:iUserGaGed[33];
new iCacheAdmName[34], iCacheUserIp[18];
new iMaxGagTime, iFlagGagTime;

#if !defined SQL
new const log_file[] = "addons/amxmodx/logs/gagsystem.log"
#endif

public plugin_init()
{
   register_plugin(PLUGIN, VERSION, AUTHOR);
   
   register_cvar("gag_system", VERSION, FCVAR_SERVER|FCVAR_SPONLY);
   
   iMaxGagTime = register_cvar("amx_maxgag_time", "20");
   iFlagGagTime = register_cvar("amx_maxgag_flag", "d");
   
   register_concmd("amx_gag", "cmdGag", ADMIN_LEVEL_B, "<name> <time> [reason]");
   register_concmd("amx_ungag", "cmdUnGag", ADMIN_LEVEL_B, "<ip>");
   register_concmd("amx_gagmenu", "cmdGagMenu", ADMIN_LEVEL_B);
   register_concmd("amx_gagreason", "cmdGagReason", ADMIN_LEVEL_B);
   register_concmd("amx_gag_clean", "cmdCleanTable", ADMIN_RCON);
   
   register_concmd("say", "cmdSayChat", -1);
   register_concmd("say_team", "cmdSayChat", -1);
   
   MsgHudSync   = CreateHudSyncObj();
   SayText    = get_user_msgid("SayText");
   
   #if defined SQL
   set_task(1.0, "plugin_mysql_init");
   set_task(30.0, "plugin_remove_past_gag");
   #else
   iVaultHandle = nvault_open("gagsys");
   if(iVaultHandle == INVALID_HANDLE) {
      log_to_file(log_file, "[%s] nVault ERROR!", PLUGIN);
      set_fail_state("Error opening nVault");
   }
   
   server_print("[%s] The plugin loaded the nVault database.", PLUGIN);
   #endif
}

public plugin_end()
{
   #if defined SQL
   if(g_iSqlConn)
   {
      SQL_FreeHandle(g_iSqlConn);
      SQL_FreeHandle(g_iSqlX);
   }
   #else
   nvault_close(iVaultHandle);
   #endif
}

#if defined SQL
public plugin_mysql_init()
{
   new iHost[64], iUser[64], iPass[64], iDb[64], iErrorCode;
   get_cvar_string("amx_sql_host", iHost, sizeof iHost - 1);
   get_cvar_string("amx_sql_user", iUser, sizeof iUser - 1);
   get_cvar_string("amx_sql_pass", iPass, sizeof iPass - 1);
   get_cvar_string("amx_sql_db", iDb, sizeof iDb - 1);
   
   g_iSqlX    = SQL_MakeDbTuple(iHost, iUser, iPass, iDb);
   g_iSqlConn = SQL_Connect(g_iSqlX, iErrorCode, iError, sizeof iError - 1);
   
   if(!g_iSqlConn)
   {
      server_cmd("Could not connect to SQL database!");
      SQL_FreeHandle(g_iSqlConn);
      SQL_FreeHandle(g_iSqlX);
   }
   
   server_cmd("%s Connected!", PLUGIN);
}

public plugin_remove_past_gag()
{
   new Handle:get;
   get = SQL_PrepareQuery(g_iSqlConn, "DELETE FROM `amx_gag` WHERE time <= UNIX_TIMESTAMP(now());");
   SQL_Execute(get);
   SQL_FreeHandle(get);
}
#endif

public cmdGag(id, level, cid)
{
   if(!cmd_access(id, level, cid, 3))
   {
      return PLUGIN_HANDLED;
   }
   
   new iArg[32], iTime[5], iReason[129];
   read_argv(1, iArg, sizeof iArg - 1);
   read_argv(2, iTime, sizeof iTime - 1);
   read_argv(3, iReason, sizeof iReason - 1);
   
   new AdminName[33];
   get_user_name(id, AdminName, sizeof AdminName - 1);
   
   new iPlayer = cmd_target(id, iArg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF);
   new iGetTime = str_to_num(iTime);
   
   new PlayerIp[18];
   get_user_ip(iPlayer, PlayerIp, sizeof PlayerIp - 1, 1);
   
   if(!iPlayer)
   {
      client_print(id, print_console, "Cannot find player %s", iArg);
   } else {
      new iGetCvar[16];
      get_pcvar_string(iFlagGagTime, iGetCvar, sizeof iGetCvar - 1);
      if(iGetTime > get_pcvar_num(iMaxGagTime))
      {
         if(!(get_user_flags(id) & read_flags(iGetCvar)))
         {
            client_print(id, print_console, "You have no right to gag more than %d minutes", get_pcvar_num(iMaxGagTime));
            return PLUGIN_HANDLED;
         }
      }
      GagPlayer(id, iArg, PlayerIp, iGetTime, iReason, AdminName);
   }
   
   return PLUGIN_HANDLED;
}

public cmdUnGag(id, level, cid)
{
   if(!cmd_access(id, level, cid, 1))
   {
      return PLUGIN_HANDLED;
   }
   
   new PlayerIp[33];
   read_argv(1, PlayerIp, sizeof PlayerIp - 1);
   UnGagPlayer(id, PlayerIp);
   
   return PLUGIN_HANDLED;
}

public cmdCleanTable(id, level, cid)
{
   if(!cmd_access(id, level, cid, 1))
   {
      return PLUGIN_HANDLED;
   }
   
   TruncateTableMenu(id);
   return PLUGIN_HANDLED;
}

public TruncateTableMenu(id)
{
   new iMenu = menu_create("\wAre you sure you want to empty database?", "TruncateTableMenuFunc");
   menu_additem(iMenu, "\rYes", "1", 0);
   menu_additem(iMenu, "\rNo", "2", 0);
   menu_setprop(iMenu, MPROP_EXIT, MEXIT_ALL);
   menu_display(id, iMenu, 0);
}

public TruncateTableMenuFunc(id, iMenu, Item)
{
   if(Item == MENU_EXIT)
   {
      menu_destroy(iMenu);
      return PLUGIN_HANDLED;
   }
   
   new iData[6], iName[64];
   new access, callback;
   
   menu_item_getinfo(iMenu, Item, access, iData, charsmax(iData), iName, sizeof iName - 1, callback);

   new iKey = str_to_num(iData);
   
   switch(iKey)
   {
      case 1:
      {
         #if defined SQL
         new Handle:iTruncate;
         iTruncate = SQL_PrepareQuery(g_iSqlConn, "TRUNCATE TABLE `amx_gag`");
         if(SQL_Execute(iTruncate))
         {
            Gaged(id, "^4The table was cleared ^3successfully^1!");
         } else {
            Gaged(id, "^4There was a problem, the table is not cleared^4!");
         }
         SQL_FreeHandle(iTruncate);
         #else
         if(nvault_prune(iVaultHandle, 0, time())) {
            Gaged(id, "^4The table was cleared ^3successfully^1!");
         }
         else {
            Gaged(id, "^4There was a problem, the table is not cleared^4!");
         }
         #endif
      }
      case 2:
      {
         return PLUGIN_CONTINUE;
      }
   }
   
   menu_destroy(iMenu);
   return PLUGIN_HANDLED;
}

public cmdSayChat(id)
{
   new iGetUserIp[18];
   get_user_ip(id, iGetUserIp, sizeof iGetUserIp - 1, 1);
   CheckGagedPlayer(id, iGetUserIp);
   
   if(iUserGaGed[id])
   {
      return PLUGIN_HANDLED;
   }
   
   return PLUGIN_CONTINUE;
}

public client_PreThink(id)
{
   if(is_user_connected(id))
   {
      if(iUserGaGed[id])
      {
         set_speak(id, SPEAK_MUTED);
      } else {
         set_speak(id, SPEAK_NORMAL);
      }
   }
}

public client_connect(id)
{
   iUserGaGed[id] = false;
}

public client_disconnect(id)
{
   iUserGaGed[id] = false;
}

public cmdGagMenu(id, level, cid)
{
   if(!cmd_access(id, level, cid, 1))
      return PLUGIN_HANDLED;
   
   new iMenu = menu_create("\rGag Menu:", "cmdGagMenuFunc");
   new iPlayers[32], iNum, iTarget;
   new UserName[34], szTempID[10];
   get_players(iPlayers, iNum);
   for(new i; i < iNum; i++)
   {
      iTarget = iPlayers[i];
      get_user_name(iTarget, UserName, sizeof UserName - 1);
      num_to_str(iTarget, szTempID, charsmax(szTempID));
      menu_additem(iMenu, UserName, szTempID, _, menu_makecallback("GagMenuPlayers"));
   }

   menu_display(id, iMenu, 0);
   return PLUGIN_HANDLED;
}

public GagMenuPlayers(iClient, iMenu, Item)
{
   new iAccess, Info[3], iCallback;
   menu_item_getinfo(iMenu, Item, iAccess, Info, sizeof Info - 1, _, _, iCallback);
   
   new iGetID = str_to_num(Info);
   
   if(access(iGetID, ADMIN_IMMUNITY))
   {
      return ITEM_DISABLED;
   }
   
   if(iUserGaGed[iGetID])
   {
      return ITEM_DISABLED;
   }
   
   return ITEM_ENABLED;
}

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

   new iData[6], iName[64];
   new access, callback;
   menu_item_getinfo(iMenu, Item, access, iData, charsmax(iData), iName, charsmax(iName), callback);

   new iTarget = str_to_num(iData);
   get_user_name(iTarget, iCacheUserName, sizeof iCacheUserName - 1);
   get_user_name(id, iCacheAdmName, sizeof iCacheAdmName - 1);
   get_user_ip(iTarget, iCacheUserIp, sizeof iCacheUserIp - 1, 1);
   cmdGagMenuTime(id);
   menu_destroy(iMenu);
   return PLUGIN_HANDLED;
}

public cmdGagMenuTime(id)
{
   new iMenu = menu_create("\wSelect Time?", "cmdGagMenuTimeFunc");
   menu_additem(iMenu, "\y1 minute", "1");
   menu_additem(iMenu, "\y5 minutes", "5");
   menu_additem(iMenu, "\y10 minutes", "10");
   menu_additem(iMenu, "\y15 minutes", "15");
   menu_additem(iMenu, "\y20 minutes", "20");
   menu_additem(iMenu, "\y30 minutes (half hour)", "30");
   menu_additem(iMenu, "\y40 minutes", "40");
   menu_additem(iMenu, "\y50 minutes", "50");
   menu_additem(iMenu, "\y1 hour", "60");
   menu_additem(iMenu, "\y2 hours", "120");
   menu_additem(iMenu, "\y3 hours", "180");
   menu_additem(iMenu, "\y4 hours", "240");
   menu_additem(iMenu, "\y5 hours", "300");
   menu_additem(iMenu, "\y6 hours", "360");
   menu_additem(iMenu, "\y7 hours", "420");
   menu_additem(iMenu, "\y8 hours", "580");
   menu_additem(iMenu, "\y24 hours (1 day)", "1440");
   menu_additem(iMenu, "\y48 hours (2 days)", "2880");
   menu_setprop(iMenu, MPROP_EXIT, MEXIT_ALL);
   menu_display(id, iMenu, 0);
}

public cmdGagMenuTimeFunc(id, iMenu, Item)
{
   if(Item == MENU_EXIT)
   {
      menu_destroy(iMenu);
      return PLUGIN_HANDLED;
   }
   new iData[6];
   new access, callback;
   menu_item_getinfo(iMenu, Item, access, iData, sizeof iData - 1, _, _, callback);
   iTime = str_to_num(iData);
   client_cmd(id, "messagemode amx_gagreason");
   menu_destroy(iMenu);
   return PLUGIN_HANDLED;
}

public cmdGagReason(id, level, cid)
{
   if(!cmd_access(id, level, cid, 1))
      return PLUGIN_HANDLED;
   
   new iReason[64];
   read_argv(1, iReason, sizeof iReason - 1);
   GagPlayer(id, iCacheUserName, iCacheUserIp, iTime, iReason, iCacheAdmName);
   return PLUGIN_HANDLED;
}

stock GagPlayer(id, const iPlayer[], const PlayerIp[], iTime, const iReason[], const iAdminName[])
{
   #if defined SQL
   new Handle:get;
   get = SQL_PrepareQuery(g_iSqlConn, "SELECT `player_ip` FROM `amx_gag` WHERE `player_ip` = ^"%s^"", PlayerIp);
   
   new ExpireDate = time() + (iTime * 60);
   
   if(SQL_Execute(get))
   {
      if(SQL_NumResults(get) > 0)
      {
         SQL_FreeHandle(get);
         client_print(id, print_console, "User ^"%s^" is already gaged", iPlayer);
      } else {
         new Handle:set;
         set = SQL_PrepareQuery(g_iSqlConn, "INSERT INTO `amx_gag` VALUES(NULL, ^"%s^", '%s', '%d', ^"%s^", ^"%s^")", iPlayer, PlayerIp, ExpireDate, iReason, iAdminName);
         SQL_Execute(set);
         SQL_FreeHandle(set);
         SQL_FreeHandle(get);
         client_print(id, print_console, "Player is gaged successfully!");
         
         switch(get_cvar_num("amx_show_activity"))
         {
            case 1:
            {
               set_hudmessage(0, 255, 0, 0.05, 0.30, 0, 6.0, 22.0, 0.1, 0.2, 22);
               ShowSyncHudMsg(0, MsgHudSync, "%s has been gaged. ^nReason: %s", iPlayer, iReason);
            }
            case 2:
            {
               set_hudmessage(0, 255, 0, 0.05, 0.30, 0, 6.0, 22.0, 0.1, 0.2, 22);
               ShowSyncHudMsg(0, MsgHudSync, "%s has been gaged. ^nReason: %s ^nBy admin %s", iPlayer, iReason, iAdminName);
            }
         }
      }
   } else {
      SQL_FreeHandle(get);
   }
   #else
   new ExpireData = time() + (iTime * 60);
   new iMinutes = iTime * 60
   
   new vaultkey[40], vaultdata[512];
   formatex(vaultkey, sizeof vaultkey-1, "[user]%s", PlayerIp);
   new szIp[32];
   if(!nvault_get(iVaultHandle, vaultkey, szIp, sizeof szIp-1)) {
      formatex(vaultdata, sizeof vaultdata-1, "^"%s^"#^"%s^"#%i#^"%s^"", iPlayer, iReason, ExpireData, iAdminName);
      nvault_set(iVaultHandle, vaultkey, vaultdata);
      client_print(id, print_console, "Player is gaged successfully!");
      switch(get_cvar_num("amx_show_activity")) {
         case 1:
         {
            set_hudmessage(0, 255, 0, 0.05, 0.30, 0, 6.0, 12.0, 0.1, 0.2, 12);
            ShowSyncHudMsg(0, MsgHudSync, "%s has been gaged. ^nReason: %s", iPlayer, iReason);
            ChatColor(0, "!g[ZP] !yPlayer !g%s !yhas been gaged. !yReason: !g%s.", iPlayer, iReason)
         }
         case 2:
         {
            set_hudmessage(0, 255, 0, 0.05, 0.30, 0, 6.0, 12.0, 0.1, 0.2, 12);
            ShowSyncHudMsg(0, MsgHudSync, "%s has been gaged for %s minutes. ^nReason: %s ^nBy admin %s", iPlayer, iMinutes, iReason, iAdminName);
            ChatColor(0, "!g[ZP] !yPlayer !g%s !yhas been gaged by Admin !g%s !yfor !g%s !yminutes. Reason: !g%s.", iPlayer, iAdminName, iMinutes, iReason)
         }
      }
   }
   else {
      client_print(id, print_console, "User ^"%s^" is already gaged", iPlayer);
   }
   #endif
}

stock UnGagPlayer(id, const PlayerIp[])
{
   #if defined SQL
   new Handle:get;
   get = SQL_PrepareQuery(g_iSqlConn, "SELECT * FROM `amx_gag` WHERE `player_ip`= ^"%s^"", PlayerIp);
   
   if(SQL_Execute(get))
   {
      if(SQL_NumResults(get) > 0)
      {
         new iGetId = SQL_ReadResult(get, 0);
         new Handle:del;
         del = SQL_PrepareQuery(g_iSqlConn, "DELETE FROM `amx_gag` WHERE `id` = '%d'", iGetId);
         SQL_Execute(del);
         client_print(id, print_console, "Gag has been removed successfully!");
         SQL_FreeHandle(del);
         SQL_FreeHandle(get);
      } else {
         SQL_FreeHandle(get);
         client_print(id, print_console, "No user with that ipaddres in the database!");
      }
   } else {
      SQL_FreeHandle(get);
   }
   #else
   new vaultkey[40]
   formatex(vaultkey, sizeof vaultkey-1, "[user]%s", PlayerIp);
   new szIp[32];
   if(!nvault_get(iVaultHandle, vaultkey, szIp, sizeof szIp-1)) {
      client_print(id, print_console, "No user with that ipaddres in the database!");
   }
   else {
      nvault_remove(iVaultHandle, vaultkey);
      client_print(id, print_console, "Gag has been removed successfully!");
   }
   #endif
}

stock CheckGagedPlayer(id, const iPlayerIP[])
{
   #if defined SQL
   new Handle:get;
   get = SQL_PrepareQuery(g_iSqlConn, "SELECT * FROM `amx_gag` WHERE `player_ip` = ^"%s^"", iPlayerIP);
   
   if(SQL_Execute(get))
   {
      if(SQL_NumResults(get) > 0)
      {
         new iGetId = SQL_ReadResult(get, 0);
         new ExpireDate[11]; SQL_ReadResult(get, 3, ExpireDate, sizeof ExpireDate - 1);
         new iGetReason[129]; SQL_ReadResult(get, 4, iGetReason, sizeof iGetReason - 1);
         if(strlen(ExpireDate) > 0)
         {
            if(time() < str_to_num(ExpireDate))
            {
               new iGagChat[512], iMonth, iDay, iYear, iHour, iMinute, iSecond;
               new iUnixTime = str_to_num(ExpireDate);
               UnixToTime(iUnixTime , iYear , iMonth , iDay , iHour , iMinute , iSecond, UT_TIMEZONE_EET);
               formatex(iGagChat, sizeof iGagChat - 1, "^4You are gaged^1! Your gag will expire on: ^3%02d/%02d/%02d - %02d:%02d:%02d ^1: Reason: ^4%s", iDay, iMonth, iYear, iHour, iMinute , iSecond, iGetReason);
               Gaged(id, "%s", iGagChat);
               iUserGaGed[id] = true;
               SQL_FreeHandle(get);
            } else {
               new Handle:del;
               del = SQL_PrepareQuery(g_iSqlConn, "DELETE FROM `amx_gag` WHERE `id` = '%d'", iGetId);
               iUserGaGed[id] = false;
               SQL_Execute(del);
               SQL_FreeHandle(del);
               SQL_FreeHandle(get);
            }
         }
      } else {
         iUserGaGed[id] = false;
      }
   } else {
      SQL_FreeHandle(get);
   }
   #else
   new vaultkey[40], vaultdata[512];
   formatex(vaultkey, sizeof vaultkey-1, "[user]%s", iPlayerIP);

   if(!nvault_get(iVaultHandle, vaultkey, vaultdata, sizeof vaultdata-1)) {
      iUserGaGed[id] = false;
   }
   else {
      new szPlayerName[32], szReason[64], szExpireDate[32], szAdminName[32];
      replace_all(vaultdata, sizeof vaultdata-1, "#", " ")
      parse(vaultdata, szPlayerName, sizeof szPlayerName-1, szReason, sizeof szReason-1, szExpireDate, sizeof szExpireDate-1, szAdminName, sizeof szAdminName-1)
      if(time() < str_to_num(szExpireDate) || str_to_num(szExpireDate) == 0) {
         new iGagChat[512], iMonth, iDay, iYear, iHour, iMinute, iSecond;
         new iUnixTime = str_to_num(szExpireDate);
         UnixToTime(iUnixTime , iYear , iMonth , iDay , iHour , iMinute , iSecond, UT_TIMEZONE_EET);
         formatex(iGagChat, sizeof iGagChat - 1, "^4You are gaged^1! Your gag will expire on: ^3%02d/%02d/%02d - %02d:%02d:%02d ^1: Reason: ^4%s", iDay, iMonth, iYear, iHour, iMinute , iSecond, szReason);
         Gaged(id, "%s", iGagChat);
         iUserGaGed[id] = true;
      }
      else {
         nvault_remove(iVaultHandle, vaultkey)
         iUserGaGed[id] = false;
      }
   }
   #endif
}

stock Gaged(const id, const input[], any:...)
{
   new count = 1, players[32];
   static msg[191];
   vformat(msg, 190, input, 3);
   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, SayText, _, players[i]) ;
            write_byte(players[i]);
            write_string(msg);
            message_end();
         }
      }
   }
}


stock ChatColor(const id, const input[], any:...)
{
   new count = 1, players[32]
   static msg[191]
   vformat(msg, 190, input, 3)
   
   replace_all(msg, 190, "!g", "^4") // Green Color
   replace_all(msg, 190, "!y", "^1") // Default Color
   replace_all(msg, 190, "!t", "^3") // Team Color
   replace_all(msg, 190, "!w", "^0") // Team2 Color
   
   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(msg);
              message_end();
                   }
               }
        }
}

here is my gag manager
Код: Выделить всё
#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <colorchat>

#define ACCESS    ADMIN_SLAY
#define WORDS   999
#define SWEAR_GAGMINUTES 3
#define SHOW
#define No_Gag ADMIN_LEVEL_D

new const g_FileName[] = "automute-words.ini";

new
bool:g_Gaged[ 33 ], g_GagTime[ 33 ],
bool:g_SwearGag[ 33 ], bool:g_CmdGag[ 33 ],
bool:g_NameChanged[33];

new g_reason[ 32 ], g_admin[ 32 ], g_name[ 33 ][ 32 ];

new g_WordsFile[ 128 ];
new g_Words[ WORDS ][ 32 ], g_Count, g_Len;
new point
new g_vault

public plugin_init()
{
    register_plugin("ChatBan-Manager", "1.0", "ExoTiQ")
   
    register_concmd( "amx_gag", "gag_cmd", ACCESS,"- <name> <min> <prichina> " );
    register_concmd( "amx_ungag", "ungag_cmd", ACCESS, "- <nume>" );
    register_clcmd( "say", "check" );
    register_clcmd( "say_team", "check" );
    g_vault = nvault_open("ListaDisconnect");
    point = get_cvar_pointer( "amx_show_activity" );
   
}

public plugin_cfg()
{
    static dir[ 999 ];
    get_localinfo( "amxx_configsdir", dir, 998 );
    formatex( g_WordsFile , 127 , "%s/%s" , dir, g_FileName );
   
    if( !file_exists( g_WordsFile ) )
        write_file( g_WordsFile, "[Gag Words]", -1 );
   
    new Len;
   
    while( g_Count < WORDS && read_file( g_WordsFile, g_Count ,g_Words[ g_Count ][ 1 ], 30, Len ) )
    {
        g_Words[ g_Count ][ 0 ] = Len;
        g_Count++;
    }
}

public client_connect(id)
{
    LoadMutedPlayers(id)
}

public gag_cmd( id, level, cid )
{
    if( !cmd_access( id, level, cid, 4 ) )
        return PLUGIN_HANDLED;   
   
    new arg[ 32 ], arg2[ 6 ], reason[ 32 ];
    new name[ 32 ], namet[ 32 ];
    new minutes;
   
    read_argv(1, arg, 31)
   
    new player = cmd_target(id, arg, 9)
   
    if (!player)
        return PLUGIN_HANDLED
   
    read_argv( 1, arg, sizeof arg - 1 );
    read_argv( 2, arg2, sizeof arg2 - 1 );
    read_argv( 3, reason, sizeof reason - 1 );
   
    get_user_name( id, name, 31 );
   
    copy( g_admin, 31, name );
    copy( g_reason, 31, reason );
    remove_quotes( reason );
   
    minutes = str_to_num( arg2 );
   
    new target = cmd_target( id, arg, 10 );
    if( !target)
        return PLUGIN_HANDLED;
   
    if( g_Gaged[ target ] )
    {
        console_print( id, "The player is chat banned!" );
        return PLUGIN_HANDLED;
    }
   
    get_user_name( target, namet, 31 );
    copy( g_name[ target ], 31, namet );
   
    g_CmdGag[ target ] = true;
    g_Gaged[target] = true;
    g_GagTime[ target ] = minutes;
   
    ColorChat( 0, GREY, "^4[^3Maina City^4] ^4%s:^1 gagged ^4Player: ^3%s ^1for ^4 %d min. ^4Reason: ^3%s",get_pcvar_num( point ) == 2 ? name : "", namet, minutes, reason );
   
   
    set_task( 60.0, "count", target + 123, _, _, "b" );
   
    return PLUGIN_HANDLED;
}

public ungag_cmd( id,level, cid )
{
    if( !cmd_access( id, level, cid, 2 ) )
        return PLUGIN_HANDLED;
   
    new arg[ 32 ], reason[ 32 ], name[ 32 ];
    read_argv( 1, arg, sizeof arg - 1 );
    read_argv( 2, reason, sizeof reason - 1 );
    get_user_name( id, name, sizeof name - 1 );
    remove_quotes( reason );
   
    new target = cmd_target( id, arg, 11 );
    if( !target )
        return PLUGIN_HANDLED;
    new namet[ 32 ];
    get_user_name( target, namet, sizeof namet - 1 );
   
    if( !g_Gaged[ target ] )
    {
        console_print( id, "Player %s is chat banned.", namet );
        return PLUGIN_HANDLED;
    }
   
    g_Gaged[ target ] = false;
    g_SwearGag[ target ] = false;
   
    if( g_NameChanged[ target ] )
        client_cmd( target, "name ^"%s^"", g_name[ target ] );
   
    g_NameChanged[ target ] = false;
   
    remove_task( target + 123 );
   
    ColorChat( 0, GREY, "^4[^3Maina City^4]^3Admin ^4%s ^1removed gag to^4[^3Player: %s^4]",get_pcvar_num( point ) == 2 ? name : "", namet );
   
    return PLUGIN_HANDLED;
}

public count( task )
{
    new index = task - 123;
    if( !is_user_connected( index ) )
        return 0;
   
    g_GagTime[index] -= 1;
   
    if( g_GagTime[ index ] <= 0 )
    {
        remove_task( index + 123 );
        new name[ 32 ]
        get_user_name( index, name, 31 );
        ColorChat( 0, GREY, "^4[^3Maina City^4]^1Player:^4 %s ^3is no longer ^4gagged! ",name );
        g_Gaged[ index ] = false;
       
        if( g_NameChanged[ index ] )
            client_cmd( index, "name ^"%s^"", g_name[ index ] );
       
        return 0;
    }
   
    return 1;
}

public check( id )
{
    new said[ 192 ];
    read_args( said, sizeof said - 1 );
   
    if( !strlen( said ) )
        return PLUGIN_CONTINUE;
   
    if( g_Gaged[ id ] )
    {
        if( g_CmdGag[ id ] )
        {
            ColorChat( id, GREY, "^4[^3Maina City^4] ^4[^3You have been gagged by ^3%s ^4] ", g_admin);
            ColorChat( id, GREY, "^4[^3Maina City^4] ^4[^3Time before the ^3ungag ^4%d ^3minutes ^4] " , g_GagTime[ id ], g_GagTime[ id ] == 1 ? "" : "s" );
            ColorChat( id, GREY, "^4[^3Maina City^4] ^4[^4Reason:^3%s ^4] ", g_reason );
           
            return PLUGIN_HANDLED;
           
            } else if( g_SwearGag[ id ] ) {
            ColorChat( id, GREY, "^4[^3Maina City^4]^4[^3You have been chat banned for ^1(^4Reclama^1,^3Obida^1) ")
            ColorChat( id, GREY, "^4[^3Maina City^4]^4[^1Time before ^4ungag ban ^3%d ^4minutes ^4] " , g_GagTime[ id ], g_GagTime[ id ] == 1 ? "" : "s" );
            return PLUGIN_HANDLED;
        }
        } else {
       
        new bool:g_Sweared, i, pos;
       
        for( i = 0; i < g_Count; ++i )
        {
            if( ( pos = containi( said, g_Words[ i ][ 1 ] ) ) != -1 )
            {
                g_Len = g_Words[ i ][ 0 ];
               
                while( g_Len-- )
                    said[ pos++ ] = '*';
               
                g_Sweared = true;
                continue;
            }
        }
       
        if( g_Sweared )
        {
            new cmd[ 32 ], name[ 32 ];
           
            get_user_name( id, name, sizeof name - 1 );
            read_argv( 0, cmd, sizeof cmd - 1 );
            copy( g_name[ id ], 31, name );
           
            engclient_cmd( id, cmd, said );
            g_Gaged[ id ] = true;
            g_CmdGag[ id ] = false;
           
           
           
            g_SwearGag[ id ] = true;
            g_GagTime[ id ] = SWEAR_GAGMINUTES;
           
            ColorChat( 0, GREY, "^4[^3Maina City^4]^3Protection system gaged ^4%s ^1for ^3 3 ^4minutes ^1/ ^4Reklama^1,^3Obida",name );
           
           
            set_task( 60.0, "count",id+123,_,_,"b");
           
            return PLUGIN_HANDLED;
        }
    }
   
    return PLUGIN_CONTINUE;
}

public client_disconnect(id)
{
    if(g_Gaged[id])
    {
        new Nick[32],Authid[35],userip[32]
        get_user_name(id,Nick,31)
        get_user_ip(id,userip,31);
        get_user_authid(id,Authid,34)
        ColorChat(0, GREY, "^4[^3Maina City^4]^1User ^3 %s ^4[^3IP: ^4%s ^4] ^1Has ^4left the server.",Nick,userip)       
        SaveMutedPlayers(id);   
        remove_task( id );
   g_Gaged[id] = false;
       
    }
}

public SaveMutedPlayers(id)
{
   
    new name[32], userip[32];
    get_user_name(id,name,31);
    get_user_ip(id,userip,31);
    new vaultkey[64],vaultdata[256] 
    format(vaultkey,63,"%s[IP: %s]-Muted",name,userip)
    format(vaultdata,255,"%i#%i#",g_Gaged[id],g_SwearGag[id])
    nvault_set(g_vault,vaultkey,vaultdata)
    return PLUGIN_CONTINUE


public LoadMutedPlayers(id)
{
    new name[32], userip[32];
    get_user_name(id,name,31);
    get_user_ip(id,userip,31);
    new vaultkey[64],vaultdata[256]
    format(vaultkey,63,"%s[IP: %s]-Muted",name,userip)
    format(vaultdata,255,"%i#%i#",g_Gaged[id],g_SwearGag[id])
    nvault_get(g_vault,vaultkey,vaultdata,255)
    replace_all(vaultdata, 255, "#", " ")
    return PLUGIN_CONTINUE


stock culoare_scris(const id, const input[], any:...)
{
    new count = 1, players[32]
    static msg[191]
    vformat(msg, 190, input, 3)
   
    replace_all(msg, 190, "!verde", "^4")
    replace_all(msg, 190, "!normal", "^1")
    replace_all(msg, 190, "!team", "^3")
   
    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(msg);
                message_end();
            }
        }
    } 
}
Аватара пользователя
VenomIvanof
 
Сообщения: 66
Зарегистрирован: 02 апр 2016, 13:26
Благодарил (а): 17 раз.
Поблагодарили: 1 раз.
Языки программирования: Counter-Strike 1.6

Re: Help edit gag Manager

Сообщение RevCrew » 03 апр 2016, 14:17

VenomIvanof, this is very unsafe plugin.

Код: Выделить всё
public client_disconnect(id

    if(
g_Gaged[id]) 
    {
        new 
Nick[32],Authid[35],userip[32// You don't use Authid variable
        // For userip use massive of 22 cells because you get ip without port
 
Аватара пользователя
RevCrew
Скриптер
 
Сообщения: 1648
Зарегистрирован: 15 июл 2013, 20:45
Благодарил (а): 273 раз.
Поблагодарили: 357 раз.
Языки программирования: Unkown

Re: Help edit gag Manager

Сообщение VenomIvanof » 03 апр 2016, 14:20

RevCrew писал(а):VenomIvanof, this is very unsafe plugin.

Код: Выделить всё

public client_disconnect
(id) 
{ 
    if
(g_Gaged[id]) 
    
{
        new Nick[32],Authid[35],userip[32] // You don't use Authid variable
        // For userip use massive of 22 cells because you get ip without port


how can be fixed? or what is the better way?
Аватара пользователя
VenomIvanof
 
Сообщения: 66
Зарегистрирован: 02 апр 2016, 13:26
Благодарил (а): 17 раз.
Поблагодарили: 1 раз.
Языки программирования: Counter-Strike 1.6

Re: Help edit gag Manager

Сообщение RevCrew » 03 апр 2016, 14:32

Код: Выделить всё


#define WORDS   999
new g_Words[ WORDS ][ 32 ]
read_file( g_WordsFile, g_Count ,g_Words[ g_Count ][ 1 ], 30, Len )
 


Use CellArray and f* function (fopen, fgets fclose) because read_file is unsafe

Добавлено спустя 3 минуты 10 секунд:
VenomIvanof, maybe you delete Authid[35] ?)

Why you get ip with the port? You can get only IP, without port, because the port changes.
For example
Код: Выделить всё
 new userip[22]
get_user_ip(id, userip, charsmax(userip), .without_port=1


Добавлено спустя 3 минуты 4 секунды:
VenomIvanof, also, you can check gagtime without this
Код: Выделить всё
 set_task( 60.0, "count", target + 123, _, _, "b" );

Because you can check this when player connect

Добавлено спустя 1 минуту 2 секунды:
Код: Выделить всё
public gag_cmdidlevelcid )
{
    if( !
cmd_accessidlevelcid) )
        return 
PLUGIN_HANDLED;   
    
    new 
arg32 ], arg2], reason32 ];
    new 
name32 ], namet32 ];
    new 
minutes;
    
    
read_argv(1arg31)
    
    new 
player cmd_target(idarg9)
    
    if (!
player
        return 
PLUGIN_HANDLED
    
    read_argv
1argsizeof arg );
 

Why you use read_argv(1, arg .. ) two times?
Аватара пользователя
RevCrew
Скриптер
 
Сообщения: 1648
Зарегистрирован: 15 июл 2013, 20:45
Благодарил (а): 273 раз.
Поблагодарили: 357 раз.
Языки программирования: Unkown

Re: Help edit gag Manager

Сообщение VenomIvanof » 03 апр 2016, 14:44

RevCrew писал(а):
Код: Выделить всё


#define WORDS   999
new g_Words[ WORDS ][ 32 ]
read_file( g_WordsFile, g_Count ,g_Words[ g_Count ][ 1 ], 30, Len )


Use CellArray and f* function (fopen, fgets fclose) because read_file is unsafe

Добавлено спустя 3 минуты 10 секунд:
VenomIvanof, maybe you delete Authid[35] ?)

Why you get ip with the port? You can get only IP, without port, because the port changes.
For example
Код: Выделить всё
 new userip[22]
get_user_ip(id, userip, charsmax(userip), .without_port=1)


Добавлено спустя 3 минуты 4 секунды:
VenomIvanof, also, you can check gagtime without this
Код: Выделить всё
 set_task( 60.0, "count", target + 123, _, _, "b" ); 

Because you can check this when player connect

Добавлено спустя 1 минуту 2 секунды:
Код: Выделить всё

public gag_cmd
( id, level, cid )
{
    if( !cmd_access( id, level, cid, 4 ) )
        return PLUGIN_HANDLED;   
    
    new arg
[ 32 ], arg2[ 6 ], reason[ 32 ];
    new name[ 32 ], namet[ 32 ];
    new minutes;
    
    read_argv
(1, arg, 31)
    
    new player 
= cmd_target(id, arg, 9)
    
    if 
(!player) 
        return PLUGIN_HANDLED
    
    read_argv
( 1, arg, sizeof arg - 1 );

Why you use read_argv(1, arg .. ) two times?



i am not so good at scripting/pawn ... would you help me to fix this problems?
Аватара пользователя
VenomIvanof
 
Сообщения: 66
Зарегистрирован: 02 апр 2016, 13:26
Благодарил (а): 17 раз.
Поблагодарили: 1 раз.
Языки программирования: Counter-Strike 1.6

Re: Help edit gag Manager

Сообщение Fedcomp » 03 апр 2016, 15:51

VenomIvanof писал(а):i am not so good at scripting/pawn ... would you help me to fix this problems?

I am sorry but probably you have to. Either you ask HOW to make it and do it yourself ... or ask someone to fix it for money.
Не помогаю в ЛС - есть форум.
Плагины тоже не пишу, на форуме достаточно хороших скриптеров.


"я ставлю зависимости потому что мне приятно" - subb98 @ 2017
Аватара пользователя
Fedcomp
Администратор
 
Сообщения: 4936
Зарегистрирован: 28 авг 2009, 20:47
Благодарил (а): 813 раз.
Поблагодарили: 1317 раз.
Языки программирования: =>
pawn / php / python / ruby
javascript / rust

Re: Help edit gag Manager

Сообщение VenomIvanof » 03 апр 2016, 16:15

Fedcomp писал(а):
VenomIvanof писал(а):i am not so good at scripting/pawn ... would you help me to fix this problems?

I am sorry but probably you have to. Either you ask HOW to make it and do it yourself ... or ask someone to fix it for money.

ок thx Lock the post!
Аватара пользователя
VenomIvanof
 
Сообщения: 66
Зарегистрирован: 02 апр 2016, 13:26
Благодарил (а): 17 раз.
Поблагодарили: 1 раз.
Языки программирования: Counter-Strike 1.6


Вернуться в Scripting

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 4