[Advanced] Server Lock & Unlock System

Started by Saiyan Attack, Aug 28, 2017, 08:59 AM

Previous topic - Next topic

Saiyan Attack

Hello Everyone !!

Today I'm going to release a snippet called server lock & unlock system ... with this snippet you can get server password & detect that your server is lock & unlock ... This lock system will only worked when you use _Server.Password ... It's mean you guys just forget about SetPassword and starting using _Server.Password ... cause the ability to get lock pass & stats is in _Server.Password ... why do i tell that becoz some newbies doesn't know how to scripting ... if newbies want to use this so it will definitely know about how it work ... so lets get start ...

_Server <- {
lock = false,
password = null

function Password(pass)
{
if(pass!="") {
SetPassword(pass);
password=pass;
lock=true;
}
else {
SetPassword(pass);
password=pass;
lock=false;
}
}

function GetLock() { return lock; }
function GetPassword() { return password; }
}

function onScriptLoad()
{
print("Server Lock & Unlock System Loaded!");
}
function onPlayerCommand( player, command, text )
{
local cmd = command.tolower();
if ((cmd == "svr")||(cmd == "server"))
{
if (!text) MessagePlayer("[syntax] /"+cmd+" <stats/pass/lock/unlock>",player);
else {
local stat = GetTok(text," ", 1).tolower();
if ((stat == "stats")||(stat == "status")) {
if(_Server.GetLock() == true) MessagePlayer("This Server Are Locked",player);
else MessagePlayer("Server Is Open For Public Use!",player);
}
else if ((stat == "pass")||(stat=="password")) {
if(_Server.GetLock() == false) MessagePlayer("Server Is Running Without Password Protection !!",player);
else MessagePlayer("Server Password Is:[ "+_Server.GetPassword()+" ]",player);
}
else if ( stat == "lock" ) {
local password = GetTok(text, " ", 2);
if(!password) MessagePlayer("[syntax] /"+cmd+" <lock> <enter your password>",player);
else if (_Server.GetLock()==true) MessagePlayer("Server Is Already Locked!",player);
else {
_Server.Password(password);
PrivMessage(player,"Server Is Lock With Password: "+_Server.GetPassword()+", Status: "+_Server.GetLock());
}
}
else if ( stat == "unlock" ) {
if(_Server.GetLock()==false) MessagePlayer("Server Is Already Unlocked !!",player);
else {
_Server.Password("");
PrivMessage(player,"Server Is Now Open For Public Use!");
}
}
else MessagePlayer("[syntax] /"+cmd+" <stats/pass/lock/unlock>",player);
}
}
}
function GetTok(string, separator, n, ...)
{
local m = vargv.len() > 0 ? vargv[0] : n,
  tokenized = split(string, separator),
  text = "";

if (n > tokenized.len() || n < 1) return null;
for (; n <= m; n++)
{
text += text == "" ? tokenized[n-1] : separator + tokenized[n-1];
}
return text;
}

function NumTok(string, separator)
{
local tokenized = split(string, separator);
return tokenized.len();
}

credits :- [KoF]Killer

Mr.Dip 2020

have you tested the command before posting it?

SHy^

Quote from: Mr.Dip 2020 on Dec 29, 2020, 06:05 PMhave you tested the command before posting it?
Have you seen when the topic was made and thought for a second before bumping?