Raised This Month: $12 Target: $400
 3% 

Fixing timer on plugin


Post New Thread Reply   
 
Thread Tools Display Modes
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
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 02-02-2018 , 22:14   Re: Fixing timer on plugin
Reply With Quote #2

Not sure if this is the issue, but change:

PHP Code:
CreateTimerg_cvTime.FloatValueTimer_Muteevent.GetInt"userid" ) ); 
to

PHP Code:
CreateTimerg_cvTime.FloatValueTimer_Muteclient ); 
__________________

Last edited by Psyk0tik; 02-02-2018 at 22:14.
Psyk0tik is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 02-03-2018 , 07:05   Re: Fixing timer on plugin
Reply With Quote #3

Quote:
Originally Posted by Crasher_3637 View Post
Not sure if this is the issue, but change:

PHP Code:
CreateTimerg_cvTime.FloatValueTimer_Muteevent.GetInt"userid" ) ); 
to

PHP Code:
CreateTimerg_cvTime.FloatValueTimer_Muteclient ); 
Uh... that violates the first rule of timers: Never pass a client index through a timer.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 02-03-2018 , 08:04   Re: Fixing timer on plugin
Reply With Quote #4

Assuming CS:GO, check that you've got it configured so that dead players can talk to alive teammates by default (sv_deadtalk I believe).
__________________
asherkin is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 02-03-2018 , 09:22   Re: Fixing timer on plugin
Reply With Quote #5

Quote:
Originally Posted by Powerlord View Post
Uh... that violates the first rule of timers: Never pass a client index through a timer.
Is that so? [O_o]? I guess I have to reprogram my brain.exe again. [>_<]
cravenge is offline
malec321
Senior Member
Join Date: May 2009
Location: Los Angeles
Old 02-03-2018 , 16:01   Re: Fixing timer on plugin
Reply With Quote #6

Quote:
Originally Posted by asherkin View Post
Assuming CS:GO, check that you've got it configured so that dead players can talk to alive teammates by default (sv_deadtalk I believe).
Maybe that is the issue, will check and report back
__________________
Ayyylmao
malec321 is offline
pride95
Senior Member
Join Date: Aug 2015
Old 02-06-2018 , 09:39   Re: Fixing timer on plugin
Reply With Quote #7

PHP Code:
#pragma deprecated Use SetListenOverride() instead
native bool SetClientListening(int iReceiverint iSenderbool bListen);

#pragma deprecated GetListenOverride() instead
native bool GetClientListening(int iReceiverint iSender); 
its not a problem with timer, its a problem with clientlistening, the calling and maybe the code. if you cant resolve the problem, try:

PHP Code:
cvar sv_deadtalk always to 2;
after 10 seconds of deathSetClientListeningFlags(iClientVOICE_NORMAL); 
pride95 is offline
Reply


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 21:00.


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