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

Solved How to check the players on the teams ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mewbie222
Senior Member
Join Date: May 2018
Old 06-21-2018 , 05:25   How to check the players on the teams ?
Reply With Quote #1

It is necessary to make that there was a check of number of players in different teams . For example, if one team has no players or he left the server (disconnect), then 1 player from the opposite team to throw over another where there are no players. Also this test would produce,and when you disconnect , and when "the withdrawal of the observers.". Could help with this "piece" of code ! It is necessary for the plugins Hide&Seek, to make it clearer what it is necessary.
Sorry for bad English.

P.S. this close topic, Thanks mug1wara.

Last edited by mewbie222; 07-02-2018 at 14:34. Reason: this close topic
mewbie222 is offline
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Old 06-21-2018 , 10:35   Re: How to check the players on the teams ?
Reply With Quote #2

So basically a teambalancer? You could use this (not tested):
PHP Code:
#include <sourcemod>
#include <sdktools>

public void OnPluginStart()
{
    
HookEvent("player_disconnect"Event_DisconnectEventHookMode_Post);
}

public 
Action Event_Disconnect(Event hEvent, const char[] sNamebool bDontBroadcast)
{
    if (
GetTeamClientCount(3) < GetTeamClientCount(2))
    {
        for (
int i 1<= MaxClientsi++)
        {
            
int iClient GetRandomInt(1i);
            
            if (
GetClientTeam(iClient) == 2)
                
ChangeClientTeam(iClient3);
        }
    }
    
    else if (
GetTeamClientCount(2) < GetTeamClientCount(3)
    {
        for (
int i 1<= MaxClientsi++)
        {
            
int iClient GetRandomInt(1i);
            
            if (
GetClientTeam(iClient) == 3)
                
ChangeClientTeam(iClient2);
        }
    }

    else
    {
        return 
Plugin_Handled;
    }

    return 
Plugin_Continue;


Last edited by mug1wara; 06-21-2018 at 10:36.
mug1wara is offline
mewbie222
Senior Member
Join Date: May 2018
Old 06-21-2018 , 11:02   Re: How to check the players on the teams ?
Reply With Quote #3

Quote:
Originally Posted by mug1wara View Post
So basically a teambalancer? You could use this (not tested):
in principle , Yes, but it to trigger when there's nobody on the same team .
And the in my plugin hiding , is beginning to seek 1 player ,and other players lurk. Now, if he will go to spectra or shuts down , the plugin seems to work but without a seeker .. That's why I would like to add this plugin . And then the original plugin I'm afraid to even touch it )
Perhaps it would be a bit more correct, from the description above :
PHP Code:
#include <sourcemod>
#include <sdktools>

public void OnPluginStart()
{
    
HookEvent("player_disconnect"Event_DisconnectEventHookMode_Post);
}

public 
Action Event_Disconnect(Event hEvent, const char[] sNamebool bDontBroadcast)
{
    if (
GetTeamClientCount(3) == )
    {
        for (
int i 1<= MaxClientsi++)
        {
            
int iClient GetRandomInt(1i);
            
            if (
GetClientTeam(iClient) == 2)
                
ChangeClientTeam(iClient3);
        }
    }
    
    else
    {
        return 
Plugin_Handled;
    }

    return 
Plugin_Continue;

And this line , probably that's the way to do that is to check more than 2 players , where you need to flip the player .
PHP Code:
if (GetClientTeam(iClient) == 2
replace:
PHP Code:
if (GetClientTeam(iClient) == 2&&iClient >
So I wrote right and changed a little bit ? It's in Sourcemod noob ..
Can say still learning, that is something I know quite a few.

thank you, a little later I will check and write what the result is.

p.s.Sorry for bad English

Last edited by mewbie222; 06-21-2018 at 13:34.
mewbie222 is offline
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Old 06-21-2018 , 13:07   Re: How to check the players on the teams ?
Reply With Quote #4

uuhm?
mug1wara is offline
mewbie222
Senior Member
Join Date: May 2018
Old 06-21-2018 , 13:31   Re: How to check the players on the teams ?
Reply With Quote #5

Quote:
Originally Posted by mug1wara View Post
uuhm?
Is this a converted version of yours, correctly written?
Quote:
And the in my plugin hiding , is beginning to seek 1 player ,and other players lurk. Now, if he will go to spectra or shuts down , the plugin seems to work but without a seeker .. That's why I would like to add this plugin . And then the original plugin I'm afraid to even touch it )
In order for the plugin to work correctly and without errors?

oh, I wrote something, I feel that this is all wrong )

Sorry for bad English

Last edited by mewbie222; 06-21-2018 at 13:59.
mewbie222 is offline
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Old 06-21-2018 , 13:43   Re: How to check the players on the teams ?
Reply With Quote #6

It's not a teambalancer, let's get that clear. Forget the code I sent. It's quite difficult to understand what you want, I'm sorry.
mug1wara is offline
mewbie222
Senior Member
Join Date: May 2018
Old 06-21-2018 , 14:02   Re: How to check the players on the teams ?
Reply With Quote #7

Perhaps that's how it should be done, that's how I wrote the code correctly


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

public void OnPluginStart()
{
    
HookEvent("player_disconnect"Event_DisconnectEventHookMode_Post);
}
public 
Action Event_Disconnect(Event hEvent, const char[] sNamebool bDontBroadcast)
{
    if (
GetTeamClientCount(3) == &&GetTeamClientCount(2) >1)
    {
        for (
int i 1<= MaxClientsi++)
        {
            
int iClient GetRandomInt(1i);
            
            if (
GetClientTeam(iClient) == )  
                
ChangeClientTeam(iClient3);
        }
    }

    return 
Plugin_Continue;

that is , if the team "3" zero(0) players , and for the team "2" > 2 players, then "2" teams, threw 1 player randomly.
(I need, if I had no player, then only one player threw me from another. That's what I need . Sorry, it's also difficult for me to understand English and write on it.)
I wanted to ask , did I write it right ?

And this is something like a teambalance, but only when there is no one in one of the teams.

And so anyway thanks for the help with the code.

By the way, I have found the complete code in the source of Hide-and-seek , he below . Strange why he doesn't want to work ...
MinPlayers=2
PHP Code:
public OnClientDisconnect(iClient)
{
    if (
g_hInfoPanelTimer[iClient] != INVALID_HANDLE)
    {
        
KillTimer(g_hInfoPanelTimer[iClient]);
    }

    if (
g_bModRunning && g_bRoundActive)
    {
        if (
GetTeamClientCount(Team_Seekers) == 0)
        {
            if (
GetTeamClientCount(Team_Hiders) >= GetConVarInt(g_ConVar[MinPlayers]))
            {
                
SelectSeeker();

                
SetPlayerState(g_iSeekerPlayerState_ObserverMode);
                
ChangeClientTeam(g_iSeekerTeam_Seekers);

                
PrintHintText(g_iSeeker"You're now the seeker!");
                
PrintToChatAll("%s Player %N is now the seeker."HIDENSEEK_PREFIXg_iSeeker);
            }
            else
            {
                
RestartRound();
            }
        }
        else
        {
            
CheckWin();
        }
    }

that is , if the player left the server=disconnected zero emotions, the plugin for some reason does not want this code to work out .

add
do you need hookevent for this function OnClientDisconnect, and then something in the cookies can not find it, maybe because of this and does not want to work this part of the code ?

Last edited by mewbie222; 06-23-2018 at 16:40.
mewbie222 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 09:05.


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