Drug Sounds and Spawning

I need some help with playing sounds after an entity is used, and also spawning that entity. I think I know how to code some of it, but I don’t know what to do for the rest. Here is the first bit of my code:

function ENT.Initialize()
self.Entity:SetModel(“models/Gibs/metal_gib2.mdl”)
end

function ENT:Use()
self.Entity:Remove()
Player.EmitSound(“vo/npc/male01/headcrabs01.wav”,300,1)
timer.Simple(1)
Player.EmitSound(“vo/npc/male01/headcrabs01.wav”,300,1.2)
timer.Simple(0.8)
Player.EmitSound(“vo/npc/male01/headcrabs01.wav”,300,1.4)
ents.Create( “env_explosion” )
Player.Kill()
end

Is this correct? What do I need to add to make it spawnable?

You need to firstly learn basic syntax. Most of your object methods are being called incorrectly.

  • Player:EmitSound( “vo/npc/male01/headcrabs01.wav”, 300, 1 )
  • function ENT:Initialize()
  • Player:Kill()

(Please don’t think the * is apart of the code it is more implying a correction like you’d do over an instant message.)

As for how to create a basic SENT (Scripted Entity) please check out this tutorial from the wiki: http://wiki.garrysmod.com/?title=Ricky’s_Example_SENT

You might also want to check how to use timer.Simple properly: http://wiki.garrysmod.com/?title=Timer.Simple the code you want to execute after the delay is apart of the functions parameters. Those timers will do nothing.

Finally to spawn your SENT just spawn it like you would any entity: http://wiki.garrysmod.com/?title=Ents.Create

Thanks a bunch!