if not Authentification then
Authentification=AdvancedPlugin:New();
Authentification:Init();
end
function Authentification:PrepareAll()
self:LoadData();
end
function Authentification:CheckPlayer(player)
if self.Data then
if self.Data[player.profile] then
player.authQuery=self.Data[player.profile];
player.authExists=true;
else
player.authQuery=nil;
player.authExists=false;
end
player.auth=false;
player.needAuth=false;
end
if player.IsAdminLogged then
player.authTgt=\"IsAdminLogged\";
player.IsAdminLogged=false;
player.needAuth=true;
end
if player.IsModeratorLogged then
player.authTgt=\"IsModeratorLogged\";
player.IsModeratorLogged=false;
player.needAuth=true;
end
if player._wasRevived then
self:WarnPlayer(player);
end
player._wasChecked=true;
end
function Authentification:OnPlayerRevive(player)
player._wasRevived=true;
if player._wasChecked then
self:WarnPlayer(player);
end
end
function Authentification:WarnPlayer(player)
if player.needAuth and not player.gotAuthMsg then
if player.authExists then
Chat:SendToTarget(nil,player,\"Use !pass <password> to authentificate yourself\");
else
Chat:SendToTarget(nil,player,\"Use !npass <password> to create your authentification password\");
end
player.gotAuthMsg=true;
end
end
function __hasrights(player)
if SafeWriting.Settings.Admins[player.profile] or SafeWriting.Settings.Moderators[player.profile] then
return true;
end
return false;
end
AddChatCommand(\"pass\",function(self,player,msg,pass)
if __hasrights(player) then
if player.needAuth then
if not pass then Chat:SendToTarget(nil,player,\"Enter a valid password!\"); return; end
if player.authExists then
local hsh=JL1Hash:Create(123);
pass=JL1Hash:Hash(pass);
if pass==player.authQuery then
Chat:SendToTarget(nil,player,\"You have successfuly authentificated yourself, now you have rights\");
player[player.authTgt]=true;
player.needAuth=false;
else
Chat:SendToTarget(nil,player,\"Authentification failed - invalid password!\");
return;
end
else
Chat:SendToTarget(nil,player,\"Use !npass <password> to create your authentification password\");
end
else Chat:SendToTarget(nil,player,\"You are already logged-in!\"); end
else
Chat:SendToTarget(nil,player,\"You do not have rights to use this command!\");
end
end,{TEXT}); --must be for normal players!
AddChatCommand(\"npass\",function(self,player,msg,pass)
if __hasrights(player) then
if player.needAuth then
if not pass then Chat:SendToTarget(nil,player,\"Enter a valid password!\"); return; end
if not player.authExists then
local hsh=JL1Hash:Create(123);
pass=JL1Hash:Hash(pass);
Chat:SendToTarget(nil,player,\"You have successfuly created your authentification password, you are already logged-in now.\");
player[player.authTgt]=true;
player.needAuth=false;
Authentification.Data[player.profile]=pass;
Authentification:SaveData();
else
Chat:SendToTarget(nil,player,\"You already have authentification password!\");
end
else Chat:SendToTarget(nil,player,\"You are already logged-in!\"); end
else
Chat:SendToTarget(nil,player,\"You do not have rights to use this command!\");
end
end,{TEXT});
SafeWriting.FuncContainer:LoadPlugin(Authentification);
Admins and moderators are now required to use password to get rights.
Login with !pass password and register password with !npass pwd❤️ 0