This should work but i keep getting a string expected got a table error when trying to run it and the button won’t press or do anything!
[lua]-- for _, ent in ipairs(ents.GetAll()) do
– if ent:GetClass():find(“prop_physics”) then
– contents = file.Read(“my_mod/data.txt”)
-- end
– end
if(SERVER) then return; end
muse = 0
local start_html = [[
<html>
<head>
<style type=“text/css”>
body, html{
padding:0px 0px 0px 0px;
margin:0px 0px 0px 0px;
text-align: center;
vertical-align:100%;
height:100%;
}
</style>
</head>
<body scroll=“no”; bgcolor=“black”>
</body>
</html>
]]
–http.Get(“http://gamerfm.co.uk”, “”, httpCallBack)
local function Create_Browser2(contents, size)
--local offsets = Screen_Offsets[Entity:GetModel()]
--BW = offsets.w
--BH = offsets.h
--Scale = offsets.scale
Browser = vgui.Create( "HTML" )
Browser:SetSize( 90, 90 )
Browser:SetPaintedManually( true )
Browser:SetVerticalScrollbarEnabled( false )
Browser:SetHTML( contents )
--Browser:StartAnimate( 1000 )
end
local function Create_Browser(ply, command, arguments)
–Browser:Remove( )
http.Get(arguments, “”, Create_Browser2)
–muse = 1
–else
–muse = 0
–contents = start_html
–end
end
–http.Get(“http://gamerfm.co.uk”, “”, Create_Browser)
concommand.Add( “playradio”, Create_Browser ) //Now we add a console command for the function we just created. It can be run straight from the console. If you look under the first couple of lines under init.lua, we
function radio2()
local steamid ={}
local DermaFrame = vgui.Create(“DFrame”)
DermaFrame:SetSize( 400, 285 )
DermaFrame:AlignLeft( 30 )
DermaFrame:AlignTop( 20 )
DermaFrame:SetTitle( “Adding Enforcers” ) – Title of the frame
DermaFrame:MakePopup()
local TestingComboBox = vgui.Create( “DComboBox”, DermaFrame )
TestingComboBox:SetPos( 10, 35 )
TestingComboBox:SetSize( 100, 185 )
TestingComboBox:SetMultiple( false ) – Don’t use this unless you know extensive knowledge about tables
TestingComboBox:AddItem( “GamerFM” ) – Add our options
TestingComboBox:AddItem( “FragFM” )
TestingComboBox:AddItem( “BBC Radio 1” )
TestingComboBox:AddItem( “BBC Radio 2” )
– TestingComboBox:AddItem( “Add” ) – Add our options
– TestingComboBox:AddItem( “Some” )
– TestingComboBox:AddItem( “Options” )
– TestingComboBox:AddItem( “Here” )
local MainMenuSheet = vgui.Create( “DPanel”, DermaFrame ) – We create a panel so we can draw shit on; if we use the frame, it comes up transparent for some reason
MainMenuSheet:SetPos( 125, 50 )
MainMenuSheet:SetSize( DermaFrame:GetWide() - 25, DermaFrame:GetTall() - 25 )
MainMenuSheet.Paint = function()
if TestingComboBox:GetSelectedItems() and TestingComboBox:GetSelectedItems()[1] then – make sure something is selected if not we get uber spam of errors
–local OurStringThing = "Your selection is: “…TestingComboBox:GetSelectedItems()[1]:GetValue()…”! Which is: " … steamid[ TestingComboBox:GetSelectedItems()[1]:GetValue() ] – This was a pain in the ass to figure out; this gets the name of the option chosen
if TestingComboBox:GetSelectedItems()[1]:GetValue() == “GamerFM” then
local httpp = “http://gamerfm.co.uk”
end
if TestingComboBox:GetSelectedItems()[1]:GetValue() == “FragFM” then
local httpp = “http://fragfm.co.uk/listen/”
end
if TestingComboBox:GetSelectedItems()[1]:GetValue() == “BBC Radio 1” then
local httpp = “http://www.bbc.co.uk/iplayer/console/radio1”
end
if TestingComboBox:GetSelectedItems()[1]:GetValue() == “BBC Radio 2” then
local httpp = “http://www.bbc.co.uk/iplayer/console/bbc_radio_two”
end
local OurStringThing = "You selected the radio: "..TestingComboBox:GetSelectedItems()[1]:GetValue()
–local OurStringThing2 = "The Steam ID is: "… steamid[ TestingComboBox:GetSelectedItems()[1]:GetValue() ] – This was a pain in the ass to figure out; this gets the name of the option chosen
–local OurStringThing3 = “Are you sure you want to add this player as an Enforcer?”
surface.SetFont( “default” )
surface.SetTextColor( 255, 255, 255, 255 )
surface.SetTextPos( 30, 20 )
surface.DrawText( OurStringThing ) – Draws the text
–surface.SetTextPos( 30, 40 )
–surface.DrawText( OurStringThing2 ) – Draws the text
– surface.SetTextPos( 30, 70 )
– surface.DrawText( OurStringThing3 ) – Draws the text
local SystemButtonThingOne = vgui.Create(“DSysButton”, DermaFrame)
SystemButtonThingOne:SetPos( 110,50 )
SystemButtonThingOne:SetSize( 50, 25 )
SystemButtonThingOne:SetType( “close” ) – This can be “close”, “down”, or “up”
SystemButtonThingOne.DoClick = function()
RunConsoleCommand( "playradio " …httpp) – What happens when you press the button
end
end
end
end
concommand.Add( “radio2”, radio2 ) //Now we add a console command for the function we just created. It can be run straight from the console. If you look under the first couple of lines under init.lua, we[/lua]