• creating an entity
    9 replies, posted
[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 [code]init.lua:67: '<eof>' expected near 'end'[/code] I am not showing the path for security reasons, but where am I not ending?
[QUOTE=c-unit;21804262][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 [code]init.lua:67: '<eof>' expected near 'end'[/code] I am not showing the path for security reasons, but where am I not ending?[/QUOTE] Remove the 2 unneeded ends at the end of your code
[QUOTE=Cubar;21804295]Remove the 2 unneeded ends at the end of your code[/QUOTE] Thanks! now the only problem is, the entity is not spawning. any ideas?
[QUOTE=c-unit;21804352]Thanks! now the only problem is, the entity is not spawning. any ideas?[/QUOTE] 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.
[QUOTE=DocDoomsday;21805354]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.[/QUOTE] 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.. [code] hook.Add( "PlayerUse", "USINGNPC", "UseNPC" ) [/code] ? [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]
Sorry, you need to Log In to post a reply to this thread.