SergiuAndreiM

block_chat

Jun 3rd, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.58 KB | None | 0 0
  1. ACMD(do_block_chat)
  2. {
  3.     // GM? ???? block_chat_privilege? ?? ??? ??? ?? ??
  4.     if (ch && (ch->GetGMLevel() < GM_HIGH_WIZARD && ch->GetQuestFlag("chat_privilege.block") <= 0))
  5.     {
  6.         ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("?? ???? ????"));
  7.         return;
  8.     }
  9.  
  10.     char arg1[256];
  11.     argument = one_argument(argument, arg1, sizeof(arg1));
  12.  
  13.     if (!*arg1)
  14.     {
  15.         if (ch)
  16.             ch->ChatPacket(CHAT_TYPE_INFO, "Usage: block_chat <name> <time> (0 to off)");
  17.  
  18.         return;
  19.     }
  20.  
  21.     const char* name = arg1;
  22.     long lBlockDuration = parse_time_str(argument);
  23.  
  24.     if (lBlockDuration < 0)
  25.     {
  26.         if (ch)
  27.         {
  28.             ch->ChatPacket(CHAT_TYPE_INFO, "??? ??? ?????. h, m, s? ??? ??? ????.");
  29.             ch->ChatPacket(CHAT_TYPE_INFO, "?) 10s, 10m, 1m 30s");
  30.         }
  31.         return;
  32.     }
  33.  
  34.     sys_log(0, "BLOCK CHAT %s %d", name, lBlockDuration);
  35.  
  36.     LPCHARACTER tch = CHARACTER_MANAGER::instance().FindPC(name);
  37.  
  38.     if (!tch)
  39.     {
  40.         CCI * pkCCI = P2P_MANAGER::instance().Find(name);
  41.  
  42.         if (pkCCI)
  43.         {
  44.             TPacketGGBlockChat p;
  45.  
  46.             p.bHeader = HEADER_GG_BLOCK_CHAT;
  47.             strlcpy(p.szName, name, sizeof(p.szName));
  48.             p.lBlockDuration = lBlockDuration;
  49.             P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGBlockChat));
  50.         }
  51.         else
  52.         {
  53.             TPacketBlockChat p;
  54.  
  55.             strlcpy(p.szName, name, sizeof(p.szName));
  56.             p.lDuration = lBlockDuration;
  57.             db_clientdesc->DBPacket(HEADER_GD_BLOCK_CHAT, ch ? ch->GetDesc()->GetHandle() : 0, &p, sizeof(p));
  58.         }
  59.  
  60.         if (ch)
  61.             ch->ChatPacket(CHAT_TYPE_INFO, "Chat block requested.");
  62.  
  63.         return;
  64.     }
  65.  
  66.     if (tch && ch != tch)
  67.         tch->AddAffect(AFFECT_BLOCK_CHAT, POINT_NONE, 0, AFF_NONE, lBlockDuration, 0, true);
  68. }
Advertisement
Add Comment
Please, Sign In to add comment