SHARE
TWEET

Untitled

a guest May 19th, 2017 39 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     Hera Admin >> Framework
  3. */
  4. require "gatekeeper"
  5. require "glon"
  6.  
  7. Hera = {}
  8. Hera.Version = 1
  9. Hera.Constants = {}
  10. Hera.Constants.Denied = { "You aren't allowed to do that!" }
  11. Hera.Logging = {}
  12. Hera.Logging.Debug = 0
  13. Hera.Logging.Info = 1
  14. Hera.Logging.Warning = 2
  15. Hera.Logging.Error = 3
  16. Hera.Logging.SeverityColor = {
  17.     [ Hera.Logging.Debug ]      = Color( 80, 80, 255 ),
  18.     [ Hera.Logging.Info ]       = Color( 80, 255, 80 ),
  19.     [ Hera.Logging.Warning ]    = Color( 255, 255, 80 ),
  20.     [ Hera.Logging.Error ]      = Color( 255, 80, 80 ),
  21. }
  22. Hera.Immunity = true
  23. Hera.CompatibilityRanks = glon.decode( file.Read( "hera_ranks.txt" ) )
  24.  
  25. function Hera.FindPlayer( nick )
  26.     for k, v in pairs( player.GetAll() ) do
  27.         if v:Nick():lower():find( nick ) then
  28.             return v
  29.         end
  30.     end
  31. end
  32.  
  33. function Hera.Notify( ply, severity, str, ... )
  34.     if severity < Hera.Logging.Debug or severity > Hera.Logging.Error then return end
  35.     ply:SendLua( [[ chat.AddText( clr[lvl], "[Hera] ", Color( 255, 255, 255 ), string.format( str, ... ) ) ]] )
  36. end
  37.  
  38. function Hera.NotifyAll( severity, str, ... )
  39.     if severity < Hera.Logging.Debug or severity > Hera.Logging.Error then return end
  40.     for k, v in pairs( player.GetAll() ) do
  41.         ply:SendLua( [[ chat.AddText( clr[lvl], "[Hera] ", Color( 255, 255, 255 ), string.format( str, ... ) ) ]] )
  42.     end
  43. end
  44.  
  45. function Hera.Log( severity, str, ... )
  46.     if severity < Hera.Logging.Action or severity > Hera.Logging.Error then return end
  47.     if severity == 0 then
  48.         severity = "Debug"
  49.     elseif severity == 1 then
  50.         severity = "Info"
  51.     elseif severity == 2 then
  52.         severity = "Warning"
  53.     else
  54.         severity = "ERROR"
  55.     end
  56.     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, ... ) ) )
  57. end
  58.  
  59. function Hera.NumToBin( num )
  60.     local ret = ""
  61.     while( num > 0 ) do
  62.         ret = tostring( num % 2 ) .. ret
  63.         num = math.floor( num / 2 )
  64.     end
  65.     return ret
  66. end
  67.  
  68. function Hera.StrToBin( str )
  69.     local ret = ""
  70.     for b in str:gmatch( "%S+" ) do
  71.         for c in b:gmatch( "." ) do
  72.             ret = ret .. "0" .. Hera.NumToBin( c:byte() )
  73.             ret = ret .. " "
  74.         end
  75.     end
  76.     return ret
  77. end
  78.  
  79. function Hera.Kick( ply, reason )
  80.     gatekeeper.Drop( ply:UserID(), reason )
  81. end
  82.  
  83. function Hera.Ban( ply, length, reason )
  84.     ply:Ban( length, reason )
  85.     gatekeeper.Drop( ply:UserID(), reason )
  86. end
  87.  
  88. concommand.Add( "hera_kick", function( ply, command, args )
  89.     if not ply:IsAdmin() then return end
  90.     local reason = table.concat( args, " ", 2 ) or "General Idiot"
  91.     local target = Hera.FindPlayer( args[ 1 ] )
  92.     Hera.Kick( target, reason )
  93.     Hera.Log( 1, "%s kicked %s with the reason << %s >>", ply:Nick(), target:Nick(), reason )
  94.     Hera.NotifyAll( 1, "%s kicked %s with the reason \"%s\"", ply:Nick(), target:Nick(), reason )
  95. end )
  96.  
  97. concommand.Add( "hera_ban", function( ply, command, args )
  98.     if not ply:IsAdmin() then return end
  99.     local target = Hera.FindPlayer( args[ 1 ] )
  100.     if Hera.Immunity and target:IsSuperAdmin() then return end
  101.     local time = tonumber( args[ 2 ] ) or 10
  102.     local reason = table.concat( args, " ", 3 )
  103.     if not #reason then reason = "No reason specified" end
  104.     Hera.Ban( target, time, reason )
  105.     Hera.Log( 1, "%s banned %s for %s minutes with the reason << %s >>", ply:Nick(), target:Nick(), time, reason )
  106.     Hera.NotifyAll( 1, "%s banned %s for %s minutes with the reason \"%s\"", ply:Nick(), target:Nick(), time, reason )
  107. end )
  108.  
  109. concommand.Add( "hera_give", function( ply, command, args )
  110.     if not ply:IsAdmin() then return end
  111.     local weapon = args[ 2 ]
  112.     local target = Hera.FindPlayer( args[ 1 ] )
  113.     if Hera.Immunity and target:IsSuperAdmin() then return end
  114.     target:Give( weapon )
  115.     Hera.Log( 1, "%s gave %s << %s >>", ply:Nick(), target:Nick(), weapon )
  116.     Hera.NotifyAll( 1, "%s gave %s a %s", ply:Nick(), target:Nick(), weapon )
  117. end )
  118.  
  119. concommand.Add( "hera_freeze", function( ply, command, args )
  120.     if not ply:IsAdmin() then return end
  121.     local target = Hera.FindPlayer( args[ 1 ] )
  122.     if Hera.Immunity and target:IsSuperAdmin() then return end
  123.     target:Lock()
  124.     Hera.Log( 1, "%s froze %s", ply:Nick(), target:Nick() )
  125.     Hera.NotifyAll( 1, "%s froze %s", ply:Nick(), target:Nick() )
  126. end )
  127.  
  128. concommand.Add( "hera_unfreeze", function( ply, command, args )
  129.     if not ply:IsAdmin() then return end
  130.     local target = Hera.FindPlayer( args[ 1 ] )
  131.     if Hera.Immunity and target:IsSuperAdmin() then return end
  132.     target:UnLock()
  133.     Hera.Log( 1, "%s unfroze %s", ply:Nick(), target:Nick() )
  134.     Hera.NotifyAll( 1, "%s unfroze %s", ply:Nick(), target:Nick() )
  135. end )
  136.  
  137. concommand.Add( "hera_goto", function( ply, command, args )
  138.     if not ply:IsAdmin() then return end
  139.     local target = Hera.FindPlayer( args[ 1 ] )
  140.     if Hera.Immunity and target:IsSuperAdmin() then return end
  141.     local newpos = target:GetPos() + Vector( 0, 0, 80 )
  142.     ply:SetPos( newpos )
  143.     Hera.Log( 1, "%s has gone to %s", ply:Nick(), target:Nick() )
  144.     Hera.NotifyAll( 1, "%s has gone to %s", ply:Nick(), target:Nick() )
  145. end )
  146.  
  147. concommand.Add( "hera_bring", function( ply, command, args )
  148.     if not ply:IsAdmin() then return end
  149.     local target = Hera.FindPlayer( args[ 1 ] )
  150.     if Hera.Immunity and target:IsSuperAdmin() then return end
  151.     local newpos = ply:GetPos() + Vector( 0, 0, 80 )
  152.     target:SetPos( newpos )
  153.     Hera.Log( 1, "%s has brought %s to them", ply:Nick(), target:Nick() )
  154.     Hera.NotifyAll( 1, "%s has brought %s to them", ply:Nick(), target:Nick() )
  155. end )
  156.  
  157. concommand.Add( "hera_strip", function( ply, command, args )
  158.     if not ply:IsAdmin() then return end
  159.     local target = Hera.FindPlayer( args[ 1 ] )
  160.     if Hera.Immunity and target:IsSuperAdmin() then return end
  161.     target:StripWeapons()
  162.     Hera.Log( 1, "%s has stripped the weapons of %s", ply:Nick(), target:Nick() )
  163.     Hera.NotifyAll( 1, "%s has stripped the weapons of %s", ply:Nick(), target:Nick() )
  164. end )
  165.  
  166. concommand.Add( "hera_slay", function( ply, command, args )
  167.     if not ply:IsAdmin() then return end
  168.     local target = Hera.FindPlayer( args[ 1 ] )
  169.     if Hera.Immunity and target:IsSuperAdmin() then return end
  170.     target:Kill()
  171.     Hera.Log( 1, "%s has slayed %s", ply:Nick(), target:Nick() )
  172.     Hera.NotifyAll( 1, "%s has slayed %s", ply:Nick(), target:Nick() )
  173. end )
  174.  
  175. concommand.Add( "hera_god", function( ply, command, args )
  176.     if not ply:IsAdmin() then return end
  177.     local target = Hera.FindPlayer( args[ 1 ] )
  178.     if Hera.Immunity and target:IsSuperAdmin() then return end
  179.     target:GodEnable()
  180.     Hera.Log( 1, "%s has enabled godmode for %s", ply:Nick(), target:Nick() )
  181.     Hera.NotifyAll( 1, "%s has enabled godmode for %s", ply:Nick(), target:Nick() )
  182. end )
  183.  
  184. concommand.Add( "hera_ungod", function( ply, command, args )
  185.     if not ply:IsAdmin() then return end
  186.     local target = Hera.FindPlayer( args[ 1 ] )
  187.     if Hera.Immunity and target:IsSuperAdmin() then return end
  188.     target:GodDisable()
  189.     Hera.Log( 1, "%s has disabled godmode for %s", ply:Nick(), target:Nick() )
  190.     Hera.NotifyAll( 1, "%s has disabled godmode for %s", ply:Nick(), target:Nick() )
  191. end )
RAW Paste Data
Challenge yourself this year...
Learn something new in 2017
Top