View Single Post
controlsuz123
Member
Join Date: Nov 2009
Old 02-10-2018 , 16:09   Re: [CSGO] Set server password
Reply With Quote #14

Quote:
Originally Posted by Bacardi View Post
CSGO only


Here you go.
This is only server command. It work from cfg file or using sm_rcon or rcon or server console input.
Or can be set up in admin menu custom.

For remove password, same way as sv_password "none"
sm_sv_password "none"

Setting password
sm_sv_password "abcdef"
this change cvar sv_hibernate_postgame_delay to 0 and kick all connected players.
1 second later password has set by given argument.
Also logging kicks and password inputs through sm_sv_password command.


https://www.sourcemod.net/compiler.php

PHP Code:


public void OnPluginStart()
{
    
RegServerCmd("sm_sv_password"sm_sv_password"Set server password");
}

public 
Action sm_sv_password(int args)
{

    if(
args 1)
    {
        
ReplyToCommand(0"Set a password or to remove password use \"none\"");
        return 
Plugin_Handled;
    }

    
char buffer[30];
    
GetCmdArg(1buffersizeof(buffer));

    if(!
StrEqual(buffer"none"false))
    {

        
SetConVarInt(FindConVar("sv_hibernate_postgame_delay"), 0falsefalse); // # of seconds to wait after final client leaves before hibernating.
        //-> Reservation cookie 0:  reason reserved(yes), clients(no), reservationexpires(0.00)

        
for(int i 1<= MaxClientsi++)
        {
            if(
IsClientConnected(i) && !IsFakeClient(i) && !IsClientInKickQueue(i))
            {
                
LogAction(0i"sm_sv_password - kick %L"i);
                
KickClient(i"[SM] The server is cleared from the players to activate the password.");
            }
        }
    }

    
Handle pack;
    
CreateDataTimer(1.0delaypack);
    
WritePackString(packbuffer);
    
ResetPack(pack);
    
    return 
Plugin_Handled;
}

public 
Action delay(Handle timerHandle pack)
{
    
char buffer[30];
    
ReadPackString(packbuffersizeof(buffer));

    
LogMessage("sm_sv_password - setting server password to \"%s\""buffer);

    
SetConVarString(FindConVar("sv_password"), buffer);

hi bacardi, it's doesn't work anymore, could u fix it ...
controlsuz123 is offline