I'd like to make an addon that gives everyone Adminlogin command in console where they can type password and login as admin. How I do it?
At least how do I give somebody admin privileges?
Try running this and see if this is what you want to occur. This would make it so they would have to be a predefined admin and to use any commands they would need to login so if someone like a brother came on they wouldnt have admin.
Is that why you are asking?
[lua]
if(SERVER)then
local m = FindMetaTable("Player");
function m:IsSuperAdmin()
if (self.IsFullyAuthenticated && !self:IsFullyAuthenticated()) then return false end
return self.succefullyAuthed && self:oldIsSA();
end
function m:IsAdmin()
if (self.IsFullyAuthenticated && !self:IsFullyAuthenticated()) then return false end
return self.successfullyAuthed && (self:IsUserGroup("admin") || self:IsUserGroup("superadmin"));
end
local function playerAuthed(ply,username,password)
print("userAuth -> Authed player " .. ply:Nick());
ply.successfullyAuthed = true;
end
concommand.Add("userAuth",function(ply,cmd,_args)
if(#_args != 2)then return; end
local _logins = {
['rute'] = "test.",
}
for a,b in pairs(_logins)do
if(a==_args[1])then
if(b==_args[2])then
playerAuthed(ply,a,b);
return;
end
break;
end
end
print("userAuth -> Failed, incorrect login (bad username or password)");
return;
end)
end
[/lua]
[QUOTE=zzaacckk;32007941]Like this?
[lua]--Stuff
[/lua][/QUOTE]Your on a roll tonight.
And so giving everybody admin is simply as?:
[lua]
if(SERVER)then
local m = FindMetaTable("Player");
function m:IsSuperAdmin()
return true
end
function m:IsAdmin()
return true
end
end
[/lua]
Yes.
Just so you are able to implement this in the future, m is a metatable, as you probably know. If you are familiar with OOP then you could think of a metatable as adding a method to an existing object.
If you arent another helpful description is "A metatable is, like the word metatable means, 'a table about a table'. Metatables are used to store information about tables and contain methods that can be used to change the behavior of tables."
There are a few pages on the wiki if you want some more info on them.
Sorry, you need to Log In to post a reply to this thread.