> > > > >

Модифицировать Voices Management

Сообщения
75
Рейтинг
7
#1
Подскажите как в этот плагин добавить время на информацию?

Код:
// Required admin access level
#define ADMIN_VOICE   ADMIN_CHAT
 
// Delay before a connected player see the text announce
#define ANNOUNCE_TASK_DELAY 30.0
 
// Comment this out if you don't want that a "no sound" player can hear admins using +adminvoice
// All other player settings are respected whatever this is commented or not.
// #define SUPER_ADMIN_PRIORITY
 
/* ** END OF EDITABLE ** */
 
/*    Changelog
*
* v1.1.0 (10/23/13)
* -cleaned up code
*
* v1.0.2 (04/19/08)
* -few code corrections
* -updated player spawn detection
* -added HLTV & BOT checks
*
* v1.0.1 (03/31/08)
* -added colored chat
* -added chat command /vm that display <span class="searchlite">voices</span> settings
* -inform new players about /vm command
* -display adminlisten status when toggle_adminlisten command is used
* -added support for amx_show_activity cvar on amx_(un)mute command
*
* v1.0.0 (03/26/08)
* First release
*
*/
 
/*
Flags :
 1 : hear dead terrorists
 2 : hear alive terrorists
 4 : hear dead cts
 8 : hear alive cts
16 : hear specs
*/
 
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
 
#pragma semicolon 1
 
#define VERSION "1.1.alpha"
 
#define cm(%0)   ( sizeof(%0) - 1 )
 
#define MaskPlayerVoice(%0)   ( 1<<((%0-1) & 31) )
 
enum _:mStates
{
   DEAD_T,
   ALIVE_T,
   DEAD_CT,
   ALIVE_CT,
   SPEC
}
 
enum _:mStatesFlags ( <<= 1 )
{
   FL_DEAD_T = 1,
   FL_ALIVE_T,
   FL_DEAD_CT,
   FL_ALIVE_CT,
   FL_SPEC
}
 
const MAX_PLAYERS = 32;
 
const m_iTeam = 114;
const TEAM_T = 1;
const TEAM_CT = 2;
 
new g_bHasVoicesOn[33 char];
new g_bitBannedClients[33];
#define CanPlayerHearPlayer(%0,%1)   ( ~g_bitBannedClients[%0] & MaskPlayerVoice(%1) )
 
new g_iAdminVoice;
new g_bAdmin[33 char];
new g_bInterAdminVoice[33 char];
new g_bAdminListen[33 char];
 
new g_bMuted[33 char];
new g_szClientsIp[MAX_PLAYERS+1][22];
new Trie:g_tMutedPlayersIps;
 
new g_iMaxPlayers;
new g_pcvarVoicesRules[mStates];
new g_amx_show_activity;
 
public plugin_init()
{
   register_plugin("<span class="searchlite">Voices</span> Management", VERSION, "ConnorMcLeod");
   register_dictionary("voicesmanagement.txt");
   register_dictionary("common.txt");
 
   g_pcvarVoicesRules[DEAD_T] = register_cvar("amx_vm_dead_t", "abcde");
   g_pcvarVoicesRules[ALIVE_T] = register_cvar("amx_vm_alive_t", "bd");
   g_pcvarVoicesRules[DEAD_CT] = register_cvar("amx_vm_dead_ct", "abcde");
   g_pcvarVoicesRules[ALIVE_CT] = register_cvar("amx_vm_alive_ct", "bd");
   g_pcvarVoicesRules[SPEC] = register_cvar("amx_vm_spec", "abcde");
 
   register_forward(FM_Voice_SetClientListening, "OnVoice_SetClientListening");
 
   register_clcmd("VModEnable", "ClCmd_VModEnable");
   register_clcmd("vban", "ClCmd_vban");
 
   register_clcmd("+adminvoice", "AdminCommand_VoiceOn");
   register_clcmd("-adminvoice", "AdminCommand_VoiceOff");
 
   register_clcmd("+interadminvoice", "AdminCommand_InterAdminOn");
   register_clcmd("-interadminvoice", "AdminCommand_InterAdminOff");
 
   register_clcmd("+adminlisten", "AdminCommand_ListenOn");
   register_clcmd("-adminlisten", "AdminCommand_ListenOff");
   register_clcmd("toggle_adminlisten", "AdminCommand_ListenToggle");
 
   register_concmd("amx_mute", "AdminCommand_Mute", ADMIN_VOICE, "<name/#userid>");
   register_concmd("amx_unmute", "AdminCommand_UnMute", ADMIN_VOICE, "<name/#userid>");
 
   // register_clcmd("say /vm", "ClCmd_SayStatus");
   // register_clcmd("say_team /vm", "ClCmd_SayStatus");
}
 
public plugin_cfg()
{
   g_iMaxPlayers = get_maxplayers();
   g_tMutedPlayersIps = TrieCreate();
   g_amx_show_activity = get_cvar_pointer("amx_show_activity");
   if( g_amx_show_activity )
   {
      g_amx_show_activity = register_cvar("amx_show_activity", "2");
   }
}
 
// public ClCmd_SayStatus(id)
// {
   // new iDeads = get_pcvar_num(g_pcvarDeadsHear),
      // iAlives = get_pcvar_num(g_pcvarAlivesHear);
 
   // new szDeadsStatus[18], szAlivesStatus[19];
 
   // switch( iAlives )
   // {
      // case 0:szAlivesStatus = "VM_ALIVES_TEAMATES";
      // case 1:szAlivesStatus = "VM_ALIVES";
      // case 2:szAlivesStatus = "VM_ALL";
   // }
 
   // switch( iDeads )
   // {
      // case 0:szDeadsStatus = "VM_DEADS_TEAMATES";
      // case 1:szDeadsStatus = "VM_DEADS";
      // case 2:szDeadsStatus = "VM_ALL";
   // }
 
   // client_print_color(id, id, "%L", id, "VM_ALIVES_STATUS", id, szAlivesStatus);
   // client_print_color(id, id, "%L", id, "VM_DEADS_STATUS", id, szDeadsStatus);
// }
 
// public taskAnnounce(id)
// {
   // if( is_user_connected(id) )
   // {
      // client_print_color(id, id, "%L", id, "VM_ANNOUCE");
   // }
// }
 
public client_authorized(id)
{
   g_bAdmin{ id } = bool:(get_user_flags(id) & ADMIN_VOICE);
}
 
public client_putinserver(id)
{
   g_bAdminListen{ id } = false;
   g_bInterAdminVoice{ id } = false;
 
   if(is_user_bot(id) || is_user_hltv(id))
      return;
 
   static szIp[22];
   get_user_ip(id, szIp, cm(szIp));
   g_szClientsIp[id] = szIp;
 
   if( TrieKeyExists(g_tMutedPlayersIps, szIp) )
   {
      g_bMuted{ id } = true;
      TrieDeleteKey(g_tMutedPlayersIps, szIp);
   }
 
   // set_task(ANNOUNCE_TASK_DELAY, "taskAnnounce", id);
}
 
public client_disconnect(id)
{
   if(g_iAdminVoice == id)
   {
      g_iAdminVoice = 0;
   }
   if(g_bMuted{ id })
   {
      TrieSetCell(g_tMutedPlayersIps, g_szClientsIp[id], 1);
      g_bMuted{ id } = false;
   }
}
 
public ClCmd_VModEnable(id)
{
   if( read_argc() >= 2 )
   {
      new arg[32];
      read_argv(1, arg, cm(arg));
      g_bHasVoicesOn{ id } = !!str_to_num(arg);
   }
}
 
public ClCmd_vban(id)
{
   if( read_argc() >= 2 )
   {
      new arg[32];
      read_argv(1, arg, cm(arg));
      g_bitBannedClients[id] = strtol(arg, .base = 16);
   }
}
 
public OnVoice_SetClientListening(id, iSender, bool:bListen)
{
   if( !is_user_connected(iSender) )
   {
      return FMRES_IGNORED;
   }
   static bool:bShouldListen;
   bShouldListen = false;
#if defined SUPER_ADMIN_PRIORITY
   if(g_iAdminVoice)
   {
      bShouldListen = (g_iAdminVoice == iSender);
   }
   else if( !g_bHasVoicesOn{ id } || CanPlayerHearPlayer(id, iSender) )
   {
      return FMRES_IGNORED;
   }
#else
   if( !g_bHasVoicesOn{ id } || CanPlayerHearPlayer(id, iSender) )
   {
      return FMRES_IGNORED;
   }
   else if(g_iAdminVoice)
   {
      bShouldListen = (g_iAdminVoice == iSender);
   }
#endif
   else if( !g_bMuted{ iSender } )
   {
      if( g_bInterAdminVoice{ iSender } )
      {
         bShouldListen = !!g_bAdmin{ id };
      }
      else if(g_bAdminListen{ id })
      {
         bShouldListen = true;
      }
      else
      {
         static pcvar;
         switch( get_pdata_int(id, m_iTeam) )
         {
            case TEAM_T:
            {
               pcvar = g_pcvarVoicesRules[ is_user_alive(id) ? ALIVE_T : DEAD_T];
            }
            case TEAM_CT:
            {
               pcvar = g_pcvarVoicesRules[ is_user_alive(id) ? ALIVE_CT : DEAD_CT];
            }
            default:
            {
               pcvar = g_pcvarVoicesRules[SPEC];
            }
         }
 
         static szRules[6], iRules;
         get_pcvar_string(pcvar, szRules, cm(szRules));
         iRules = read_flags(szRules);
 
         switch( get_pdata_int(iSender, m_iTeam) )
         {
            case TEAM_T:
            {
               bShouldListen = !!(iRules & ( is_user_alive(iSender) ? FL_ALIVE_T : FL_DEAD_T ));
            }
            case TEAM_CT:
            {
               bShouldListen = !!(iRules & ( is_user_alive(iSender) ? FL_ALIVE_CT : FL_DEAD_CT ));
            }
            default:
            {
               bShouldListen = !!(iRules & FL_SPEC);
            }
         }
      }
   }
 
   if( bShouldListen != bListen )
   {
      forward_return
      (
         FMV_CELL,
         engfunc(EngFunc_SetClientListening, id, iSender, bShouldListen)
      );
      return FMRES_SUPERCEDE;
   }
   return FMRES_IGNORED;
}
 
public AdminCommand_ListenOn(id)
{
   if( !g_bAdmin{ id } )
   {
      return PLUGIN_HANDLED;
   }
 
   g_bAdminListen{ id } = true;
 
   return PLUGIN_HANDLED;
}
 
public AdminCommand_ListenOff(id)
{
   if( g_bAdminListen{ id } )
   {
      g_bAdminListen{ id } = false;
   }
 
   return PLUGIN_HANDLED;
}
 
public AdminCommand_ListenToggle(id)
{
   if( !g_bAdmin{ id } )
   {
      return PLUGIN_HANDLED;
   }
 
   g_bAdminListen{ id } = !g_bAdminListen{ id };
 
   client_print_color(id, id, "%L", id, "VM_LISTEN_STATUS", g_bAdminListen{ id } ? "ON" : "OFF");
 
   return PLUGIN_HANDLED;
}
 
public AdminCommand_VoiceOn(id)
{
   if( !g_bAdmin{ id } )
   {
      return PLUGIN_HANDLED;
   }
 
   if(g_iAdminVoice)
   {
      client_print_color(id, id, "%L", id, "VM_ALREADY_INUSE");
      return PLUGIN_HANDLED;
   }
 
   g_iAdminVoice = id;
 
   new name[32];
   pev(id, pev_netname, name, cm(name));
 
   for(new player = 1; player <= g_iMaxPlayers; player++)
   {
      if( is_user_connected(player) && !is_user_hltv(player) && !is_user_bot(player) )
      {
         client_print_color(player, id, "%L", player, "VM_ADMIN_TALK", name);
      }
   }
 
   client_cmd(id, "+voicerecord");
 
   return PLUGIN_HANDLED;
}
 
public AdminCommand_VoiceOff(id)
{
   if( !g_bAdmin{ id } )
   {
      return PLUGIN_HANDLED;
   }
 
   if(g_iAdminVoice != id)
   {
      client_cmd(id, "-voicerecord");
      return PLUGIN_HANDLED;
   }
 
   client_cmd(id, "-voicerecord");
   g_iAdminVoice = 0;
   return PLUGIN_HANDLED;
}
 
public AdminCommand_InterAdminOn(id)
{
   if( !g_bAdmin{ id } )
   {
      return PLUGIN_HANDLED;
   }
 
   g_bInterAdminVoice{ id } = true;
   client_cmd(id, "+voicerecord");
 
   new name[32];
   get_user_name(id, name, cm(name));
   for(new i=1; i<=g_iMaxPlayers; i++)
   {
      if( !g_bAdmin{ i } || !is_user_connected(i) )
      {
         continue;
      }
      client_print_color(i, id, "%L", i, "VM_INTER_START", name);
   }
 
   return PLUGIN_HANDLED;
}
 
public AdminCommand_InterAdminOff(id)
{
   if( !g_bInterAdminVoice{ id } )
      return PLUGIN_HANDLED;
 
   g_bInterAdminVoice{ id } = false;
   client_cmd(id, "-voicerecord");
 
   new name[32];
   get_user_name(id, name, cm(name));
   for(new i=1; i<=g_iMaxPlayers; i++)
   {
      if( !g_bAdmin{ i } || !is_user_connected(i) )
      {
         continue;
      }
      client_print_color(i, id, "%L", i, "VM_INTER_STOP", name);
   }
 
   return PLUGIN_HANDLED;
}
 
public AdminCommand_Mute(id, level, cid)
{
   if( !cmd_access(id, level, cid, 2, true) )
   {
      return PLUGIN_HANDLED;
   }
 
   new szPlayer[32];
   read_argv(1, szPlayer, cm(szPlayer));
   new iPlayer = cmd_target(id, szPlayer, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS);
 
   if( !iPlayer )
   {
      return PLUGIN_HANDLED;
   }
 
   if( g_bAdmin{ iPlayer } )
   {
      client_print(id, print_console, "%L", id ? id : LANG_SERVER, "VM_MUTE_ADMIN");
      return PLUGIN_HANDLED;
   }
 
   if( g_bMuted{ iPlayer } )
   {
      client_print(id, print_console, "%L", id ? id : LANG_SERVER, "VM_AR_MUTED");
      return PLUGIN_HANDLED;
   }
 
   g_bMuted{ iPlayer } = true;
   client_print(id, print_console, "%L", id ? id : LANG_SERVER, "VM_MUTED");
 
   if(g_amx_show_activity)
   {
      new name[32], name2[32];
      get_user_name(id, name, cm(name));
      get_user_name(iPlayer, name2, cm(name2));
      // show_activity_col(id, name, name2, "VM_MUTE_ACTIVITY");
      show_activity_key_color(id, "VM_MUTE_ACTIVITY_NO_NAME", "VM_MUTE_ACTIVITY_NAME", name, name2);
   }
   return PLUGIN_HANDLED;
}
 
public AdminCommand_UnMute(id, level, cid)
{
   if( !cmd_access(id, level, cid, 2, true) )
   {
      return PLUGIN_HANDLED;
   }
 
   new szPlayer[32], iPlayer;
   read_argv(1, szPlayer, cm(szPlayer));
   iPlayer = cmd_target(id, szPlayer, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS);
 
   if( !iPlayer )
   {
      return PLUGIN_HANDLED;
   }
 
   if( !g_bMuted{ iPlayer } )
   {
      client_print(id, print_console, "%L", id ? id : LANG_SERVER, "VM_NOT_MUTED");
      return PLUGIN_HANDLED;
   }
 
   g_bMuted{ iPlayer } = false;
   client_print(id, print_console, "%L", id ? id : LANG_SERVER, "VM_UNMUTED");
 
   if(g_amx_show_activity)
   {
      new name[32], name2[32];
      get_user_name(id, name, cm(name));
      get_user_name(iPlayer, name2, cm(name2));
 
      // show_activity_col(id, name, name2, "VM_UNMUTE_ACTIVITY");
      show_activity_key_color(id, "VM_UNMUTE_ACTIVITY_NO_NAME", "VM_UNMUTE_ACTIVITY_NAME", name, name2);
   }
 
   return PLUGIN_HANDLED;
}
 
show_activity_key_color(sender, const KeyWithoutName[], const KeyWithName[], const ___AdminName[], any:...)
{
// The variable gets used via vformat, but the compiler doesn't know that, so it still cries.
#pragma unused ___AdminName
   static activity;
   activity = get_show_activity_value();
   if( !activity )
   {
      return;
   }
 
   new buffer[512];
   new keyfmt[256];
   new id;
   new players[32];
   new num;
   new isadmin;
   new activityBit = 1<<activity;
 
   get_players(players, num, "ch");
   for(--num; num>=0; num--)
   {
      id = players[num];
      isadmin = is_user_admin(id);
      
      if( activity == 2 || (activityBit & 0b1100 && isadmin) ) // show name
      {
         LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithName, id);
         vformat(buffer, charsmax(buffer), keyfmt, 4);
         client_print_color(id, sender, "%s", buffer);
      }
      else if( activity == 1 || (activityBit & 12 /* 0b1100 */ && !isadmin) || (activity == 5 && isadmin ) ) // show without name
      {
         LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithoutName, id);
         // skip the "adminname" argument if not showing name
         vformat(buffer, charsmax(buffer), keyfmt, 5);
         client_print_color(id, sender, "%s", buffer);
      }
   }
}
 
get_show_activity_value()
{
   static amx_show_activity;
   static const string_amx_show_activity[] = "amx_show_activity";
   if (amx_show_activity == 0)
   {
      amx_show_activity = get_cvar_pointer(string_amx_show_activity);
    
      // if still not found, then register the cvar as a dummy
      if (amx_show_activity == 0)
      {
         amx_show_activity = register_cvar(string_amx_show_activity, "2");
      }
   }
   return get_pcvar_num(amx_show_activity);
}
 
 
Сообщения
4
Рейтинг
-1
#2
Да да мне тоже хотелось бы знать, попробовал покрутить, с voice manager 1.6, не очень вышло, а точнее вообще ничего не получилось.
А так было бы не плохо, добавить в это плагин время для инфы
 
 
Сообщения
75
Рейтинг
7
#3
blacklist_krsk,
Код:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
 
 
#define PLUGIN   "Voice Manager"
#define VERSION   "1.6"
#define AUTHOR   "Stimul"
 
#define get_bit(%1,%2)   (%1 & (1 << (%2 & 31)))
#define set_bit(%1,%2)   (%1 |= (1 << (%2 & 31)))
#define reset_bit(%1,%2)   (%1 &= ~(1 << (%2 & 31)))
 
#define m_iTeam 114
#define fm_cs_get_user_team_index(%1)   get_pdata_int(%1, m_iTeam)
 
#define MAX_CLIENTS   32
 
#define ACCESS_LEVEL   ADMIN_BAN   // Все флаги смотрите в amxconst.inc
 
new g_bIsConnected;
new g_bIsAlive;
new g_bIsAdmin;
new g_bInfo;
 
new g_iTeam[MAX_CLIENTS+1];
 
new g_pImmunity;
 
public plugin_init()
{
   register_plugin(PLUGIN, VERSION, AUTHOR);
    
   /*
      Иммунитет для админов
      * 1 - включен
      * 0 - выключен
   */
    
   g_pImmunity = register_cvar("vm_immunity", "1");
    
   RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", true);
   RegisterHam(Ham_Killed, "player", "fw_PlayerKilled_Post", true);
    
   register_forward(FM_Voice_SetClientListening, "fw_Voice_SetClientListening");
}
 
public fw_PlayerSpawn_Post(id)
{
   if(is_user_alive(id))
   {
      set_bit(g_bIsAlive, id);
      
      g_iTeam[id] = fm_cs_get_user_team_index(id);
   }
}
 
public fw_PlayerKilled_Post(id)
{
   reset_bit(g_bIsAlive, id);
   set_bit(g_bInfo, id);
   set_task(5.0, "OffTimeInfo", id);
}
 
public OffTimeInfo(id)
{
   if(get_bit(g_bIsConnected, id))
   {
      client_print(id, print_chat, "Время для инфы ИСТЕКЛО.");
      reset_bit(g_bInfo, id);
   }
}
 
public client_putinserver(id)
{
   set_bit(g_bIsConnected, id);
   get_user_flags(id) & ACCESS_LEVEL ? set_bit(g_bIsAdmin, id) : reset_bit(g_bIsAdmin, id);
   reset_bit(g_bInfo, id);
}
 
public client_disconnect(id)
{
   reset_bit(g_bIsConnected, id);
   reset_bit(g_bIsAlive, id);
}
 
public fw_Voice_SetClientListening(receiver, sender, listen)
{
   if(get_bit(g_bIsConnected, receiver) && get_bit(g_bIsConnected, sender) && receiver != sender && get_pcvar_num(g_pImmunity) && (!get_bit(g_bIsAdmin, receiver) || !get_bit(g_bIsAdmin, sender)))
   {
      if(get_bit(g_bInfo, sender))
         return FMRES_IGNORED;
      
      if((get_bit(g_bIsAlive, receiver) && g_iTeam[receiver] == 2) && ((get_bit(g_bIsAlive, sender) && g_iTeam[sender] == 2)))
         return FMRES_IGNORED;
      
      else if((get_bit(g_bIsAlive, receiver) && g_iTeam[receiver] == 1) && ((get_bit(g_bIsAlive, sender) && g_iTeam[sender] == 1)))
         return FMRES_IGNORED;
      
      else if((!get_bit(g_bIsAlive, receiver) && g_iTeam[receiver] == 1) || (!get_bit(g_bIsAlive, receiver) && g_iTeam[receiver] == 2))
         return FMRES_IGNORED;
      
      else
      {
         engfunc(EngFunc_SetClientListening, receiver, sender, false);
         return FMRES_SUPERCEDE;
      }
   }
    
   return FMRES_IGNORED;
}
 
 
Сообщения
135
Рейтинг
27
#7
Dmitriy Korolev, Вы не поняли моего вопроса: Что должно выводится в чат и в какой период (после коннекта 5 сек, после смерти 5 сек, вариантов масса)
 
 
Сообщения
135
Рейтинг
27
#9
Отлавливаешь событие смерти игрока, далее в помощь set_task, через него выводишь в чат, свое инфо. Не забываем обнулять task.
 
1  
Сообщения
135
Рейтинг
27
#12
Dmitriy Korolev, Я, все прекрасно вижу. Вы к чему мне про спойлер сказали? Что, я там должен увидеть?
Пятница в 12:36
За ваше "хочу" и без наработок - никто вам помогать не будет. Не хотите учиться и пытаться? Переходите сюда, здесь все сделают за вас: ТЫК
 
 
> > > > >