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

Solved L4D2 Plugin Help Anyone?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ricksfishin
Senior Member
Join Date: Oct 2017
Old 05-25-2018 , 07:04   L4D2 Plugin Help Anyone?
Reply With Quote #1

Can this be fixed? Admin only join when server in test mode/Maintenance if not. Is there a better plugin for this?
PHP Code:
 #include <sourcemod>

#pragma semicolon 1

new Handle:gH_Enabled INVALID_HANDLE;
new 
Handle:gH_KickReason INVALID_HANDLE;
new 
bool:Enabled false;

#define PLUGIN_VERSION "1.4"

public Plugin:myinfo 
{
    
name "Server Maintenance",
    
description "Allows to initiate a server maintenance to allow admins to join only.",
    
author "TimeBomb",
    
version PLUGIN_VERSION,
    
url "http://vgames.co.il/"
}

public 
OnPluginStart()
{
    
gH_Enabled CreateConVar("sm_maintenance_enabled""0""\"Server maintenance\" is enabled?"FCVAR_PLUGIN|FCVAR_REPLICATEDtrue_true1.0);
    
gH_KickReason CreateConVar("sm_maintenance_kick_reason""Hey there {name}, this server is under maintenance and admins are allowed to join only""Kick reason if the plugin is enabled. [Don't add dot at the end, {name} - Player's name.]"FCVAR_PLUGIN|FCVAR_REPLICATEDtrue_true1.0);
    
CreateConVar("sm_maintenance_version"PLUGIN_VERSION"\"Server maintenance\"'s version."FCVAR_NOTIFY|FCVAR_DONTRECORD|FCVAR_PLUGIN|FCVAR_REPLICATED);
    
AutoExecConfig();
    
HookConVarChange(gH_Enabledcvarchange);
}

public 
OnClientPostAdminCheck(client)
{
    new 
String:KickReason[128], String:KickReasonFormat[128], String:Name[MAX_NAME_LENGTH];
    
GetClientName(clientNameMAX_NAME_LENGTH);
    
GetConVarString(gH_KickReasonKickReasonsizeof(KickReason));
    
ReplaceString(KickReasonFormat128"{name}"Namefalse);
    
Format(KickReasonFormatsizeof(KickReasonFormat), "%s"KickReasonclient);
    if(
Enabled && !CheckCommandAccess(client"maintenance_allowed"ADMFLAG_GENERIC))
    {
        
KickClient(client"%s"KickReasonFormatclient);
    }
}

public 
cvarchange(Handle:cvar, const String:oldVal[], const  String:newVal[])
{
    
Enabled GetConVarBool(cvar);


Last edited by ricksfishin; 06-01-2018 at 13:12.
ricksfishin is offline
ricksfishin
Senior Member
Join Date: Oct 2017
Old 05-31-2018 , 01:22   Re: L4D2 Plugin Help
Reply With Quote #2

Anyone? Or do i just keep setting server to 1 when testing and hope i get in first?
ricksfishin is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 05-31-2018 , 02:23   Re: L4D2 Plugin Help Anyone?
Reply With Quote #3

You need to give a better explanation. Can't even figure out what you asking.
__________________
Spirit_12 is offline
ricksfishin
Senior Member
Join Date: Oct 2017
Old 05-31-2018 , 08:25   Re: L4D2 Plugin Help Anyone?
Reply With Quote #4

Have 8 slot server. When i need to do testing on a plugin. The above plugin when used is suppose to block non admins from joining if i am the only one on server 1/8 server. But does not work and throws no error's So i have to set my server slots to 0/1 Then try to get on server before anyone else just to do testing on a plugin. Looking for alternative if above plugin is not fixable Thanks

Last edited by ricksfishin; 05-31-2018 at 09:15.
ricksfishin is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 05-31-2018 , 10:22   Re: L4D2 Plugin Help Anyone?
Reply With Quote #5

Did you set sm_maintenance_enabled to 1? Also, what is up with the slashes in the ConVar descriptions?

EDIT: With the KickClient and formatting, why are you passing client as a last parameter?

EDIT 2: Here is what I did, untested but should work. Optimized code and accounted for ConVar change.
PHP Code:
ConVar g_hConVars[2];

public 
void OnPluginStart()
{
    
CreateConVar("sm_maintenance_version""1.0""Plugin's version."FCVAR_NOTIFY|FCVAR_DONTRECORD);
    
g_hConVars[0] = CreateConVar("sm_maintenance_enable""0""Enable/disable the plugin."_true0.0true1.0);
    
g_hConVars[1] = CreateConVar("sm_maintenance_reason""{NAME}, the server is currently undergoing maintenance.""Kick reason.");
    
g_hConVars[0].AddChangeHook(ConVarUpdate);
    
AutoExecConfig();
}

public 
void ConVarUpdate(ConVar cvar, const char[] oldValue, const char[] newValue)
{
    if (
g_hConVars[0].BoolValue)
        for (
int i 1<= MaxClientsi++)
            if (
IsClientInGame(i))
                
OnClientPostAdminCheck(i);
}

public 
void OnClientPostAdminCheck(int client)
{
    if (
g_hConVars[0].BoolValue && !CheckCommandAccess(client"maintenance_allowed"ADMFLAG_GENERIC))
    {
        
char name[32], reason[256];
        
GetClientName(clientnamesizeof(name));
        
g_hConVars[1].GetString(reasonsizeof(reason));
        
ReplaceString(reasonsizeof(reason), "{NAME}"name);
        
KickClient(clientreason);
    }


Last edited by ThatKidWhoGames; 05-31-2018 at 10:44.
ThatKidWhoGames is offline
ricksfishin
Senior Member
Join Date: Oct 2017
Old 05-31-2018 , 12:21   Re: L4D2 Plugin Help Anyone?
Reply With Quote #6

ThatKidWhoGames
sm_maintenance_enabled to 1? i did have it enabled
With the KickClient and formatting, why are you passing client as a last parameter? this plugin was asked by friend to see if someone could fix it or not.
-------------------------------------------------------------------------------------------------------------------

Tested works has these warnings
plugin.sp(53) : warning 204: symbol is assigned a value that is never used: "Enabled"
plugin.sp(5) : warning 203: symbol is never used: "gH_Enabled"
plugin.sp(6) : warning 203: symbol is never used: "gH_KickReason"
Warnings are fine no errors in log. While on first join in game the 3 bot's that are normally there are not seen and are constantly flashing. showing not showing. And if you happen to go idle and type !join you die and it says You have already played on survivor team you will spawn dead. This is in coop Then map restarts. Did not do this with original plugin code. Thanks

Last edited by ricksfishin; 05-31-2018 at 12:27.
ricksfishin is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 05-31-2018 , 20:51   Re: L4D2 Plugin Help Anyone?
Reply With Quote #7

You need to put the correct code in the plugin to remove warnings. The code given to you by ThatKidWhoGames was a separate plugin not an addition. Remove all lines from your file and just put this code.

PHP Code:
#include <sourcemod>

ConVar g_hConVars[2];

public 
void OnPluginStart()
{
    
CreateConVar("sm_maintenance_version""1.0""Plugin's version."FCVAR_NOTIFY|FCVAR_DONTRECORD);
    
g_hConVars[0] = CreateConVar("sm_maintenance_enable""0""Enable/disable the plugin."_true0.0true1.0);
    
g_hConVars[1] = CreateConVar("sm_maintenance_reason""{NAME}, the server is currently undergoing maintenance.""Kick reason.");
    
g_hConVars[0].AddChangeHook(ConVarUpdate);
    
AutoExecConfig();
}

public 
void ConVarUpdate(ConVar cvar, const char[] oldValue, const char[] newValue)
{
    if (
g_hConVars[0].BoolValue)
        for (
int i 1<= MaxClientsi++)
            if (
IsClientInGame(i))
                
OnClientPostAdminCheck(i);
}

public 
void OnClientPostAdminCheck(int client)
{
    if (
g_hConVars[0].BoolValue && !CheckCommandAccess(client"maintenance_allowed"ADMFLAG_GENERIC))
    {
        
char name[32], reason[256];
        
GetClientName(clientnamesizeof(name));
        
g_hConVars[1].GetString(reasonsizeof(reason));
        
ReplaceString(reasonsizeof(reason), "{NAME}"name);
        
KickClient(clientreason);
    }

The other errors that you just mentioned have nothing to do with this plugin. My best bet would be your team management plugin.
__________________
Spirit_12 is offline
oceanyss
Member
Join Date: Jan 2012
Old 05-31-2018 , 21:58   Re: L4D2 Plugin Help Anyone?
Reply With Quote #8

Why not just set a password temporarily for the server in the cfg file instead of a plugin?
oceanyss is offline
ricksfishin
Senior Member
Join Date: Oct 2017
Old 06-01-2018 , 00:02   Re: L4D2 Plugin Help Anyone?
Reply With Quote #9

Thanks Spirit_12 it works But i can't spawn any tanks spitters etc I can spawn common uncommon... And if i go idle for a moment and rejoin !join i die and map restarts. But other than that it works.

I may go password route thanks oceanyss.

Last edited by ricksfishin; 06-01-2018 at 00:05.
ricksfishin is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 06-01-2018 , 00:18   Re: L4D2 Plugin Help Anyone?
Reply With Quote #10

PHP Code:
public void OnClientPostAdminCheck(int client)
{
    if( 
IsFakeClient(client) ) return; 
__________________
Silvers 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 17:23.


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