So I am creating a jukebox addon, but I cant seem to get the sound to play when the use key is pressed. Any help is appreciated.
[code]
AddCSLuaFile( "shared.lua" )
AddCSLuaFile( "cl_init.lua" )
include( "shared.lua" )
local radioPlaying = 0
function ENT:Initialize()
self:SetModel( "models/fallout3/jukebox.mdl" )
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
self.isRunning = false
local phys = self:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
end
end
function ENT:Use(c , a)
if radioPlaying == 1 then
c:ConCommand( "stopsound" )
radioPlaying = 0
else
radioPlaying = 1
end
end
if radioPlaying == 1 then
Entity:EmitSound( "sound/fallout3st/fallout3waybackhome.wav" )
end
[/code]
Ill try surface.playsound
Your last 3 line are only even ran ONCE and only when the server starts, not even when one of your entities can possibly be in the level.
Solution: Use hooks/callbacks.
[QUOTE=Robotboy655;51282084]Your last 3 line are only even ran ONCE and only when the server starts, not even when one of your entities can possibly be in the level.
Solution: Use hooks/callbacks.[/QUOTE]
What if I added Entity:EmitSound( "sound/fallout3st/fallout3waybackhome.wav" ) to the use command?
[editline]30th October 2016[/editline]
[QUOTE=Bkamahl;51282093]What if I added Entity:EmitSound( "sound/fallout3st/fallout3waybackhome.wav" ) to the use command?[/QUOTE]
I have gotten it working, now its not finding the sound yet its in the addon file
Sorry, you need to Log In to post a reply to this thread.