I know that is a bad title but I cannot think of a better one.
Basically what I am trying to do:
Make an entity like a bell.
-You press E on it and it goes off.
This is what I have so far
[url]https://www.sendspace.com/file/70k842[/url]
The download is just my
-init.lua
-cl_init.lua
-shared.lua
What I am trying to do is make it so when I press E on the the entity it makes a sound. Any ideas?
[QUOTE=Fayhd;49488483]I know that is a bad title but I cannot think of a better one.
Basically what I am trying to do:
Make an entity like a bell.
-You press E on it and it goes off.
This is what I have so far
[url]https://www.sendspace.com/file/70k842[/url]
The download is just my
-init.lua
-cl_init.lua
-shared.lua
What I am trying to do is make it so when I press E on the the entity it makes a sound. Any ideas?[/QUOTE]
[code]function Entity.Use() // ORIGINALLY POSTED .ONUSE, .USE IS CORRECT
*something*
end[/code]
B)
[QUOTE=kalis0x;49488520][code]function Entity.OnUse()
*something*
end[/code]
B)[/QUOTE]
Where it says something do I put the sound location?
[QUOTE=Fayhd;49488529]Where it says something do I put the sound location?[/QUOTE]
[code]function Entity.Use()
surface.PlaySound("soundlocation")
end[/code]
something like this
[QUOTE=kalis0x;49488537][code]function Entity.Use()
surface.PlaySound("soundlocation")
end[/code]
something like this[/QUOTE]
Thanks dude, I will try this now
[editline]9th January 2016[/editline]
It does not work. I would like it to be server sided as well forgot to say that. I put this in shared.lua
function ENT.Use()
surface.PlaySound("garrysmod/save_load1.wav")
end
[del]Entity.Use isn't a real function.[/del]
[CODE]function ENTITY:Use()
self:EmitSound("garrysmod/save_load1.wav")
end[/CODE]
Remember this is serverside code.
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ENTITY/Use]ENTITY/Use[/url]
[QUOTE=BillyOnWiiU;49489061]Entity.Use isn't a real function.
[CODE]function ENTITY:Use()
self:EmitSound("garrysmod/save_load1.wav")
end[/CODE]
Remember this is serverside code.
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ENTITY/Use]ENTITY/Use[/url][/QUOTE]
ah sorry, i forgot about that :V
[QUOTE=BillyOnWiiU;49489061]Entity.Use isn't a real function.
[CODE]function ENTITY:Use()
self:EmitSound("garrysmod/save_load1.wav")
end[/CODE]
Thanks for the help. But I am new to this
ENT:Use( Entity activator, Entity caller, number useType, number value )
What do I change in order to fit the sound I need etc.
Like an example code?
Remember this is serverside code.
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ENTITY/Use]ENTITY/Use[/url][/QUOTE]
Can I have an example as how this would work for me?
To reiterate what BillyOnWiiU said.
ENT.Use is actually a function. What matters is the way it is written.
The difference between a period and a colon is that using a colon will pass itself as the first argument, for example:
[code]
function ENT.Use( self )
end
[/code]
is the same as
[code]
function ENT:Use()
end
[/code]
The example previously provided will emit a sound from the entity ( self ) when used.
[URL="https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index8f77.html"]Here[/URL]'s a list of HL2 sounds.
Okay, thanks for the info guys! I will update if I get this working or not
Update I got it working thanks!
Sorry, you need to Log In to post a reply to this thread.