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

sv_steamgroup_exclusive question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Balloons
Member
Join Date: Feb 2020
Old 12-16-2022 , 22:21   sv_steamgroup_exclusive question
Reply With Quote #1

I'm looking for a way to reinforce sv_steamgroup_exclusive 1 whenever my server is empty.

My server.cfg normally has it set to 1, but I have it change to 0 whenever a player from the Steam group joins using first_player_spawn HookEvent. I was wondering if there was an automated way to change it back to 1 as soon as the last player disconnects if possible. I have looked into timers with the player_disconnect event while counting human players but that did not seem to work.
Balloons is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 12-16-2022 , 23:29   Re: sv_steamgroup_exclusive question
Reply With Quote #2

You never mentioned the game.
Maxximou5 is offline
Balloons
Member
Join Date: Feb 2020
Old 12-16-2022 , 23:47   Re: sv_steamgroup_exclusive question
Reply With Quote #3

Sorry, forgot to mention that it was Left 4 Dead 2.

Here is my attempt at a plugin that did not work
PHP Code:
public OnPluginStart()
{
    
HookEvent("player_disconnect"PlayerDisconnect_Event);
}


public 
Action PlayerDisconnect_Event(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    
    if (!
IsFakeClient(client) && GetClientTeam(client) == 2)
    {
        
CreateTimer(3.0CheckPlayersTimer);
    }
    
    return 
Plugin_Continue;
}

public 
Action CheckPlayersTimer(Handle timer)
{
    
CheckPlayers();
    
    return 
Plugin_Continue;
}

public 
void CheckPlayers()
{
    if (
GetHumanPlayers() == 0)
    {
        
ServerCommand("sv_steamgroup_exclusive 1");
    }
}

int GetHumanPlayers()
{
    
int count;
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && !IsFakeClient(i))
        {
            
count++;
        }
    }
    
    return 
count;


Last edited by Balloons; 12-16-2022 at 23:59. Reason: Added my attempt
Balloons is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 12-17-2022 , 01:58   Re: sv_steamgroup_exclusive question
Reply With Quote #4

You should probably remove: GetClientTeam(client) == 2

Is your servers hibernation off? sv_hibernate_when_empty 0 or whats the value of sv_hibernate_postgame_delay?

Would recommend debug printing to see if CheckPlayers ever gets to the ServerCommand part.



Well instead of that try this:

I recently had to swap "player_disconnect" event with "OnClientDisconnect_Post" since it appeared to not always trigger.

Try this, I've modified it from Vote Mode plugins recent update that resets mode when all players disconnect:

PHP Code:
Handle g_hTimerResetMap;

public 
void OnClientDisconnect_Post(int client)
{
    for( 
int i 1<= MaxClientsi++ )
    {
        if( 
IsClientConnected(i) && !IsFakeClient(i) )
        {
            return;
        }
    }

    
delete g_hTimerResetMap;
    
g_hTimerResetMap CreateTimer(1.0TimerReset);
}

Action TimerReset(Handle timer)
{
    
g_hTimerResetMap null;

    for( 
int i 1<= MaxClientsi++ )
    {
        if( 
IsClientConnected(i) && !IsFakeClient(i) )
        {
            return 
Plugin_Continue;
        }
    }

    
ServerCommand("sv_steamgroup_exclusive 1");

    return 
Plugin_Continue;

__________________

Last edited by Silvers; 12-17-2022 at 01:59.
Silvers is offline
Balloons
Member
Join Date: Feb 2020
Old 12-17-2022 , 03:03   Re: sv_steamgroup_exclusive question
Reply With Quote #5

Quote:
Originally Posted by Silvers View Post
You should probably remove: GetClientTeam(client) == 2

Is your servers hibernation off? sv_hibernate_when_empty 0 or whats the value of sv_hibernate_postgame_delay?

Would recommend debug printing to see if CheckPlayers ever gets to the ServerCommand part.



Well instead of that try this:

I recently had to swap "player_disconnect" event with "OnClientDisconnect_Post" since it appeared to not always trigger.

Try this, I've modified it from Vote Mode plugins recent update that resets mode when all players disconnect:

...
It appears that this did the trick.
Only thing was it only seemed to have worked with sv_hibernate_when_empty is set to 0. I tried using different values for sv_hibernate_postgame_delay with sv_hibernate_when_empty at 1 but no luck.

Thank you Silvers!
Balloons 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 22:42.


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