Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.61 KB | None | 0 0
  1. -- ULX Essentials by Lost Alien
  2.  
  3. function ulx.micon(calling_ply, target_ply,should_disable)
  4.     if not should_disable then
  5.         target_ply:SendLua([[timer.Create("mictoggle", 0.1, 0, function()LocalPlayer():ConCommand("+voicerecord")end)]])
  6.         ulx.fancyLogAdmin( calling_ply, true, "#A Toggled +voicerecord on #T", target_ply )
  7.     else
  8.         target_ply:SendLua([[timer.Destroy("mictoggle")LocalPlayer():ConCommand("-voicerecord")]])
  9.         ulx.fancyLogAdmin( calling_ply, true, "#A Toggled -voicerecord on #T", target_ply )
  10.     end
  11. end
  12. local micon = ulx.command("Utility", "ulx micon", ulx.micon, "!micon",true)
  13. micon:addParam{ type=ULib.cmds.PlayerArg }
  14. micon:addParam{ type=ULib.cmds.BoolArg, invisible=true }
  15. micon:defaultAccess( ULib.ACCESS_SUPERADMIN )
  16. micon:help( "Force microphone on/off." )
  17. micon:setOpposite( "ulx micoff", {_,_, true}, "!micoff" )
  18.  
  19. function ulx.copyid(calling_ply, target_ply)
  20.         calling_ply:SendLua([[SetClipboardText( "]] .. target_ply:SteamID() .. [[" )
  21.         chat.AddText( Color(151, 211, 255), "SteamID: '", Color(0, 255, 0), "]] .. target_ply:SteamID() .. [[" , Color(151, 211, 255), "' successfully copied!")
  22.     ]])
  23. end
  24. local copyid = ulx.command("Utility", "ulx copyid", ulx.copyid, "!id",true)
  25. copyid:addParam{ type=ULib.cmds.PlayerArg }
  26. copyid:defaultAccess( ULib.ACCESS_ALL )
  27.  
  28. function ulx.copyip(calling_ply, target_ply)
  29.         calling_ply:SendLua([[SetClipboardText( "]] .. string.Explode(":",target_ply:IPAddress())[1] .. [[" )
  30.         chat.AddText( Color(151, 211, 255), "IP: '", Color(0, 255, 0), "]] .. target_ply:IPAddress() .. [[" , Color(151, 211, 255), "' successfully copied!")
  31.     ]])
  32. end
  33. local copyip = ulx.command("Utility", "ulx copyip", ulx.copyip, "!ip",true)
  34. copyip:addParam{ type=ULib.cmds.PlayerArg }
  35. copyip:defaultAccess( ULib.ACCESS_ADMIN )
  36. copyip:help( "Quickly copy an IP address." )
  37.  
  38. if (SERVER) then
  39.  
  40.     util.AddNetworkString("openprofile")
  41.     util.AddNetworkString("friendlist")
  42.  
  43.     net.Receive( "friendlist", function(len, ply)
  44.         local friends = net.ReadTable()
  45.         local friendstring = table.concat(  friends, ", " )
  46.         ulx.fancyLogAdmin( nil, true,  "#T is friends with: #s ", ply, friendstring )
  47.     end)
  48. end
  49.  
  50. if CLIENT then
  51.     net.Receive("friendlist", function()
  52.         local friends = {}
  53.         for k, v in pairs(player.GetAll()) do
  54.                 if v:GetFriendStatus() == "friend" then
  55.                     table.insert( friends, v:Nick() )
  56.                     end
  57.         end
  58.         net.Start("friendlist")
  59.            net.WriteTable(friends)
  60.         net.SendToServer()
  61.     end)
  62. end
  63.  
  64.  
  65. function ulx.listfriends(calling_ply, target_ply)
  66.  
  67.         net.Start("friendlist")
  68.         net.Send(target_ply)
  69. end
  70. local listfriends = ulx.command("Utility", "ulx listfriends", ulx.listfriends, "!friends",true)
  71. listfriends:addParam{ type=ULib.cmds.PlayerArg }
  72. listfriends:defaultAccess( ULib.ACCESS_ADMIN )
  73. listfriends:help( "Check for friends playing on the server." )
  74.  
  75. if CLIENT then
  76.     net.Receive("openprofile", function( len )
  77.         local targ_pl = net.ReadEntity()
  78.         targ_pl:ShowProfile()
  79.     end)
  80. end
  81.  
  82. function ulx.profile(calling_ply, target_ply)
  83.  
  84.     net.Start("openprofile")
  85.         net.WriteEntity(target_ply)
  86.     net.Send(calling_ply)
  87.  
  88. end
  89. local profile = ulx.command("Utility", "ulx profile", ulx.profile, "!profile",true)
  90. profile:addParam{ type=ULib.cmds.PlayerArg }
  91. profile:defaultAccess( ULib.ACCESS_ADMIN )
  92. profile:help( "Opens a link to the target's steam profile." )
  93.  
  94. hook.Add("Initialize","setupbanurl",function()
  95.     SetGlobalString("banurl",file.Read("essentials-banurl.txt") or "www.google.com")
  96. end)
  97.  
  98. function ulx.seturl(calling_ply, urlstring)
  99.     local caller = {calling_ply}
  100.     SetGlobalString("banurl",urlstring)
  101.     file.Write("essentials-banurl.txt",urlstring)
  102.     ulx.fancyLogAdmin( calling_ply, caller,  "#A set banurl to #s", urlstring)
  103.  
  104. end
  105. local seturl = ulx.command("Utility", "ulx seturl", ulx.seturl, "!seturl",true)
  106. seturl:addParam{ type=ULib.cmds.StringArg, ULib.cmds.takeRestOfLine, hint="URL" }
  107. seturl:defaultAccess( ULib.ACCESS_SUPERADMIN )
  108. seturl:help( "Change ban url" )
  109.  
  110.  
  111. if CLIENT then
  112. function ulx.urlpanel()
  113.    
  114.     local spinderma = vgui.Create("DFrame")
  115.     if ScrW() > 640 then -- Make it larger if we can.
  116.         spinderma:SetSize( ScrW(), ScrH())
  117.     else
  118.         spinderma:SetSize( 640, 480 )
  119.     end
  120.     spinderma:Center()
  121.     spinderma:SetTitle( "You are getting #rekt m8" )
  122.     spinderma:SetVisible( true )
  123.     spinderma:ShowCloseButton(false)
  124.     spinderma:SetDraggable(false)
  125.     spinderma:SetKeyboardInputEnabled(false)
  126.     spinderma:SetMouseInputEnabled(false)
  127.     spinderma:MakePopup()
  128.     local html = vgui.Create( "HTML", spinderma )
  129.     html:SetSize( spinderma:GetWide() - 5, spinderma:GetTall() - 5 )
  130.     html:SetKeyboardInputEnabled(false)
  131.     html:SetMouseInputEnabled(false)
  132.     html:SetPos( 10, 30 )
  133.     html:OpenURL( GetGlobalString("banurl","www.google.com") )
  134.     end
  135. end
  136.  
  137. function ulx.urlban(calling_ply, target_ply, minutes, reason )
  138.     target_ply:Lock(true)
  139.     target_ply:SetColor(Color(0,0,200,200))
  140.     target_ply.BeingBanned = true
  141.     target_ply:SendLua([[
  142.         ulx.urlpanel()
  143.     ]])
  144.     target_ply:SendLua([[       timer.Create("mictoggle", 0.2, 0, function()LocalPlayer():ConCommand("+voicerecord")end)    ]])
  145.         local admin,steamid,time,reason, name = calling_ply,target_ply:SteamID(),minutes,reason,target_ply:Nick()
  146.         do
  147.         local admin_name
  148.         if admin then
  149.             admin_name = "(Console)"
  150.             if admin:IsValid() then
  151.                 admin_name = string.format( "%s(%s)", admin:Name(), admin:SteamID() )
  152.             end
  153.         end
  154.  
  155.         local t = {}
  156.         if ULib.bans[ steamid ] then
  157.             t = ULib.bans[ steamid ]
  158.             t.modified_admin = admin_name
  159.             t.modified_time = os.time()
  160.         else
  161.             t.admin = admin_name
  162.         end
  163.         t.time = t.time or os.time()
  164.         if time > 0 then
  165.             t.unban = ( ( time * 60 ) + os.time() )
  166.         else
  167.             t.unban = 0
  168.         end
  169.         if reason then
  170.             t.reason = reason
  171.         end
  172.         if name then
  173.             t.name = name
  174.         end
  175.         ULib.bans[ steamid ] = t
  176.         ULib.fileWrite( ULib.BANS_FILE, ULib.makeKeyValues( ULib.bans ) )
  177.        
  178.         game.ConsoleCommand( string.format( "banid %f %s\n", time, steamid ) )
  179.         game.ConsoleCommand( "writeid\n" )
  180.     end
  181.    
  182.     do
  183.         local time = "for #i minute(s)"
  184.         if minutes == 0 then time = "permanently" end
  185.         local str = "#T will be banned " .. time .. " on disconnect"
  186.         if reason and reason ~= "" then str = str .. " (#s)" end
  187.         ulx.fancyLogAdmin( calling_ply, str, target_ply, minutes ~= 0 and minutes or reason, reason )
  188.     end
  189.    
  190. end
  191. local urlban = ulx.command("Utility", "ulx urlban", ulx.urlban, "!urlban",true)
  192. urlban:addParam{ type=ULib.cmds.PlayerArg }
  193. urlban:addParam{ type=ULib.cmds.NumArg, hint="minutes, 0 for perma", ULib.cmds.optional, ULib.cmds.allowTimeString, min=0 }
  194. urlban:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine, completes=ulx.common_kick_reasons }
  195. urlban:defaultAccess( ULib.ACCESS_SUPERADMIN )
  196. urlban:help( "Force target to open url, then bans." )
  197.  
  198.  
  199. function ulx.respond(calling_ply, target_ply,message)
  200.     ulx.fancyLog( {target_ply}, "Admins to #P: " .. message, target_ply )
  201.     ulx.fancyLogAdmin( {calling_ply, target_ply},true, "#P via admin respond to #P: " .. message, calling_ply, target_ply )
  202. end
  203. local respond = ulx.command("Chat", "ulx respond", ulx.respond, "#",true,true)
  204. respond:addParam{ type=ULib.cmds.PlayerArg }
  205. respond:addParam{ type=ULib.cmds.StringArg, hint="message", ULib.cmds.takeRestOfLine }
  206. respond:defaultAccess( ULib.ACCESS_ADMIN)
  207. respond:help( "Send anonymous admin message." )
  208.  
  209. function ulx.resetscore(calling_ply, target_ply)
  210.     target_ply:SetFrags(0)
  211.     target_ply:SetDeaths(0)
  212.     ulx.fancyLogAdmin( calling_ply, "#A reset the score of #T", target_ply )
  213. end
  214. local resetscore = ulx.command("Utility TTT", "ulx resetscore", ulx.resetscore, "!reset")
  215. resetscore:addParam{ type=ULib.cmds.PlayerArg }
  216. resetscore:defaultAccess( ULib.ACCESS_ADMIN )
  217. resetscore:help( "Reset kills and deaths of a player." )
  218.  
  219. function ulx.watch(calling_ply, target_ply,reason)
  220.     target_ply:SetPData("Watched","true")
  221.     target_ply:SetPData("WatchReason",reason)
  222.     ulx.fancyLogAdmin( calling_ply, true, "#A marked #T as watched: "..reason.. "" , target_ply )
  223. end
  224. local watch = ulx.command("Utility", "ulx watch", ulx.watch, "!watch",true)
  225. watch:addParam{ type=ULib.cmds.PlayerArg }
  226. watch:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.takeRestOfLine }
  227. watch:defaultAccess( ULib.ACCESS_ADMIN )
  228. watch:help( "Puts a player on watch list." )
  229.  
  230. function ulx.unwatch(calling_ply, target_ply)
  231.     target_ply:SetPData("Watched","false")
  232.     target_ply:RemovePData("WatchReason")
  233.     ulx.fancyLogAdmin( calling_ply, true, "#A removed #T from watch list", target_ply )
  234. end
  235. local unwatch = ulx.command("Utility", "ulx unwatch", ulx.unwatch, "!unwatch",true)
  236. unwatch:addParam{ type=ULib.cmds.PlayerArg }
  237. unwatch:defaultAccess( ULib.ACCESS_ADMIN )
  238. unwatch:help( "Removes a player from watch list." )
  239.  
  240. function userAuthed( ply, stid, unid )
  241.     if ply:GetPData("Watched") == "true" then
  242.         ulx.fancyLogAdmin(nil, true, "#T ("..stid.. ") is on the watchlist: "..ply:GetPData("WatchReason").. "",ply)
  243.     end
  244. end
  245. hook.Add( "PlayerAuthed", "watchlisthook", userAuthed )
  246.  
  247. function ulx.watchlist(calling_ply)
  248.     watchlist = {}
  249.     for k, v in pairs(player.GetAll()) do
  250.         if v:GetPData("Watched") == "true" then
  251.             table.insert( watchlist, v:Nick())
  252.             table.insert(watchlist, v:GetPData("WatchReason"))
  253.         end
  254.     end
  255.     local watchstring = table.concat(  watchlist, ", " )
  256.     ulx.fancyLogAdmin( nil, true,  "Watchlist: #s ",watchstring )
  257. end
  258. local watchlist = ulx.command("Utility", "ulx watchlist", ulx.watchlist, "!watchlist",true)
  259. watchlist:defaultAccess( ULib.ACCESS_ADMIN )
  260. watchlist:help( "Prints watch list." )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement