AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved count mobs l4d (https://forums.alliedmods.net/showthread.php?t=316377)

Alexmy 05-20-2019 11:59

count mobs l4d
 
Hi, I'm trying to count the number of live mobs. But I do not like it. Since Mobs does not have m_zombieClass.

PHP Code:

int IsPanicMobsAlive()
{
    
int count 0;
    for (
int i 1<= MaxClientsi++)
        if (
IsClientConnected(i) && IsClientInGame(i) && IsFakeClient(i) && GetEntProp(iProp_Send"m_zombieClass") == 0count++;
    return 
count;


Does anyone have an option how to count live mobs

farawayf 05-20-2019 12:48

Re: count mobs l4d
 
i dont know why you trying to check m_zombieClass on bots, because you wrote that you want to count all.
would not it be easier to do like this ?

PHP Code:


int IsPanicMobsAlive
() 

    
int count 0
    for (
int i 1<= MaxClientsi++) 
        if (
IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i) && IsFakeClient(i) && GetClientTeam(i) == 3count++; 
    return 
count



Alexmy 05-20-2019 12:57

Re: count mobs l4d
 
Quote:

Originally Posted by farawayf (Post 2652410)
i dont know why you trying to check m_zombieClass on bots, because you wrote that you want to count all.
would not it be easier to do like this ?

PHP Code:


int IsPanicMobsAlive
() 

    
int count 0
    for (
int i 1<= MaxClientsi++) 
        if (
IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i) && IsFakeClient(i) && GetClientTeam(i) == 3count++; 
    return 
count



If use GetClientTeam(i) == 3. Mobs will be considered this way.?

farawayf 05-20-2019 13:21

Re: count mobs l4d
 
as far as i know "3" is a infected team, so i think yes it will.

Alexmy 05-20-2019 13:49

Re: count mobs l4d
 
Quote:

Originally Posted by farawayf (Post 2652416)
as far as i know "3" is a infected team, so i think yes it will.

No, it doesn't work, I tried the code does not work.

PHP Code:

if(IsPanicMobsAlive() >= 5)        
        {
            
PrintHintText(client"Да Подожди Ты %N Запускать Генератор, Мобов много: %s."clientIsPanicMobsAlive());
            return 
Plugin_Handled;
        }
    }
    return 
Plugin_Continue;


int IsPanicMobsAlive() 

    
int count 0
    for (
int i 1<= MaxClientsi++) 
        if (
IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i) && IsFakeClient(i) && GetClientTeam(i) == 3count++; 
    return 
count



Silvers 05-20-2019 13:56

Re: count mobs l4d
 
What do you mean "Mobs"? Common Infected? They are not client entities like Special Infected which use m_zombieClass. You want to count common infected during a panic event? Then you have to find and count the number of "infected" classes.

Alexmy 05-20-2019 14:04

Re: count mobs l4d
 
Quote:

Originally Posted by Silvers (Post 2652419)
What do you mean "Mobs"? Common Infected? They are not client entities like Special Infected which use m_zombieClass. You want to count common infected during a panic event? Then you have to find and count the number of "infected" classes.

I'm interested in Common Infected. How can I do it?

Silvers 05-20-2019 14:07

Re: count mobs l4d
 
PHP Code:

int common = -1;
while( (
common FindEntityByClassname(common"infected")) != INVALID_ENT_REFERENCE )
    
numCommon++; 


Alexmy 05-20-2019 16:56

Re: count mobs l4d
 
Quote:

Originally Posted by Silvers (Post 2652422)
PHP Code:

int common = -1;
while( (
common FindEntityByClassname(common"infected")) != INVALID_ENT_REFERENCE )
    
numCommon++; 


Thank you very much, it really works. =)

canadianjeff 09-27-2020 12:10

Re: count mobs l4d
 
is there a plugin that counts common infected?


All times are GMT -4. The time now is 12:13.

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