I am trying to create a new SNPC, in this particular error, i am trying to add an automatic musical theme which starts upon the spawn of the SNPC...
[QUOTE][addons\godzilla snpc\lua\entities\npc_godzilla\init.lua:35] '(' expected near 'self'[/QUOTE]
This is the error i am constantly recieving no matter what i do, on line 35 of the SNPC code, there is supposed to be a "(" near "self" and no matter where i place it, it refuses to work properly.
[CODE] function ENT:OnSpawn
self:(CreateSound = "npc/godzilla/Theme.mp3")
end[/CODE] there is the code, that is'nt the original, and seriously, i've attempted to place brackets everywhere, nothing seems to work... so if you understand how to resolve this, i'd like to know!
Honestly, how do you expect that code to work?
[editline]...[/editline] I've no clue how to play the sound, but I can tell you this:
"Near 'self'" means it must be either before or after self, not one character away.
I guess pepper has his shitposting day today, anyway, go read the Lua-PIL again.
There is a difference between CreateSound and surface.PlaySound.
Won't work either, the sound will get purged because it's not referenced anymore, you need to save it in the entity.
What about
[lua]
function ENT:Initialize()
local self.sound = CreateSound(self, Sound("npc/godzilla/Theme.mp3"))
self.sound:Play()
end
[/lua]
That would work right ?
That would give you a syntax error lol.
Not having to deal with the fact that your sounds aren't working.. I haven't seen anybody point out that his ENT:OnSpawn has no () after it..
Sorry, you need to Log In to post a reply to this thread.