View Single Post
Author Message
malec321
Senior Member
Join Date: May 2009
Location: Los Angeles
Old 02-02-2018 , 14:57   Fixing timer on plugin
Reply With Quote #1

Hello all,

I was trying to get help to finish completing this plugin and wanted to see if anyone can help here, as I was unable to get assistance in the plugin/gameplay ideas & requests section:

What this plugin is meant to do is give players who die 10 seconds (or a certain set time) to call out any information regarding the enemy team to those who are still alive. After those 10 seconds, that player is only allowed to speak with others in his team that are also dead.

The current problem with the below source is that the plugin is muting dead players but after you get the message that you can no longer speak to your alive teammates, you can talk still to them until you eventually randomly get muted. So I think the problem is the timer is not working.

Plugin credits: alexr153


PHP Code:
#include <sourcemod>
#include <sdktools>

#pragma newdecls required
#pragma semicolon 1

#define PLUGIN_VERSION "1.0"

ConVar g_cvEnable;
ConVar g_cvTime;
ConVar g_cvMessage;

bool g_bPlayerMuted[MAXPLAYERS 1];

public 
Plugin myinfo =
{
    
name "Info after death",
    
author "hAlexr",
    
description "Allows players to speak to teammates for limited time after death",
    
version PLUGIN_VERSION,
    
url ""
};

public 
void OnPluginStart(  )
{
    
/* CONVARS */
    
g_cvEnable CreateConVar"iad_enable""1""Enables or disables the plugin"_true0.0true1.0 );
    
g_cvTime CreateConVar"iad_time""10.0""Time until player is muted"_true0.1true20.0 );
    
g_cvMessage CreateConVar"iad_message""1""Enable or disable chat message"_true0.0true1.0 );
    
AutoExecConfigtrue"InfoAfterDeath" );
    
    
/* HOOKS */
    
HookEvent"player_death"Event_PlayerDeath );
    
HookEvent"player_spawn"Event_PlayerSpawn );
    
HookEvent"player_team"Event_PlayerTeam );
    
HookEvent"round_end"Event_RoundEnd );
}

public 
void OnClientDisconnectint client )
{
    
g_bPlayerMuted[client] = false;
}

public 
Action Event_PlayerDeathEvent event, const char[] namebool dontBroadcast )
{
    if ( !
g_cvEnable.BoolValue )
        return;
    
    
int userid event.GetInt"userid" );
    
int client GetClientOfUserIduserid );
    
    if( 
g_cvMessage.BoolValue )
    {
        
PrintToChatclient"[SM] You have %.1f seconds to speak to your teammates!"g_cvTime.FloatValue );
    }
    
    
CreateTimerg_cvTime.FloatValueTimer_Muteevent.GetInt"userid" ) );
}

public 
Action Event_PlayerTeamEvent event, const char[] namebool dontBroadcast )
{
    if ( !
g_cvEnable.BoolValue )
        return;
    
    
UnmuteClientGetClientOfUserIdevent.GetInt"userid" ) ) );
}

public 
Action Event_PlayerSpawnEvent event, const char[] namebool dontBroadcast )a
{
    if ( !
g_cvEnable.BoolValue )
        return;
    
    
UnmuteClientGetClientOfUserIdevent.GetInt"userid" ) ) );
}

public 
Action Event_RoundEndEvent event, const char[] namebool dontBroadcast )
{
    for ( 
int i 1<= MaxClientsi++ )
    {
        if ( 
IsClientConnected) && IsClientInGame) )
        {
            
UnmuteClient);
        }
    }
}

public 
Action Timer_MuteHandle timerint userid )
{
    if ( !
g_cvEnable.BoolValue )
        return;
    
    
MuteClientGetClientOfUserIduserid ) );
}

void MuteClientint client )
{
    if( 
IsClientConnectedclient ) && IsClientInGameclient ) && !IsPlayerAliveclient ) )
    {
        
g_bPlayerMuted[client] = true;
        
int clientTeam GetClientTeamclient );
        
        for( 
int i 1<= MaxClientsi++ )
        {
            if( 
IsClientConnected) && IsClientInGame) && != client && IsPlayerAlive) )
            {
                if ( 
clientTeam == GetClientTeam) )
                {
                    
SetListenOverrideiclientListen_No );
                }
            }
        }
        
        if( 
g_cvMessage.BoolValue )
            
PrintToChat(client"[SM] Times up! You can no longer speak to your teammates.");
    }
}

void UnmuteClientint client )
{
    if( !
g_bPlayerMuted[client] )
        return;
        
    if ( 
IsClientConnectedclient ) && IsClientInGameclient ) )
    {
        
g_bPlayerMuted[client] = false;
        
        for( 
int i 1<= MaxClientsi++ )
        {
            if( 
IsClientConnected) && IsClientInGame) && != client )
            {
                
SetListenOverrideiclientListen_Default );
            }
        }
    }

__________________
Ayyylmao
malec321 is offline