Търся плъгин за гаг

В този раздел можете да подавате всякакви заявки за намиране, изработка или преработка на плъгини/модове.
Аватар
Pet(5)ko
Извън линия
Потребител
Потребител
Мнения: 134
Регистриран на: 09 Фев 2017, 19:53
Местоположение: Варна
Се отблагодари: 12 пъти
Получена благодарност: 2 пъти
Обратна връзка:

Търся плъгин за гаг

Мнение от Pet(5)ko » 09 Фев 2017, 23:09

Здравейте,търся гаг плъгин... Изпробвах този на костов и доста други... Един тръгна и след 3-4 дни сега още се води,че работи,но всъщност не гагва през конзолата... амх_гаг и ми изкарва да въведа име и минути и като го напиша нищо не става...
Последно промяна от OciXCrom на 10 Фев 2017, 16:39, променено общо 1 път.
Причина: Чети какво пише горе!!!

Аватар
stop cry!
Извън линия
Потребител
Потребител
Мнения: 382
Регистриран на: 07 Яну 2017, 02:18
Се отблагодари: 2 пъти
Получена благодарност: 1 път

Re: Търся плъгин за гаг

Мнение от stop cry! » 09 Фев 2017, 23:22

МНЕНИЕТО Е СКРИТО ОТ СТРАНА НА МОДЕРАТОР! ЦЪКНИ ВЪРХУ ЛЕНТАТА ЗА ДА ГО ПРЕГЛЕДАШ.
Последно промяна от OciXCrom на 10 Фев 2017, 16:40, променено общо 1 път.
Причина: Прочети правилата на форума.

Аватар
JustInCase
Извън линия
Потребител
Потребител
Мнения: 582
Регистриран на: 14 Окт 2016, 23:31
Се отблагодари: 4 пъти
Получена благодарност: 15 пъти

Re: Търся плъгин за гаг

Мнение от JustInCase » 10 Фев 2017, 10:39

Не ти препоръчвам да ползваш плъгини, които не си компилирал локално. Ето.

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

//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_KICK, "<name> <time> [reason]");
   register_concmd("amx_ungag", "cmdUnGag", ADMIN_KICK, "<ip>");
   register_concmd("amx_gagmenu", "cmdGagMenu", ADMIN_KICK);
   register_concmd("amx_gagreason", "cmdGagReason", ADMIN_KICK);
   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 minutes?", "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_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, 12.0, 0.1, 0.2, 12);
               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, 12.0, 0.1, 0.2, 12);
               ShowSyncHudMsg(0, MsgHudSync, "%s has been gaged. ^nReason: %s ^nBy %s", iPlayer, iReason, iAdminName);
            }
         }
      }
   } else {
      SQL_FreeHandle(get);
   }
   #else
   new ExpireData = time() + (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);
         }
         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. ^nReason: %s ^nBy admin %s", iPlayer, iReason, iAdminName);
         }
      }
   }
   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);
         Gaged(id, "Player Name: %s | Reason %s | Expire Date: %s | Admin Name: %s", szPlayerName, szReason, szExpireDate, szAdminName);
         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();
         }
      }
   }
}
  
ПС: За да го компилираш ще ти трябва библиотеката unixtime.inc.
MANSION - HNS : 45.144.155.99:27026
ONLINE

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

Обратно към “Заявки за плъгини”

Кой е на линия

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