AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   sv_steamgroup_exclusive question (https://forums.alliedmods.net/showthread.php?t=340913)

Balloons 12-16-2022 22:21

sv_steamgroup_exclusive question
 
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.

Maxximou5 12-16-2022 23:29

Re: sv_steamgroup_exclusive question
 
You never mentioned the game.

Balloons 12-16-2022 23:47

Re: sv_steamgroup_exclusive question
 
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;



Silvers 12-17-2022 01:58

Re: sv_steamgroup_exclusive question
 
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;



Balloons 12-17-2022 03:03

Re: sv_steamgroup_exclusive question
 
Quote:

Originally Posted by Silvers (Post 2795419)
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!


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

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