AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get_playersnum exclude HLTV (https://forums.alliedmods.net/showthread.php?t=129096)

sparkey 06-08-2010 18:13

get_playersnum exclude HLTV
 
Hi there,

Is there any way to exclude a hltv from being counted in the get_playersnum function or a similar function. Today i have a piece of coding looking kinda like this:

Code:

public client_disconnect(id)
{
    if (get_playersnum(1) <= 1)
    {
        remove_task(TASKID_RESET);
        reset();
    }
}

When all of the players are disconnected it stops the reset function.
My dilemma now is that it is ofcource counting the HLTV as a player and therefore it does not remove the task.

I know i can change it to if (get_playersnum(1) <= 2) but then everything depends on the HLTV being connected which it might not be all the time.

I'm very thankfull for your answers. Thx!

RedRobster 06-08-2010 18:31

Re: get_playersnum exclude HLTV
 
PHP Code:

public client_disconnect(id)
{
    new 
PlayerCount
    
new iPlayers[32], iNum
    get_players
(iPlayers,iNum)
    for(new 
iiNumi++)
    {
        new 
tempid iPlayers[i]
        if(!
is_user_bot(tempid) && is_user_connected(tempid))
            
PlayerCount++
    }
    if(
PlayerCount == 0)
    {
        
remove_task(TASKID_RESET)
        
reset()
    }


That should work.

fysiks 06-08-2010 19:33

Re: get_playersnum exclude HLTV
 
PHP Code:

new iPlayers[32], iPlayerCount
get_players
(iPlayersiPlayerCount"h")

if( 
iPlayerCount ... 


Kreation 06-09-2010 00:14

Re: get_playersnum exclude HLTV
 
@Red:
PHP Code:

if(!is_user_bot(tempid) && !is_user_hltv(tempid) && is_user_connected(tempid)) 


RedRobster 06-09-2010 00:16

Re: get_playersnum exclude HLTV
 
Quote:

Originally Posted by Kreation (Post 1203828)
@Red:
PHP Code:

if(!is_user_bot(tempid) && !is_user_hltv(tempid) && is_user_connected(tempid)) 


Did not know that there was a is_user_hltv(id) . Thanks :D

Kreation 06-09-2010 00:19

Re: get_playersnum exclude HLTV
 
Useful.

:D


All times are GMT -4. The time now is 05:19.

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