Raised This Month: $32 Target: $400
 8% 

[Request] Something that can execute commands when server becomes empty


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
yuv41
Member
Join Date: Jan 2020
Old 06-07-2020 , 03:20   [Request] Something that can execute commands when server becomes empty
Reply With Quote #1

I need a plugin that executes a list of commands / a .cfg once the server becomes empty if it’s possible.
I’ve tried searching but didn’t find a thing. If there’s someone who has something like this please help
I also tried using the cronjobs plugin for this but I couldn’t find a trigger that marks the server as empty
Thanks a lot

Last edited by yuv41; 06-07-2020 at 03:24.
yuv41 is offline
SSheriFF
AlliedModders Donor
Join Date: May 2020
Location: Israel
Old 06-07-2020 , 06:03   Re: [Request] Something that can execute commands when server becomes empty
Reply With Quote #2

PHP Code:
#pragma semicolon 1

#define DEBUG
#pragma tabsize 0
#define PLUGIN_AUTHOR ""
#define PLUGIN_VERSION "0.00"

#include <sourcemod>
#include <sdktools>

int PlayerAmount;
public 
Plugin myinfo 
{
    
name "",
    
author PLUGIN_AUTHOR,
    
description "",
    
version PLUGIN_VERSION,
    
url ""
};

public 
void OnPluginStart()
{
     
PlayerAmount 0;
}

public 
void OnClientDisconnect(int client)
{
    
PlayerAmount--;
    if(
PlayerAmount==0)
    {
        if(
FileExists("/cfg/server_empty.cfg"))
            
ServerCommand("exec server_empty.cfg");
        else
        
LogError("server_empty.cfg not found.");
    }        
}
public 
OnClientPostAdminCheck(int client)
{
    
PlayerAmount++;

__________________
Taking small private requests (Free) and big private requests (Paid).
Contact me via Discord: WilDick#1524

My Plugins:

Last edited by SSheriFF; 06-07-2020 at 12:06.
SSheriFF is offline
yuv41
Member
Join Date: Jan 2020
Old 06-07-2020 , 08:23   Re: [Request] Something that can execute commands when server becomes empty
Reply With Quote #3

Quote:
Originally Posted by SSheriFF View Post
PHP Code:
#pragma semicolon 1

#define DEBUG
#pragma tabsize 0
#define PLUGIN_AUTHOR ""
#define PLUGIN_VERSION "0.00"

#include <sourcemod>
#include <sdktools>

int PlayerAmount;
public 
Plugin myinfo 
{
    
name "",
    
author PLUGIN_AUTHOR,
    
description "",
    
version PLUGIN_VERSION,
    
url ""
};

public 
void OnPluginStart()
{
     
PlayerAmount 0;
}

public 
void OnClientDisconnect(int client)
{
    
PlayerAmount--;
    if(
PlayerAmount==0)
    {
        if(
FileExists("cfg/server_empty.cfg"))    
            
ServerCommand("exec server_empty.cfg");
        else
        
LogError("server_empty.cfg not found.");
    }        
}
public 
OnClientPostAdminCheck(int client)
{
    
PlayerAmount++;

Thank you, hopefully it works as intended.
yuv41 is offline
yuv41
Member
Join Date: Jan 2020
Old 06-07-2020 , 09:12   Re: [Request] Something that can execute commands when server becomes empty
Reply With Quote #4

Quote:
Originally Posted by SSheriFF View Post
PHP Code:
#pragma semicolon 1

#define DEBUG
#pragma tabsize 0
#define PLUGIN_AUTHOR ""
#define PLUGIN_VERSION "0.00"

#include <sourcemod>
#include <sdktools>

int PlayerAmount;
public 
Plugin myinfo 
{
    
name "",
    
author PLUGIN_AUTHOR,
    
description "",
    
version PLUGIN_VERSION,
    
url ""
};

public 
void OnPluginStart()
{
     
PlayerAmount 0;
}

public 
void OnClientDisconnect(int client)
{
    
PlayerAmount--;
    if(
PlayerAmount==0)
    {
        if(
FileExists("cfg/server_empty.cfg"))    
            
ServerCommand("exec server_empty.cfg");
        else
        
LogError("server_empty.cfg not found.");
    }        
}
public 
OnClientPostAdminCheck(int client)
{
    
PlayerAmount++;

Hi it doesn’t do anything or maybe I’m stoopid?
yuv41 is offline
yuv41
Member
Join Date: Jan 2020
Old 06-07-2020 , 09:31   Re: [Request] Something that can execute commands when server becomes empty
Reply With Quote #5

Never mind I fixed it by adding a “/“ on if(FileExists("/cfg/server_empty.cfg"))
yuv41 is offline
yuv41
Member
Join Date: Jan 2020
Old 06-07-2020 , 13:47   Re: [Request] Something that can execute commands when server becomes empty
Reply With Quote #6

Quote:
Originally Posted by SSheriFF View Post
PHP Code:
#pragma semicolon 1

#define DEBUG
#pragma tabsize 0
#define PLUGIN_AUTHOR ""
#define PLUGIN_VERSION "0.00"

#include <sourcemod>
#include <sdktools>

int PlayerAmount;
public 
Plugin myinfo 
{
    
name "",
    
author PLUGIN_AUTHOR,
    
description "",
    
version PLUGIN_VERSION,
    
url ""
};

public 
void OnPluginStart()
{
     
PlayerAmount 0;
}

public 
void OnClientDisconnect(int client)
{
    
PlayerAmount--;
    if(
PlayerAmount==0)
    {
        if(
FileExists("/cfg/server_empty.cfg"))
            
ServerCommand("exec server_empty.cfg");
        else
        
LogError("server_empty.cfg not found.");
    }        
}
public 
OnClientPostAdminCheck(int client)
{
    
PlayerAmount++;

Hi, after couple of hours I just notified that it crashes the server on map change. The console spams can’t init different functions and just gets the segment failed issue. I’d provide a log but I can’t I’m only on phone
yuv41 is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 06-07-2020 , 15:23   Re: [Request] Something that can execute commands when server becomes empty
Reply With Quote #7

I think "OnClientPostAdminCheck" is bad place for ++, ppl could connect and disconnect before being authed. Use "OnClientConnected" instead.

Crashed maybe because: on map change everyone is disconnected, so it executes the config when it shouldn't. Maybe you have some bad commands/cvars in the config that shouldn't be executed on map change. You would have to hook the change map command(s) because OnMapEnd() happens after all clients are disconnected for map change.
__________________
Silvers is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 06-07-2020 , 15:32   Re: [Request] Something that can execute commands when server becomes empty
Reply With Quote #8

Try this
Attached Files
File Type: sp Get Plugin or Get Source (exec_on_empty.sp - 161 views - 1.2 KB)
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.


Last edited by Franc1sco; 06-07-2020 at 18:05.
Franc1sco is offline
Send a message via MSN to Franc1sco
yuv41
Member
Join Date: Jan 2020
Old 06-07-2020 , 17:42   Re: [Request] Something that can execute commands when server becomes empty
Reply With Quote #9

Quote:
Originally Posted by Franc1sco View Post
Try this
Yes! Thank you works perfectly!
yuv41 is offline
Reply


Thread Tools
Display Modes

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 04:54.


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