• Explain this error to me please?
    19 replies, posted
Hi all! Im making an entity that when spawned creates a sound. However when I start the server I get this error straight away. [lua\entities\atmos_radio\sv_auto.lua:1] <name> or '...' expected near '"soundebsebszombie.wav"' All my sounds are in place correctly so it can't be that. Help would be appreciated please! This is the original code for those interested. function ent:EmitSound("sound\ebs\ebszombie.wav" , 100, 100) Msg("Radio Used") -- Used to confirm launch. end
function ent:EmitSound( Sound( "sound\ebs\ebszombie.wav" ), 100, 100 ) Msg("Radio Used") -- Used to confirm launch. end Try that
I did what you said and it now returns this error: [lua\entities\atmos_radio\sv_auto.lua:1] ')' expected near '(' Im baffled xD
function ent:EmitSound( Sound( "sound\ebs\ebszombie.wav" ) ) Msg("Radio Used") -- Used to confirm launch. end
[lua\entities\atmos_radio\sv_auto.lua:1] ')' expected near '( I now get that xD
Shouldn't it be 'function()' not just 'function'
It should just be function as far as I know...
The way he's doing it, it'd have to be function sound( ent ) ent:EmitSound( Sound( "sound\ebs\ebszombie.wav" ) ) Msg("Radio Used") -- Used to confirm launch. end
Fuck. Im an idiot. That might fix it. Hang on...
From my experience I've never had to use Sound() in EmitSound(). Try using forward slashes (/) instead of backslashes (\). Might make a difference.
[QUOTE=TZScribblez;30831380]From my experience I've never had to use Sound() in EmitSound(). Try using forward slashes (/) instead of backslashes (\). Might make a difference.[/QUOTE] yeah that's my bad. It's required if you don't provide the sound path (IE: Weapon_Famas.Single)
If you guys want to help me again?? My Entity won't spawn. My code is as follows... INIT.LUA function ENT:Initialize() self.Entity:SetModel("models\props/cs_office/radio.mdl") self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) self.Entity:SetSolid( SOLID_VPHYSICS ) self.Entity:SetAngles(Vector(0,0,0)) local phys = self.Entity:GetPhysicsObject() end SHARED.LUA ENT.Type = "anim" ENT.Base = "base_gmodentity" ENT.PrintName = "Atmospheric Radio." ENT.Author = "MILTON!" ENT.Category = "Atmosphere" ENT.Contact = "butlerboy5400@hotmail.co.uk" ENT.Purpose = "Plays sounds" ENT.Instructions = "Spawn and enjoy!" ENT.Spawnable = true; ENT.AdminSpawnable = true;
[QUOTE=MILTON!;30831701]If you guys want to help me again?? My Entity won't spawn. My code is as follows... INIT.LUA function ENT:Initialize() self.Entity:SetModel("models\props/cs_office/radio.mdl") self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) self.Entity:SetSolid( SOLID_VPHYSICS ) self.Entity:SetAngles(Vector(0,0,0)) local phys = self.Entity:GetPhysicsObject() end SHARED.LUA ENT.Type = "anim" ENT.Base = "base_gmodentity" ENT.PrintName = "Atmospheric Radio." ENT.Author = "MILTON!" ENT.Category = "Atmosphere" ENT.Contact = "butlerboy5400@hotmail.co.uk" ENT.Purpose = "Plays sounds" ENT.Instructions = "Spawn and enjoy!" ENT.Spawnable = true; ENT.AdminSpawnable = true;[/QUOTE] self.Entity is depreciated, just use self, also local phys = self.Entity:GetPhysicsObject() isn't needed
No luck.
Hey Milton a little off topic talk here if you don't mind Try to use lua tags they highlight the code so it's easier to read. like this [LUA] -- Add Brackets at each end of the words and the start of them, make them face towards the capital letters. LUA /LUA [/LUA]
[QUOTE=Christian;30834872]Hey Milton a little off topic talk here if you don't mind Try to use lua tags they highlight the code so it's easier to read. like this [LUA] -- Add Brackets at each end of the words and the start of them, make them face towards the capital letters. LUA /LUA [/LUA][/QUOTE] My bad. All I need to do is to get the bloody entity to spawn!
Could you paste the entire code?
[lua]function ENT:SpawnFunction(player,trace) if(trace.Hit) then local ent = ents.Create("-insertfoldernamehere-") // set the spawn pos ent:SetPos(trace.HitPos + trace.HitNormal * 16) ent:Spawn() ent:Activate() return ent end end[/lua] Add that, substitute the -insertfoldernamehere- bit. As far as I know, which isn't much, you need ENT:SpawnFunction( p, t ) for it to work in the spawn menu.
[QUOTE=Silv;30906533]-snip-[/QUOTE] Also you can use local ent = ents.Create(ClassName) [QUOTE=MILTON!;30889985]-Snip-[/QUOTE] Change [lua] function ENT:Initialize() self:SetModel("models\props/cs_office/radio.mdl") // First error models\ self:SetMoveType( MOVETYPE_VPHYSICS ) self:SetSolid( SOLID_VPHYSICS ) self:SetAngles(Vector(0,0,0)) local phys = self.Entity:GetPhysicsObject() end[/lua] To [lua] function ENT:Initialize() self.Entity:SetModel("models/props/cs_office/radio.mdl") self:PhysicsInit( SOLID_VPHYSICS ) self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) self.Entity:SetSolid( SOLID_VPHYSICS ) self.Entity:SetAngles(Vector(0,0,0)) local phys = self.Entity:GetPhysicsObject() end[/lua] If it's an sandbox game use the [lua] function ENT:SpawnFunction(player,trace) end [/lua] Else use [lua] local radio = ents.Create("radio") radio:Spawn() radio:Activate()[/lua]
Hey. [QUOTE=techtuts0;30831829]self.Entity is depreciated[/QUOTE] Everything else you wrote is completely irrelevant. Don't try to help people if you really have no clue, it will just make them even more confused. [editline]5th July 2011[/editline] No actually my bad, there's one relevant thing you mentioned. He forgot to call self:PhysicsInit(SOLID_VPHYSICS) right after self:SetModel. As far as I know, his entity won't have proper physics if he doesn't do that. You could have mentioned it directly though, instead of throwing your code at his face with no explanation or whatsoever.
Sorry, you need to Log In to post a reply to this thread.