Raised This Month: $ Target: $400
 0% 

Players vban - Voice Ban command


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-07-2016 , 16:32   Players vban - Voice Ban command
Reply With Quote #1

Players use vban command when connect into server and mute/unmute players.
vban execute two arguments, ex. vban 1 1

I'm not sure what purpose have second argument, because I have tested with bots, it just identical with first argument.

But vban command execute hexadecimal values, which is ban list
Just convert hex string to decimal, then use player slot as shift bit in binary.
(Slot start from index 0)



PHP Code:
int vban[MAXPLAYERS+1];

public 
void OnPluginStart()
{
    
AddCommandListener(listen"vban");
}

public 
Action listen(int client, const char[] commandint argc)
{
    
// vban mute list is hexadecimal
    
char hexadecimal[100];
    
GetCmdArg(1hexadecimalsizeof(hexadecimal));

    
// lets think it is binary, player slots, 00000000000000000000010000001000000000000000000000010000001011111
    
int binary;
    
StringToIntEx(hexadecimalbinary16);

    
// follow which bits get change from previous vban
    
int bits_toggle binary vban[client];

    
// store current vban
    
vban[client] = binary;

    
int slot;

    
// Loop in game players
    
for(new player 1player <= MaxClientsplayer++)
    {
        if(!
IsClientInGame(player)) continue;

        
// change player index to match player slot, shifted bit
        
slot player 1;

        
// bit has change ?
        
if(bits_toggle & (<< slot))
        {
            
// client muted player
            
if(binary & (<< slot))
            {
                
ClientMutedPlayer(clientplayerbinary);
            }
            else 
// client unmuted player
            
{
                
ClientUnMutedPlayer(clientplayerbinary);
            }
        }
    }

    return 
Plugin_Continue;
}

void ClientMutedPlayer(int clientint playerint &ban)
{
    
PrintToServer("ClientMutedPlayer(%N %N)"clientplayer);
    
MuteStatus();
}

void ClientUnMutedPlayer(int clientint playerint &ban)
{
    
PrintToServer("ClientUnMutedPlayer(%N %N)"clientplayer);
    
MuteStatus();
}

stock void MuteStatus()
{
    
int[] list = new int[MaxClients+1];
    
int slot;

    for(
int client 1client <= MaxClientsclient++)
    {
        if(!
IsClientInGame(client)) continue;

        for(
int player 1player <= MaxClientsplayer++)
        {
            if(!
IsClientInGame(player) || IsFakeClient(player)) continue;

            
slot client 1;
            if(
vban[player] & (<< slot)) list[client]++;
        }

        
PrintToServer("%i players muted %N", list[client], client);
    }

__________________
Do not Private Message @me

Last edited by Bacardi; 09-07-2016 at 16:35.
Bacardi is offline
 



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 18:52.


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