[lua]local radio = ents.Create("radio_hits")
radio:SetPos(Vector(980,-3565,695))
radio:Spawn()[/lua]
The location of init.lua for the radio is addons/radio/lua/entities/radio_hits/init.lua, so I assume the entity create would be "radio_hits". I am getting an error about a null entity on the second line...what am I doing wrong?
[editline]10:11PM[/editline]
Ok, now I am getting "radio_hits is an unknown entity type!"
[editline]11:06PM[/editline]
Ok, got it spawning now. It just won't stream music. Here's the code.
[lua]AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
--Clients shouldn't download the custom radio sounds.
--
--[[
resource.AddFile( "sound/radio_mod_sounds/radio/custom/1.mp3" )
resource.AddFile( "sound/radio_mod_sounds/radio/custom/2.mp3" )
resource.AddFile( "sound/radio_mod_sounds/radio/custom/3.mp3" )
resource.AddFile( "sound/radio_mod_sounds/radio/custom/4.mp3" )
resource.AddFile( "sound/radio_mod_sounds/radio/custom/5.mp3" )
resource.AddFile( "sound/radio_mod_sounds/radio/custom/6.mp3" )
resource.AddFile( "sound/radio_mod_sounds/radio/custom/7.mp3" )
resource.AddFile( "sound/radio_mod_sounds/radio/custom/8.mp3" )
--]]
resource.AddFile( "materials/vgui/entities/sent_Radio3.vtf" )
resource.AddFile( "materials/vgui/entities/sent_Radio3.vmt" )
resource.AddFile( "materials/models/radio_electro.vtf" )
resource.AddFile( "materials/models/radio_electro.vmt" )
include('shared.lua')
function startStream()
local HTML = vgui.Create("HTML")
local function stopRadio()
HTML:Remove()
end
local function listenRadio()
HTML:SetParent(HTMLFrame)
HTML:SetPos(0 , 0)
HTML:SetSize(0, 0)
HTML:OpenURL("http://www.977music.com/tunein/web/hitz.asx")
end
usermessage.Hook("listenRadio", listenRadio)
conCommand.Add("listenRadio", listenRadio)
usermessage.Hook("stopListening", stopRadio)
RunConsoleCommand("listenRadio")
end
------------------------------------VARIABLES END
function ENT:SpawnFunction( ply, tr )
if ( !tr.Hit ) then return end
local SpawnPos = tr.HitPos + tr.HitNormal * 16
local ent = ents.Create( self.ClassName )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()
return ent
end
--------------
function ENT:Initialize( )
self:SetModel( "models/props_lab/citizenradio.mdl" )
self:SetMaterial( "models/radio_electro" )
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
local phys = self:GetPhysicsObject()
if(phys:IsValid()) then phys:Wake() end
self.Engine = NULL
startStream()
end
-------------------
function ENT:Think()
if self.Entity:WaterLevel() > 0 then
local effectdata = EffectData()
effectdata:SetOrigin( self.Entity:GetPos())
effectdata:SetStart(Vector(0,0,2))
util.Effect( "PropellerBubbles", effectdata )
end
end
-------------------
function ENT:OnRemove()
umsg.Start("stopListening")
umsg.End()
end[/lua]
Are you sure the HTML control knows how to handle .asx files?
[QUOTE=_nonSENSE;23324937]Are you sure the HTML control knows how to handle .asx files?[/QUOTE]
Not sure, found this code lying around. Not exactly Lua-smart here.
Any links/examples/suggestions?
Use the bass module.
Sorry, you need to Log In to post a reply to this thread.