Hey, I need some help with the code.
Why does the plugin start alltalk in a new round?
PHP Code:
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1
#pragma newdecls required
ConVar vc_enable;
ConVar vc_time;
public Plugin myinfo = {
name = "[Voice controller] Mute dead players time",
author = "hAlexr",
description = "Adds so when player dieswill set a timer to mute him/herself from alive players",
version = "1.0.0",
url = "www.crypto-gaming.tk"
};
public void OnPluginStart()
{
vc_enable = CreateConVar("vc_enable", "1", "Enables or disables the plugin", _, true, 0.0, true, 1.0);
vc_time = CreateConVar("vc_time", "5.0", "Time until player is muted", _, true, 0.1, true, 20.0);
AutoExecConfig(true, "plugin.MuteDeadPlayers");
HookEvent("player_death", playerDeath);
HookEvent("player_team", Event_PlayerTeam);
}
public Action playerDeath(Event event, const char[] name, bool dontBroadcast)
{
if(!GetConVarBool(vc_enable))
return;
int client = GetClientOfUserId(GetEventInt(event, "userid"));
CreateTimer(GetConVarFloat(vc_time), muteTimer, client);
PrintToChat(client, " \x02╔═════════════════\x05[INFO]\x02═════════════════╗");
PrintToChat(client, " \x02╠ \x01Masz \x025s \x01 na podanie \x02INFA");
PrintToChat(client, " \x02╠ \x01Masz \x025s \x01 na podanie \x02INFA");
PrintToChat(client, " \x02╠ \x01Masz \x025s \x01 na podanie \x02INFA");
PrintToChat(client, " \x02╚═════════════════\x05[INFO]\x02═════════════════╝");
}
public Action muteTimer(Handle timer, int client)
{
if(!GetConVarBool(vc_enable))
return;
for(int i = 1; i<=MaxClients;i++)
{
if(IsClientConnected(client) && IsClientInGame(client) && i != client && !IsPlayerAlive(client))
{
int clientTeam = GetClientTeam(client);
if(IsClientConnected(i) && IsClientInGame(i) && i != client && IsPlayerAlive(i))
{
int iTeam = GetClientTeam(i);
if(clientTeam == iTeam)
{
SetListenOverride(i, client, Listen_No);
}
}
}
}
}
public Action Event_PlayerTeam(Event event, const char[] name, bool dontBroadcast)
{
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i))
{
int clientTeam = GetClientTeam(i);
unmuteClients(i, clientTeam);
}
}
}
public void unmuteClients(int client, int clientTeam)
{
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i))
{
int iTeam = GetClientTeam(client);
if(iTeam == clientTeam)
{
SetListenOverride(i, client, Listen_Yes);
SetListenOverride(client, i, Listen_Yes);
}
}
}
}