creating an entity

[lua]-- Talking with an NPC
function UseNPC( ply, NPC )
RunConsoleCommand(“My client-sided menu command here”)
Msg( "Player " … ply:Nick() … " Has discussed with Jared the Gun Dealer " )
end

– making an NPC
local ent = ents.Create(“npc_gman”) – This creates our entity
ent:SetPos(-278.422241, -1538.100464, -79.968750)
ent:Spawn() – actually spawning
end

local sequence = self.Entity:LookupSequence(“idle”)
self.Entity:SetSequence(sequence)
end[/lua]

The error I am getting is this


init.lua:67: '<eof>' expected near 'end'

I am not showing the path for security reasons, but where am I not ending?

Remove the 2 unneeded ends at the end of your code

Thanks! now the only problem is, the entity is not spawning. any ideas?

did you bother doing the ENT:Initialize() function anywhere and setting it up? If you didn’t then you need to in order to fix that.

Ah, I did not, I will look into that now.

If you put that in a gamemode it will probbably crash on start, you have to use InitPostEntity to spawn stuff(a hook, check it on wiki)

Doesn’t crash, just doesn’t spawn anything (it doesn’t even load the gamemode )

It’s meant to be

[lua]ent:SetPos(Vector(-278.422241, -1538.100464, -79.968750))[/lua]

And assuming that the sequence bit is in the same file as above…

[lua]local sequence = ent:LookupSequence(“idle”)
ent:SetSequence(sequence)[/lua]

ah, thank you.

I just realized that, don’t I need a hook in the first part
–> [lua] – Talking with an NPC
function UseNPC( ply, NPC )
RunConsoleCommand(“My client-sided menu command here”)
Msg( "Player " … ply:Nick() … " Has discussed with Jared the Gun Dealer " )
end [/lua]

such as…


 hook.Add( "PlayerUse", "USINGNPC", "UseNPC" ) 

?

[editline]05:04PM[/editline]

forgot to add: so it will then look like this

[lua]
– Talking with an NPC
function UseNPC( ply, NPC )
RunConsoleCommand(“My client-sided menu command here”)
Msg( "Player " … ply:Nick() … " Has discussed with Jared the Gun Dealer " )
hook.Add(“PlayerUse”, “USINGNPC”, “UseNPC”)
end
[/lua]