Raised This Month: $ Target: $400
 0% 

[HELP] Voices Management


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Toy0t1k
Junior Member
Join Date: May 2013
Old 05-16-2013 , 14:37   [HELP] Voices Management
Reply With Quote #1

PHP Code:
// 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.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 voices 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
*
*/

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define VERSION "1.0.2"

#define MAX_PLAYERS    32

#define OFFSET_TEAM        114

new g_iClientSettings[MAX_PLAYERS+1][2]
new 
bool:g_bPlayerNonSpawnEvent[MAX_PLAYERS+1]
new 
g_iFwFmClientCommandPost
new bool:g_bAlive[MAX_PLAYERS+1]

new 
g_iAdminVoice
new bool:g_bAdmin[MAX_PLAYERS+1]
new 
bool:g_bInterAdminVoice[MAX_PLAYERS+1]
new 
bool:g_bAdminListen[MAX_PLAYERS+1]

new 
bool:g_bMuted[MAX_PLAYERS+1]
new 
g_szClientsIp[MAX_PLAYERS+1][22]
new Array:
g_aMutedPlayersIps

new g_iMaxPlayers
new g_msgidSayText
new g_pcvarAlivesHearg_pcvarDeadsHear
new g_amx_show_activity

public plugin_init()
{
    
register_plugin("Voices Management"VERSION"ConnorMcLeod")
    
register_dictionary("voicesmanagement.txt")
    
register_dictionary("common.txt")

    
g_pcvarAlivesHear register_cvar("vm_alives""1")  // 0:alive teamates , 1:alives , 2:all
    
g_pcvarDeadsHear register_cvar("vm_deads""0")    // 0:dead teamates , 1:deads , 2:all

    
register_forward(FM_Voice_SetClientListening"Forward_SetClientListening")
    
register_event("VoiceMask""Event_VoiceMask""b")

    
register_event("TextMsg""Event_TextMsg_Restart""a""2=#Game_will_restart_in")
    
register_event("ResetHUD""Event_ResetHUD""b")
    
register_event("DeathMsg""Event_DeathMsg""a")

    
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""ClientCommand_SayStatus")
    
register_clcmd("say_team /vm""ClientCommand_SayStatus")

    
register_clcmd("fullupdate""ClientCommand_fullupdate")
}

public 
plugin_cfg()
{
    
server_cmd("sv_alltalk 1;alias sv_alltalk")
    
server_exec()
    
g_iMaxPlayers get_maxplayers()
    
g_aMutedPlayersIps ArrayCreate(22)
    
g_msgidSayText get_user_msgid("SayText")
    
g_amx_show_activity get_cvar_pointer("amx_show_activity")
}

public 
ClientCommand_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"
    
}

    
col_mess(idid"%L"id"VM_ALIVES_STATUS"idszAlivesStatus)
    
col_mess(idid"%L"id"VM_DEADS_STATUS"idszDeadsStatus)
}

public 
taskAnnounce(id)
{
    if( 
is_user_connected(id) )
    {
        
col_mess(idid"%L"id"VM_ANNOUCE")
    }
}

public 
ClientCommand_fullupdate(id)
{
    
g_bPlayerNonSpawnEvent[id] = true
    
static const szFwFmClientCommandPost[] = "fwFmClientCommandPost"
    
g_iFwFmClientCommandPost register_forward(FM_ClientCommandszFwFmClientCommandPost1)
    return 
PLUGIN_CONTINUE
}

public 
fwFmClientCommandPost(iPlayerId) {
    
unregister_forward(FM_ClientCommandg_iFwFmClientCommandPost1)
    
g_bPlayerNonSpawnEvent[iPlayerId] = false
    
return FMRES_HANDLED
}

public 
Event_TextMsg_Restart()
{
    for(new 
id=1id <= g_iMaxPlayers; ++id)
    {
        if(
g_bAlive[id])
        {
            
g_bPlayerNonSpawnEvent[id] = true
        
}
    }
}

public 
Event_ResetHUD(id)
{
    if( !
is_user_alive(id) )
    {
        return
    }

    if(
g_bPlayerNonSpawnEvent[id])
    {
        
g_bPlayerNonSpawnEvent[id] = false
        
return
    }
    
g_bAlive[id] = true
}

public 
client_authorized(id)
{
    
g_bAdmin[id] = bool:(get_user_flags(id) & ADMIN_VOICE)
}

public 
client_putinserver(id)
{
    
g_bAlive[id] = false
    g_bAdminListen
[id] = false
    g_bInterAdminVoice
[id] = false

    
if(is_user_bot(id) || is_user_hltv(id))
        return

    static 
szIp[22]
    
get_user_ip(idszIp21)
    
g_szClientsIp[id] = szIp

    
static szTempIp[22], iArraySize
    iArraySize 
ArraySize(g_aMutedPlayersIps)
    for(new 
ii<iArraySizei++)
    {
        
ArrayGetString(g_aMutedPlayersIpsiszTempIp21)
        if( 
equal(szIpszTempIp) )
        {
            
ArrayDeleteItem(g_aMutedPlayersIpsi)
            
g_bMuted[id] = true
            
break
        }
    }

    
set_task(ANNOUNCE_TASK_DELAY"taskAnnounce"id)
}

public 
client_disconnect(id)
{
    if(
g_iAdminVoice == id)
    {
        
g_iAdminVoice 0
    
}
    if(
g_bMuted[id])
    {
        
ArrayPushString(g_aMutedPlayersIpsg_szClientsIp[id])
        
g_bMuted[id] = false
    
}
}

public 
Event_DeathMsg()
{
    
g_bAlive[read_data(2)] = false
}

public 
Event_VoiceMask(id)
{
    
g_iClientSettings[id][0] = read_data(1)
    
g_iClientSettings[id][1] = read_data(2)
}

public 
Forward_SetClientListening(iReceiveriSenderbool:bListen)
{
#if defined SUPER_ADMIN_PRIORITY
    
if(g_iAdminVoice)
    {
        if(
g_iAdminVoice == iSender)
        {
            
engfunc(EngFunc_SetClientListeningiReceiveriSendertrue)
            
forward_return(FMV_CELLtrue)
            return 
FMRES_SUPERCEDE
        
}
        
engfunc(EngFunc_SetClientListeningiReceiveriSenderfalse)
        
forward_return(FMV_CELLfalse)
        return 
FMRES_SUPERCEDE
    
}

    if( !
g_iClientSettings[iReceiver][0] || g_iClientSettings[iReceiver][1] & (1<<(iSender-1)) )
    {
        return 
FMRES_IGNORED
    
}
#else
    
if( !g_iClientSettings[iReceiver][0] || g_iClientSettings[iReceiver][1] & (1<<(iSender-1)) )
    {
        return 
FMRES_IGNORED
    
}

    if(
g_iAdminVoice)
    {
        if(
g_iAdminVoice == iSender)
        {
            
engfunc(EngFunc_SetClientListeningiReceiveriSendertrue)
            
forward_return(FMV_CELLtrue)
            return 
FMRES_SUPERCEDE
        
}
        
engfunc(EngFunc_SetClientListeningiReceiveriSenderfalse)
        
forward_return(FMV_CELLfalse)
        return 
FMRES_SUPERCEDE
    
}
#endif
    
if(g_bMuted[iSender])
    {
        
engfunc(EngFunc_SetClientListeningiReceiveriSenderfalse)
        
forward_return(FMV_CELLfalse)
        return 
FMRES_SUPERCEDE
    
}

    if(
g_bInterAdminVoice[iSender])
    {
        if(
g_bAdmin[iReceiver]) 
        {
            
engfunc(EngFunc_SetClientListeningiReceiveriSendertrue)
            
forward_return(FMV_CELLtrue)
            return 
FMRES_SUPERCEDE
        
}
        
engfunc(EngFunc_SetClientListeningiReceiveriSenderfalse)
        
forward_return(FMV_CELLfalse)
        return 
FMRES_SUPERCEDE
    
}

    if(
g_bAdminListen[iReceiver])
    {
        
engfunc(EngFunc_SetClientListeningiReceiveriSendertrue)
        
forward_return(FMV_CELLtrue)
        return 
FMRES_SUPERCEDE
    
}

    if(
g_bAlive[iReceiver])
    {
        switch(
get_pcvar_num(g_pcvarAlivesHear))
        {
            case 
0:
            {
                if( 
g_bAlive[iSender] && get_pdata_int(iReceiverOFFSET_TEAM) == get_pdata_int(iSenderOFFSET_TEAM) )
                {
                    
engfunc(EngFunc_SetClientListeningiReceiveriSendertrue)
                    
forward_return(FMV_CELLtrue)
                    return 
FMRES_SUPERCEDE
                
}
            }
            case 
1:
            {
                if( 
g_bAlive[iSender] )
                {
                    
engfunc(EngFunc_SetClientListeningiReceiveriSendertrue)
                    
forward_return(FMV_CELLtrue)
                    return 
FMRES_SUPERCEDE
                
}
            }
            case 
2:
            {
                
engfunc(EngFunc_SetClientListeningiReceiveriSendertrue)
                
forward_return(FMV_CELLtrue)
                return 
FMRES_SUPERCEDE
            
}
        }
    }
    else
    {
        switch(
get_pcvar_num(g_pcvarDeadsHear))
        {
            case 
0:
            {
                if( !
g_bAlive[iSender] && get_pdata_int(iReceiverOFFSET_TEAM) == get_pdata_int(iSenderOFFSET_TEAM) )
                {
                    
engfunc(EngFunc_SetClientListeningiReceiveriSendertrue)
                    
forward_return(FMV_CELLtrue)
                    return 
FMRES_SUPERCEDE
                
}
            }
            case 
1:
            {
                if( !
g_bAlive[iSender] )
                {
                    
engfunc(EngFunc_SetClientListeningiReceiveriSendertrue)
                    
forward_return(FMV_CELLtrue)
                    return 
FMRES_SUPERCEDE
                
}
            }
            case 
2:
            {
                
engfunc(EngFunc_SetClientListeningiReceiveriSendertrue)
                
forward_return(FMV_CELLtrue)
                return 
FMRES_SUPERCEDE
            
}
        }
    }

    
engfunc(EngFunc_SetClientListeningiReceiveriSenderfalse)
    
forward_return(FMV_CELLfalse)
    return 
FMRES_SUPERCEDE
}

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]

    
col_mess(idid"%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)
    {
        
col_mess(idid"%L"id"VM_ALREADY_INUSE")
        return 
PLUGIN_HANDLED
    
}

    
g_iAdminVoice id

    
new name[32]
    
pev(idpev_netnamename31)

    for(new 
player 1player <= g_iMaxPlayersplayer++)
    {
        if( 
is_user_connected(player) && !is_user_hltv(player) && !is_user_bot(player) )
        {
            
col_mess(playerid"%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(idname31)
    for(new 
i=1i<=g_iMaxPlayersi++)
    {
        if( !
g_bAdmin[i] || !is_user_connected(i) )
        {
            continue
        }
        
col_mess(iid"%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(idname31)
    for(new 
i=1i<=g_iMaxPlayersi++)
    {
        if( !
g_bAdmin[i] || !is_user_connected(i) )
        {
            continue
        }
        
col_mess(iid"%L"i"VM_INTER_STOP"name)
    }

    return 
PLUGIN_HANDLED
}

public 
AdminCommand_Mute(idlevelcid)
{
    if( !
cmd_access(idlevelcid2true) )
    {
        return 
PLUGIN_HANDLED
    
}

    new 
szPlayer[32]
    
read_argv(1szPlayer31)
    new 
iPlayer cmd_target(idszPlayerCMDTARGET_OBEY_IMMUNITY CMDTARGET_NO_BOTS)

    if( !
iPlayer )
    {
        return 
PLUGIN_HANDLED
    
}

    if( 
g_bAdmin[iPlayer] )
    {
        
client_print(idprint_console"%L"id id LANG_SERVER"VM_MUTE_ADMIN")
        return 
PLUGIN_HANDLED
    
}

    if( 
g_bMuted[iPlayer] )
    {
        
client_print(idprint_console"%L"id id LANG_SERVER"VM_AR_MUTED")
        return 
PLUGIN_HANDLED
    
}

    
g_bMuted[iPlayer] = true
    client_print
(idprint_console"%L"id id LANG_SERVER"VM_MUTED")

    if(
g_amx_show_activity)
    {
        new 
name[32], name2[32]
        
get_user_name(idname31)
        
get_user_name(iPlayername231)
        
show_activity_col(idnamename2"VM_MUTE_ACTIVITY")
    }
    return 
PLUGIN_HANDLED
}

public 
AdminCommand_UnMute(idlevelcid)
{
    if( !
cmd_access(idlevelcid2true) )
    {
        return 
PLUGIN_HANDLED
    
}

    new 
szPlayer[32], iPlayer
    read_argv
(1szPlayer31)
    
iPlayer cmd_target(idszPlayerCMDTARGET_OBEY_IMMUNITY CMDTARGET_NO_BOTS)

    if( !
iPlayer )
    {
        return 
PLUGIN_HANDLED
    
}

    if( !
g_bMuted[iPlayer] )
    {
        
client_print(idprint_console"%L"id id LANG_SERVER"VM_NOT_MUTED")
        return 
PLUGIN_HANDLED
    
}

    
g_bMuted[iPlayer] = false
    client_print
(idprint_console"%L"id id LANG_SERVER"VM_UNMUTED")

    if(
g_amx_show_activity)
    {
        new 
name[32], name2[32]
        
get_user_name(idname31)
        
get_user_name(iPlayername231)

        
show_activity_col(idnamename2"VM_UNMUTE_ACTIVITY")
    }

    return 
PLUGIN_HANDLED
}

col_mess(idsenderstring[], any:...)
{
    static 
szMessage[128]
    
szMessage[0] = 0x01
    vformat
(szMessage[1], 127string4)

    
replace_all(szMessage127"!n""^x01")
    
replace_all(szMessage127"!t""^x03")
    
replace_all(szMessage127"!g""^x04")

    
message_begin(MSG_ONE_UNRELIABLEg_msgidSayText_id)
    
write_byte(sender)
    
write_string(szMessage)
    
message_end()
}

show_activity_col(idname[], name2[], ML_KEY[])
{
    switch(
get_pcvar_num(g_amx_show_activity))
    {
        case 
5// hide name only to admins, show nothing to normal users
        
{        
            for (new 
i=1i<=g_iMaxPlayersi++)
            {
                if (
is_user_connected(i) && !is_user_bot(i) && !is_user_hltv(i))
                {
                    if (
is_user_admin(i))
                    {
                        
col_mess(iid" ** !g[VM] !n%L: %L"i"ADMIN"iML_KEYname2)
                    }
                }
            }
        }
        case 
4// show name only to admins, show nothing to normal users
        
{
            for (new 
i=1i<=g_iMaxPlayersi++)
            {
                if (
is_user_connected(i) && !is_user_bot(i) && !is_user_hltv(i))
                {
                    if (
is_user_admin(i))
                    {
                        
col_mess(iid" ** !g[VM] !n%L !t%s!n: %L"i"ADMIN"nameiML_KEYname2)
                    }
                }
            }
        }
        case 
3// show name only to admins, hide name from normal users
        
{
            for (new 
i=1i<=g_iMaxPlayersi++)
            {
                if (
is_user_connected(i) && !is_user_bot(i) && !is_user_hltv(i))
                {
                    if (
is_user_admin(i))
                    {
                        
col_mess(iid" ** !g[VM] !n%L !t%s!n: %L"i"ADMIN"nameiML_KEYname2)
                    }
                    else
                    {
                        
col_mess(iid" ** !g[VM] !n%L: %L"i"ADMIN"iML_KEYname2)
                    }
                }
            }
        }
        case 
2// show name to all
        
{
            for (new 
i=1i<=g_iMaxPlayersi++)
            {
                if (
is_user_connected(i) && !is_user_bot(i) && !is_user_hltv(i))
                {
                    
col_mess(iid" ** !g[VM] !n%L !t%s!n: %L"i"ADMIN"nameiML_KEYname2)
                }
            }
        }
        case 
1// hide name to all
        
{
            for (new 
i=1i<=g_iMaxPlayersi++)
            {
                if (
is_user_connected(i) && !is_user_bot(i) && !is_user_hltv(i))
                {
                    
col_mess(iid" ** !g[VM] !n%L: %L"i"ADMIN"iML_KEYname2)
                }
            }
        }
    }

The scripting is like the "TEAM T" can talk to the server.
I just wanted the "TEAM CT" can speak on the server.

I do not know how to do, if anyone knows, help me.
Toy0t1k is offline
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:21.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode