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

[CSGO] Set server password


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alienagat
Junior Member
Join Date: Aug 2017
Old 08-29-2017 , 10:57   [CSGO] Set server password
Reply With Quote #1

Hi all,

I search to be able to set a server password (ex : sv_password "test"), while players are connected

(i know it's not possible with CSGO), so for this i try, to set a .cfg file (password.cfg) to execute on the server with rcon
i edit the file with this :

sm_kick @all
sv_password "test"

after executing this cfg, every players are kicked but the password is not set (i think two command are too fast to execute because it works when i execute the cfg since the console while the server is empty).

Also i try this commande in console '_restart -sv_password "test" ', the server restart correctly but with no password set. (the sv_password "" line was delete from server.cfg).

Do you know if it's possible to create a sourcemod plugin to put a delay between the command to kick all the players and the command to set a password ?

Ifelse create a plugin to restart the server with a password ?

Thank you all

P.S : i m sorry if my english is not correct, i try my best
alienagat is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 08-29-2017 , 11:10   Re: [CSGO] Set server password
Reply With Quote #2

(in launch script!)
It's +sv_password test
Because it is cvar, console variable.
SRCDS start up parameters use -minus

You can also
cfg/autoexec.cfg
Add password in that config and reboot server
__________________
Do not Private Message @me

Last edited by Bacardi; 08-29-2017 at 11:13.
Bacardi is offline
alienagat
Junior Member
Join Date: Aug 2017
Old 08-29-2017 , 11:28   Re: [CSGO] Set server password
Reply With Quote #3

Thank you Bacardi for you answer,

I try with '_restart +sv_password test', the server restart with no password. I don't want edit autoexec because i search to give admins on the sourcemod menu the possibility to switch from the menu to set a password or a password NULL

For exemple with 2 cfg files

--------------------

password.cfg

_restart +sv_password test

---------------------

nopassword.cfg

_restart

---------------------

Because i don't want give the rcon password to the admins
alienagat is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 08-29-2017 , 11:53   Re: [CSGO] Set server password
Reply With Quote #4

Server command _restart is same as quit. It shutdown server.

Server reboot usually with "Watchdog", it follow when SRCDS shutdown, it launch back alive.
__________________
Do not Private Message @me
Bacardi is offline
alienagat
Junior Member
Join Date: Aug 2017
Old 08-29-2017 , 12:03   Re: [CSGO] Set server password
Reply With Quote #5

I see

thank you for your help
alienagat is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 08-29-2017 , 12:08   Re: [CSGO] Set server password
Reply With Quote #6

Have you try ? Does it work ?

sm_cvar sv_password test
__________________
Do not Private Message @me
Bacardi is offline
alienagat
Junior Member
Join Date: Aug 2017
Old 08-29-2017 , 12:20   Re: [CSGO] Set server password
Reply With Quote #7

i tried it but doesn't work if server is not empty
alienagat is offline
alienagat
Junior Member
Join Date: Aug 2017
Old 08-29-2017 , 12:28   Re: [CSGO] Set server password
Reply With Quote #8

For more information, i have this message in console :

[SM] Changed cvar "sv_password" to "test".
08/29/2017 - 18:257: [basecommands.smx] "Console<0>" changed cvar (cvar "sv_password") (value "test")
Cannot require sv_password when server is already reserved or clients connected!

but the command work when server is empty, that is why i tried before by kick all players with a .cfg
alienagat is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 08-29-2017 , 15:32   Re: [CSGO] Set server password
Reply With Quote #9

have to say, this is dam tricky in csgo.
Need all players and perhaps all kind bots to be out server, then need wait about 45sec 2 minutes that this came up

-> Reservation cookie 0: reason reserved(yes), clients(no), reservationexpires(
0.00)

then you can set password... really stupid method in this game
__________________
Do not Private Message @me

Last edited by Bacardi; 08-29-2017 at 15:41.
Bacardi is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 08-29-2017 , 18:51   Re: [CSGO] Set server password
Reply With Quote #10

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);

__________________
Do not Private Message @me

Last edited by Bacardi; 08-29-2017 at 18:55.
Bacardi 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 20:29.


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