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

[REQ] [L4D2] Survivor Counter


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
noxman
Member
Join Date: Jun 2012
Old 10-24-2013 , 10:33   [REQ] [L4D2] Survivor Counter
Reply With Quote #1

Hello,

i need a plugin which counts the Survivors. 10vs10 ( = 10 Survivors)

If a Survivor died it shows a little message (= hint message). Example:

PLAYERNAME died. 8 Survivors left.

Thanks in advance

(sry for my bad english)
noxman is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 10-30-2013 , 11:25   Re: [REQ] [L4D2] Survivor Counter
Reply With Quote #2

i dont like how i write this but what the hell..

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

new g_Survivor;
new 
g_Infected;

public 
Plugin:myinfo =
{
    
name "L4D2_PlayerCounter",
    
author "GsiX",
    
description "Announce player number",
    
version "0.0",
    
url "https://forums.alliedmods.net/showpost.php?p=2054639&postcount=2"
}

public 
OnPluginStart()
{
    
HookEvent"player_spawn"EVENT_Player );
    
HookEvent"player_death"EVENT_Player );
}

public 
EVENT_Player(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserIdGetEventIntevent"userid" ));
    
Announceclientname );
}

Announceclient, const String:namE[] )
{
    
g_Survivor 0;
    
g_Infected 0;
    new 
typE;
    
    if ( 
StrContainsnamE"spawn"false ) != -)
    {
        
typE 2;
    }
    else
    {
        
typE 3;
    }
    
    for ( new 
1<= MaxClientsi++ )
    {
        if ( 
IsClient) && IsPlayerAlive))
        {
            if ( 
GetClientTeam) == g_Infected++;
            if ( 
GetClientTeam) == g_Survivor++;
        }
    }
    
    
    for ( new 
1<= MaxClientsi++ )
    {
        if ( 
IsClient))
        {
            switch( 
GetClientTeam))
            {
                case 
2:
                {
                    if ( 
typE == )
                    {
                        
PrintHintTexti"%N has Spawned, %d Player(s) in Survivor Team"clientg_Survivor );
                    }
                    else
                    {
                        
PrintHintTexti"%N has Died, %d Player(s) in Survivor Team"clientg_Survivor );
                    }
                }
                case 
3:
                {
                    if ( 
typE == )
                    {
                        
PrintHintTexti"%N has Spawned, %d Player(s) in Infected Team"clientg_Infected );
                    }
                    else
                    {
                        
PrintHintTexti"%N has Died, %d Player(s) in Infected Team"clientg_Infected );
                    }
                }
            }
        }
    }
}

stock bool:IsClientclient )
{
    if ( 
client || client MaxClients ) return false;
    if ( !
IsClientConnectedclient )) return false;
    if ( !
IsClientInGameclient )) return false;
    return 
true;

EDIT: Untested..
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.

Last edited by GsiX; 10-30-2013 at 11:46.
GsiX is offline
noxman
Member
Join Date: Jun 2012
Old 11-01-2013 , 06:46   Re: [REQ] [L4D2] Survivor Counter
Reply With Quote #3

Thank you!!!

But, the Hinttext is always popup with "Console died (...)" or "Smoker died (...)." I just want the counter for the survivor team
noxman is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 11-01-2013 , 11:06   Re: [REQ] [L4D2] Survivor Counter
Reply With Quote #4

yay.. get rid of the team 3 and infected then..

delete all of them.

EDIT: what u mean by "Console Died"? i have a client range check.
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.

Last edited by GsiX; 11-01-2013 at 11:08.
GsiX is offline
noxman
Member
Join Date: Jun 2012
Old 11-01-2013 , 11:14   Re: [REQ] [L4D2] Survivor Counter
Reply With Quote #5

Hello,

i tested the plugin on my local dedi server. Here is the proof for "Console Died":

http://img5.fotos-hochladen.net/uplo...9yz5jhxadr.jpg

Last edited by noxman; 11-01-2013 at 11:14.
noxman is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 11-01-2013 , 11:17   Re: [REQ] [L4D2] Survivor Counter
Reply With Quote #6

awww... that was the bot.. my bad..

Ok since you tune me up.. i repost the code in a moment..
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.
GsiX is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 11-01-2013 , 11:33   Re: [REQ] [L4D2] Survivor Counter
Reply With Quote #7

note that i didnt check for the bot..

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

new g_Survivor;

public 
Plugin:myinfo =
{
    
name "L4D2_PlayerCounter",
    
author "GsiX",
    
description "Announce player number",
    
version "0.0",
    
url "https://forums.alliedmods.net/showpost.php?p=2054639&postcount=2"
}

public 
OnPluginStart()
{
    
HookEvent"player_spawn"EVENT_Player );
    
HookEvent"player_death"EVENT_Player );
}

public 
EVENT_Player(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserIdGetEventIntevent"userid" ));
    
    if ( 
IsTeamSurvivorclient ))
    {
        
g_Survivor 0;
        
        for ( new 
1<= MaxClientsi++ )
        {
            if ( 
IsTeamSurvivor) && IsPlayerAlive))
            {
                
g_Survivor++;
            }
        }
        
        if ( 
g_Survivor )
        {
            
// i think this more optimize than checking the string inside the loop
            
new typE;
            if ( 
StrContainsname"spawn"false ) != -)
            {
                
typE 1;
            }
            else
            {
                
typE 2;
            }
            
            for ( new 
1<= MaxClientsi++ )
            {
                if ( 
IsTeamSurvivor))
                {
                    if ( 
typE == )
                    {
                        
PrintHintTexti"%N has Spawned, %d Player(s) in Survivor Team"clientg_Survivor );
                    }
                    else
                    {
                        
PrintHintTexti"%N has Died, %d Player(s) in Survivor Team"clientg_Survivor );
                    }
                }
            }
        }
    }
}

stock bool:IsTeamSurvivorclient )
{
    if ( 
client || client MaxClients ) return false;
    if ( !
IsClientConnectedclient )) return false;
    if ( !
IsClientInGameclient )) return false;
    if ( 
GetClientTeamclient ) != ) return false;
    return 
true;

EDIT: sorry for double post.
EDIT2: tell me if you still get the console problem. I didnt encounter this before as i never own a server.
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.

Last edited by GsiX; 11-01-2013 at 11:37.
GsiX is offline
noxman
Member
Join Date: Jun 2012
Old 11-01-2013 , 11:55   Re: [REQ] [L4D2] Survivor Counter
Reply With Quote #8

The Console Problem is fixed. Thanks for this But the message show up if a infected died. "Boomer died 1 Survivors left." "Charger died. 1 Survivors left."

Picture: http://img5.fotos-hochladen.net/uplo...whxlczfkj4.jpg
noxman is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 11-01-2013 , 12:03   Re: [REQ] [L4D2] Survivor Counter
Reply With Quote #9

cant be..
Did you copy the entire plugin.. especially this..

PHP Code:
if ( GetClientTeamclient ) != ) return false
PHP Code:
stock bool:IsTeamSurvivorclient )
{
    if ( 
client || client MaxClients ) return false;
    if ( !
IsClientConnectedclient )) return false;
    if ( !
IsClientInGameclient )) return false;
    if ( 
GetClientTeamclient ) != ) return false//<<<< this part
    
return true;

EDIT: how you get 1 survivor left if many bot is still green life as what shown in the picture?
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.

Last edited by GsiX; 11-01-2013 at 12:09.
GsiX is offline
noxman
Member
Join Date: Jun 2012
Old 11-01-2013 , 12:19   Re: [REQ] [L4D2] Survivor Counter
Reply With Quote #10

I dont know ...


here is the fully code what is use:

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

new g_Survivor;

public 
Plugin:myinfo =
{
    
name "L4D2_PlayerCounter",
    
author "GsiX",
    
description "Announce player number",
    
version "0.0",
    
url "https://forums.alliedmods.net/showpost.php?p=2054639&postcount=2"
}

public 
OnPluginStart()
{
    
HookEvent"player_spawn"EVENT_Player );
    
HookEvent"player_death"EVENT_Player );
}

public 
EVENT_Player(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserIdGetEventIntevent"userid" ));
    
    if ( 
IsTeamSurvivorclient ))
    {
        
g_Survivor 0;
        
        for ( new 
1<= MaxClientsi++ )
        {
            if ( 
IsTeamSurvivor) && IsPlayerAlive))
            {
                
g_Survivor++;
            }
        }
        
        if ( 
g_Survivor )
        {
            
// i think this more optimize than checking the string inside the loop
            
new typE;
            if ( 
StrContainsname"spawn"false ) != -)
            {
                
typE 1;
            }
            else
            {
                
typE 2;
            }
            
            for ( new 
1<= MaxClientsi++ )
            {
                if ( 
IsTeamSurvivor))
                {
                    if ( 
typE == )
                    {
                        
PrintHintTexti"%N has Spawned, %d Player(s) in Survivor Team"clientg_Survivor );
                    }
                    else
                    {
                        
PrintHintTexti"%N has Died, %d Player(s) in Survivor Team"clientg_Survivor );
                    }
                }
            }
        }
    }
}

stock bool:IsTeamSurvivorclient )
{
    if ( 
client || client MaxClients ) return false;
    if ( !
IsClientConnectedclient )) return false;
    if ( !
IsClientInGameclient )) return false;
    if ( 
GetClientTeamclient ) != ) return false;
    return 
true;

if a survivor dies it works perfect. but it shows always a die infected: "Boomer died. 1 Survivors left".
noxman 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 23:59.


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