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[] command, int argc)
{
// vban mute list is hexadecimal
char hexadecimal[100];
GetCmdArg(1, hexadecimal, sizeof(hexadecimal));
// lets think it is binary, player slots, 00000000000000000000010000001000000000000000000000010000001011111
int binary;
StringToIntEx(hexadecimal, binary, 16);
// 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 = 1; player <= MaxClients; player++)
{
if(!IsClientInGame(player)) continue;
// change player index to match player slot, shifted bit
slot = player - 1;
// bit has change ?
if(bits_toggle & (1 << slot))
{
// client muted player
if(binary & (1 << slot))
{
ClientMutedPlayer(client, player, binary);
}
else // client unmuted player
{
ClientUnMutedPlayer(client, player, binary);
}
}
}
return Plugin_Continue;
}
void ClientMutedPlayer(int client, int player, int &ban)
{
PrintToServer("ClientMutedPlayer(%N %N)", client, player);
MuteStatus();
}
void ClientUnMutedPlayer(int client, int player, int &ban)
{
PrintToServer("ClientUnMutedPlayer(%N %N)", client, player);
MuteStatus();
}
stock void MuteStatus()
{
int[] list = new int[MaxClients+1];
int slot;
for(int client = 1; client <= MaxClients; client++)
{
if(!IsClientInGame(client)) continue;
for(int player = 1; player <= MaxClients; player++)
{
if(!IsClientInGame(player) || IsFakeClient(player)) continue;
slot = client - 1;
if(vban[player] & (1 << slot)) list[client]++;
}
PrintToServer("%i players muted %N", list[client], client);
}
}
__________________