Raised This Month: $ Target: $400
 0% 

Solved [L4D2] Survivors Counter - Issue


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
spic
Junior Member
Join Date: Feb 2022
Old 05-13-2022 , 06:32   [L4D2] Survivors Counter - Issue
Reply With Quote #1

Hi guys, this plugin count players in L4D2, when they die, when they revive, it just let you how many left

The issue is when a game of, for example, 4 players someone become afk, it tells u that there is 5 survivors left, yet its only 4 survivors there

can someone point the issue

thanks

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

public Plugin:myinfo 

    
name "Survivors_Counter"
    
author ""
    
description "Announce Survivors Number"
    
version "1.0"
    
url "" 


public 
OnPluginStart() 

    
HookEvent"player_spawn"EVENT_PlayerSpawn ); 
    
HookEvent"player_death"EVENT_PlayerDeath ); 


public 
EVENT_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast

    new 
client GetClientOfUserIdGetEventIntevent"userid" )); 
     
    if ( 
IsTeamSurvivorclient )) 
    { 
        new 
counT CountSurvivor(); 
         
        if ( 
counT 
        { 
           
PrintHintTextToAll"%N Has Spawned\nAlive: %d"clientcounT ); 
        } 
    } 


public 
EVENT_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast

    new 
client GetClientOfUserIdGetEventIntevent"userid" )); 
     
    if ( 
IsTeamSurvivorclient )) 
    { 
        new 
counT CountSurvivor(); 
         
        if ( 
counT 
        { 
           
PrintHintTextToAll"%N Has Died\nLeft: %d"clientcounT ); 
        } 
    } 


CountSurvivor() 

    new 
survivoR 0
         
    for ( new 
1<= MaxClientsi++ ) 
    { 
        if ( 
IsTeamSurvivor) && IsPlayerAlive)) 
        { 
            
survivoR++; 
        } 
    } 
    return 
survivoR


stock bool:IsTeamSurvivorclient 

    if ( 
client || client MaxClients ) return false
    if ( !
IsClientConnectedclient )) return false
    if ( !
IsClientInGameclient )) return false
    if ( 
GetClientTeamclient ) != ) return false
    return 
true


Last edited by spic; 05-14-2022 at 03:44.
spic is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 05-13-2022 , 09:50   Re: [L4D2] Survivors Counter - Issue
Reply With Quote #2

When a player becomes AFK, in-game you actually has 1 human client and 1 bot client.

I don't remember how to check but ABM plugin has this snippet:

PHP Code:
int GetRealClient(int client) {
    if (
IsClientValid(client0)) {
        if (
HasEntProp(clientProp_Send"m_humanSpectatorUserID")) {
            
int userid GetEntProp(clientProp_Send"m_humanSpectatorUserID");
            
int target GetClientOfUserId(userid);

            if (
IsClientValid(target)) {
                
client target;
            }

            else {
                for (
int i 1<= MaxClientsi++) {
                    if (
GetQRtmp(i) && g_tmpTarget == client) {
                        
client i;
                        break;
                    }
                }
            }
        }
    }

    else {
        
client 0;
    }

    return 
client;

Probably you have to check if the client has m_humanSpectatorUserID set.
__________________

Last edited by Marttt; 05-13-2022 at 09:51.
Marttt is offline
spic
Junior Member
Join Date: Feb 2022
Old 05-14-2022 , 03:43   Re: [L4D2] Survivors Counter - Issue
Reply With Quote #3

Excellent Marttt

I think its fixed
spic is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 05-14-2022 , 06:27   Re: [L4D2] Survivors Counter - Issue
Reply With Quote #4

Hello

Can you please share the script with the fix please

I would really appreciate that, thank you
alasfourom is offline
Reply



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 14:29.


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