I've tried everything to fix this and I don't know what's wrong. It plays music and collides with everything perfectly, but the only thing wrong is that the phys beam always goes to where the entity spawned, no matter where it is now. Any ideas?
[LUA]AddCSLuaFile()
DEFINE_BASECLASS( "base_anim" )
ENT.PrintName = "Portal Radio"
ENT.Author = "buster925"
ENT.Information = "The radio from Portal"
ENT.Category = "Portal"
ENT.Editable = false
ENT.Spawnable = true
ENT.AdminOnly = false
function ENT:SpawnFunction( ply, tr, ClassName )
if ( !tr.Hit ) then return end
local SpawnPos = tr.HitPos + tr.HitNormal * 16
local ent = ents.Create( ClassName )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()
return ent
end
function ENT:Initialize()
self:SetModel( "models/radio_reference.mdl" )
self:EmitSound("looping_radio_mix.wav")
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
local phys = self:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
end
end
function ENT:OnRemove()
RunConsoleCommand("stopsound", "");
end
function ENT:Use( activator, caller )
return
end
function ENT:Think()
end[/LUA]
Wrap "if SERVER then" around everything after "ENT.AdminOnly = false"
Thank you! It solved all the problems I've had with this addon! I think the reason it played the song twice for me was also relating to this, since it was playing it client and server side. You rock!
Sorry, you need to Log In to post a reply to this thread.