AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Fixing timer on plugin (https://forums.alliedmods.net/showthread.php?t=304967)

malec321 02-02-2018 14:57

Fixing timer on plugin
 
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 );
            }
        }
    }



Psyk0tik 02-02-2018 22:14

Re: Fixing timer on plugin
 
Not sure if this is the issue, but change:

PHP Code:

CreateTimerg_cvTime.FloatValueTimer_Muteevent.GetInt"userid" ) ); 

to

PHP Code:

CreateTimerg_cvTime.FloatValueTimer_Muteclient ); 


Powerlord 02-03-2018 07:05

Re: Fixing timer on plugin
 
Quote:

Originally Posted by Crasher_3637 (Post 2576010)
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.

asherkin 02-03-2018 08:04

Re: Fixing timer on plugin
 
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).

cravenge 02-03-2018 09:22

Re: Fixing timer on plugin
 
Quote:

Originally Posted by Powerlord (Post 2576055)
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. [>_<]

malec321 02-03-2018 16:01

Re: Fixing timer on plugin
 
Quote:

Originally Posted by asherkin (Post 2576060)
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

pride95 02-06-2018 09:39

Re: Fixing timer on plugin
 
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); 



All times are GMT -4. The time now is 11:18.

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