CapsAdmin

Untitled

Oct 14th, 2012
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.06 KB | None | 0 0
  1. if html and html:IsValid() then html:Remove() end
  2.  
  3. local html = vgui.Create("DHTML") _G.html = html
  4.  
  5. html:AddFunction("gmod", "print", print)
  6. local player = setmetatable(
  7.     {
  8.     },
  9.     {
  10.         __index = function(self, func_name)
  11.             return function(...)
  12.                 local tbl = {...}
  13.                
  14.                 for key, val in pairs(tbl) do
  15.                     tbl[key] = tostring(val)
  16.                    
  17.                     if tbl[key] == "nil" or tbl[key] == "NULL" then
  18.                         tbl[key] = "null"
  19.                     end
  20.                 end
  21.                
  22.                 local str = ("%s(%q);"):format(func_name, table.concat(tbl, ", "))
  23.                 html:QueueJavascript(str)
  24.                 --print(str)
  25.             end
  26.         end
  27.     }
  28. )
  29.  
  30. html:SetPos(ScrW(), ScrH())
  31. html:OpenURL("http://dl.dropbox.com/u/244444/gmod_audio.html")
  32. html:QueueJavascript[[
  33.     var obj = null;
  34.     function player()
  35.     {
  36.         if (!obj)
  37.             obj = new Audio();
  38.    
  39.         return obj;
  40.     }
  41.    
  42.     function play(str)
  43.     {
  44.         try
  45.         {
  46.             player().src = str;
  47.             player().play();
  48.            
  49.             gmod.print("playing " + player().src);
  50.         }
  51.         catch(err)
  52.         {
  53.             gmod.print(err);
  54.         }
  55.     }
  56. ]]
  57.  
  58. player.play("http://dl.dropbox.com/u/244444/2-02%20New%20Map.mp3")
Advertisement
Add Comment
Please, Sign In to add comment