Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Hera Admin >> Framework
- */
- require "gatekeeper"
- require "glon"
- Hera = {}
- Hera.Version = 1
- Hera.Constants = {}
- Hera.Constants.Denied = { "You aren't allowed to do that!" }
- Hera.Logging = {}
- Hera.Logging.Debug = 0
- Hera.Logging.Info = 1
- Hera.Logging.Warning = 2
- Hera.Logging.Error = 3
- Hera.Logging.SeverityColor = {
- [ Hera.Logging.Debug ] = Color( 80, 80, 255 ),
- [ Hera.Logging.Info ] = Color( 80, 255, 80 ),
- [ Hera.Logging.Warning ] = Color( 255, 255, 80 ),
- [ Hera.Logging.Error ] = Color( 255, 80, 80 ),
- }
- Hera.Immunity = true
- Hera.CompatibilityRanks = glon.decode( file.Read( "hera_ranks.txt" ) )
- function Hera.FindPlayer( nick )
- for k, v in pairs( player.GetAll() ) do
- if v:Nick():lower():find( nick ) then
- return v
- end
- end
- end
- function Hera.Notify( ply, severity, str, ... )
- if severity < Hera.Logging.Debug or severity > Hera.Logging.Error then return end
- ply:SendLua( [[ chat.AddText( clr[lvl], "[Hera] ", Color( 255, 255, 255 ), string.format( str, ... ) ) ]] )
- end
- function Hera.NotifyAll( severity, str, ... )
- if severity < Hera.Logging.Debug or severity > Hera.Logging.Error then return end
- for k, v in pairs( player.GetAll() ) do
- ply:SendLua( [[ chat.AddText( clr[lvl], "[Hera] ", Color( 255, 255, 255 ), string.format( str, ... ) ) ]] )
- end
- end
- function Hera.Log( severity, str, ... )
- if severity < Hera.Logging.Action or severity > Hera.Logging.Error then return end
- if severity == 0 then
- severity = "Debug"
- elseif severity == 1 then
- severity = "Info"
- elseif severity == 2 then
- severity = "Warning"
- else
- severity = "ERROR"
- end
- file.Write( "Hera/logs.txt", file.Read( "Hera/logs.txt" ) .. string.format( "[%s] [%s]\t%s\n", os.date( "%I" ) .. ":" .. os.date( "%M" ) .. " " .. os.date( "%p" ), severity, string.format( str, ... ) ) )
- end
- function Hera.NumToBin( num )
- local ret = ""
- while( num > 0 ) do
- ret = tostring( num % 2 ) .. ret
- num = math.floor( num / 2 )
- end
- return ret
- end
- function Hera.StrToBin( str )
- local ret = ""
- for b in str:gmatch( "%S+" ) do
- for c in b:gmatch( "." ) do
- ret = ret .. "0" .. Hera.NumToBin( c:byte() )
- ret = ret .. " "
- end
- end
- return ret
- end
- function Hera.Kick( ply, reason )
- gatekeeper.Drop( ply:UserID(), reason )
- end
- function Hera.Ban( ply, length, reason )
- ply:Ban( length, reason )
- gatekeeper.Drop( ply:UserID(), reason )
- end
- concommand.Add( "hera_kick", function( ply, command, args )
- if not ply:IsAdmin() then return end
- local reason = table.concat( args, " ", 2 ) or "General Idiot"
- local target = Hera.FindPlayer( args[ 1 ] )
- Hera.Kick( target, reason )
- Hera.Log( 1, "%s kicked %s with the reason << %s >>", ply:Nick(), target:Nick(), reason )
- Hera.NotifyAll( 1, "%s kicked %s with the reason \"%s\"", ply:Nick(), target:Nick(), reason )
- end )
- concommand.Add( "hera_ban", function( ply, command, args )
- if not ply:IsAdmin() then return end
- local target = Hera.FindPlayer( args[ 1 ] )
- if Hera.Immunity and target:IsSuperAdmin() then return end
- local time = tonumber( args[ 2 ] ) or 10
- local reason = table.concat( args, " ", 3 )
- if not #reason then reason = "No reason specified" end
- Hera.Ban( target, time, reason )
- Hera.Log( 1, "%s banned %s for %s minutes with the reason << %s >>", ply:Nick(), target:Nick(), time, reason )
- Hera.NotifyAll( 1, "%s banned %s for %s minutes with the reason \"%s\"", ply:Nick(), target:Nick(), time, reason )
- end )
- concommand.Add( "hera_give", function( ply, command, args )
- if not ply:IsAdmin() then return end
- local weapon = args[ 2 ]
- local target = Hera.FindPlayer( args[ 1 ] )
- if Hera.Immunity and target:IsSuperAdmin() then return end
- target:Give( weapon )
- Hera.Log( 1, "%s gave %s << %s >>", ply:Nick(), target:Nick(), weapon )
- Hera.NotifyAll( 1, "%s gave %s a %s", ply:Nick(), target:Nick(), weapon )
- end )
- concommand.Add( "hera_freeze", function( ply, command, args )
- if not ply:IsAdmin() then return end
- local target = Hera.FindPlayer( args[ 1 ] )
- if Hera.Immunity and target:IsSuperAdmin() then return end
- target:Lock()
- Hera.Log( 1, "%s froze %s", ply:Nick(), target:Nick() )
- Hera.NotifyAll( 1, "%s froze %s", ply:Nick(), target:Nick() )
- end )
- concommand.Add( "hera_unfreeze", function( ply, command, args )
- if not ply:IsAdmin() then return end
- local target = Hera.FindPlayer( args[ 1 ] )
- if Hera.Immunity and target:IsSuperAdmin() then return end
- target:UnLock()
- Hera.Log( 1, "%s unfroze %s", ply:Nick(), target:Nick() )
- Hera.NotifyAll( 1, "%s unfroze %s", ply:Nick(), target:Nick() )
- end )
- concommand.Add( "hera_goto", function( ply, command, args )
- if not ply:IsAdmin() then return end
- local target = Hera.FindPlayer( args[ 1 ] )
- if Hera.Immunity and target:IsSuperAdmin() then return end
- local newpos = target:GetPos() + Vector( 0, 0, 80 )
- ply:SetPos( newpos )
- Hera.Log( 1, "%s has gone to %s", ply:Nick(), target:Nick() )
- Hera.NotifyAll( 1, "%s has gone to %s", ply:Nick(), target:Nick() )
- end )
- concommand.Add( "hera_bring", function( ply, command, args )
- if not ply:IsAdmin() then return end
- local target = Hera.FindPlayer( args[ 1 ] )
- if Hera.Immunity and target:IsSuperAdmin() then return end
- local newpos = ply:GetPos() + Vector( 0, 0, 80 )
- target:SetPos( newpos )
- Hera.Log( 1, "%s has brought %s to them", ply:Nick(), target:Nick() )
- Hera.NotifyAll( 1, "%s has brought %s to them", ply:Nick(), target:Nick() )
- end )
- concommand.Add( "hera_strip", function( ply, command, args )
- if not ply:IsAdmin() then return end
- local target = Hera.FindPlayer( args[ 1 ] )
- if Hera.Immunity and target:IsSuperAdmin() then return end
- target:StripWeapons()
- Hera.Log( 1, "%s has stripped the weapons of %s", ply:Nick(), target:Nick() )
- Hera.NotifyAll( 1, "%s has stripped the weapons of %s", ply:Nick(), target:Nick() )
- end )
- concommand.Add( "hera_slay", function( ply, command, args )
- if not ply:IsAdmin() then return end
- local target = Hera.FindPlayer( args[ 1 ] )
- if Hera.Immunity and target:IsSuperAdmin() then return end
- target:Kill()
- Hera.Log( 1, "%s has slayed %s", ply:Nick(), target:Nick() )
- Hera.NotifyAll( 1, "%s has slayed %s", ply:Nick(), target:Nick() )
- end )
- concommand.Add( "hera_god", function( ply, command, args )
- if not ply:IsAdmin() then return end
- local target = Hera.FindPlayer( args[ 1 ] )
- if Hera.Immunity and target:IsSuperAdmin() then return end
- target:GodEnable()
- Hera.Log( 1, "%s has enabled godmode for %s", ply:Nick(), target:Nick() )
- Hera.NotifyAll( 1, "%s has enabled godmode for %s", ply:Nick(), target:Nick() )
- end )
- concommand.Add( "hera_ungod", function( ply, command, args )
- if not ply:IsAdmin() then return end
- local target = Hera.FindPlayer( args[ 1 ] )
- if Hera.Immunity and target:IsSuperAdmin() then return end
- target:GodDisable()
- Hera.Log( 1, "%s has disabled godmode for %s", ply:Nick(), target:Nick() )
- Hera.NotifyAll( 1, "%s has disabled godmode for %s", ply:Nick(), target:Nick() )
- end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement