|
Member
|
02-10-2018
, 16:09
Re: [CSGO] Set server password
|
#14
|
Quote:
Originally Posted by Bacardi
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(1, buffer, sizeof(buffer));
if(!StrEqual(buffer, "none", false))
{
SetConVarInt(FindConVar("sv_hibernate_postgame_delay"), 0, false, false); // # 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; i <= MaxClients; i++)
{
if(IsClientConnected(i) && !IsFakeClient(i) && !IsClientInKickQueue(i))
{
LogAction(0, i, "sm_sv_password - kick %L", i);
KickClient(i, "[SM] The server is cleared from the players to activate the password.");
}
}
}
Handle pack;
CreateDataTimer(1.0, delay, pack);
WritePackString(pack, buffer);
ResetPack(pack);
return Plugin_Handled;
}
public Action delay(Handle timer, Handle pack)
{
char buffer[30];
ReadPackString(pack, buffer, sizeof(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 ...
|
|
|
|