Currently working on introducing myself to Lua in aims at creating some entities in the future - but for now I’m starting with something as simple as it gets. Creation of a prop that emits a sound constantly from the moment it is Initialized and a prop that emits a sound when used.
Here is the snippet of my init.lua. With my entity that emits sound constantly, the radius is being taken into account and when you move away from the prop it decreases respectively. With THIS entity, which relies on the EmitSound() being initiated through ENT:Use, it appears that the sound does not take the radius into account and the sound is playing full-volume and does not decrease when you gain distance.
AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include("shared.lua") function ENT:Initialize() self:SetModel("models/gtavproppack/hall/prop_micro_02.mdl") self:PhysicsInit(SOLID_VPHYSICS) self:SetMoveType(MOVETYPE_VPHYSICS) self:SetSolid(SOLID_VPHYSICS) self:SetUseType(SIMPLE_USE) local phys = self:GetPhysicsObject() if phys:IsValid() then phys:Wake() end util.PrecacheSound("nev_entities/microwave.wav") end function ENT:Use( activator, ent ) if ( activator:IsPlayer() ) then activator:EmitSound("nev_entities/microwave.wav", 25, 100, 1, CHAN_AUTO) end end
I’d appreciate some help on this. My only goal is to create a prop microwave that plays a microwave.wav sound on the entity and can be heard by other players.