• "Unknown entity type!" in a gamemode that I am working on
    9 replies, posted
So I have decided to work on a little gamemode for the sake of experience, and have run into a bit of a problem. I have followed the simple NPC tutorial on the gmod wiki, with the folder for the entity in gamemode/entities/entities and checked through the code, compared it to other entities etc and nothing seems amiss, however whenever I try and spawn it in with the console command that I have created I get this error: [QUOTE]Attempted to create unknown entity type cop_hire! [ERROR] gamemodes/mprp/gamemode/init.lua:34: Tried to use a NULL entity! 1. Spawn - [C]:-1 2. unknown - gamemodes/mprp/gamemode/init.lua:34 3. unknown - lua/includes/modules/concommand.lua:69 [/QUOTE] The code that I am using to spawn the entity is: [QUOTE]local myEnt = ents.Create("cop_hire") myEnt:Spawn()[/QUOTE] (yes, I know that I haven't positioned it) Any help on this would be useful, if any more information is required please tell me and I will update this thread.
Means cop_hire does not exist. You could have made an error in the code, or named the cop_hire folder incorrectly.
[QUOTE=Ylsid;39218279]Means cop_hire does not exist. You could have made an error in the code, or named the cop_hire folder incorrectly.[/QUOTE] [IMG]http://i.imm.io/SRBC.png[/IMG] [IMG]http://i.imm.io/SRBL.png[/IMG] I've checked through the code and it's spelled correctly and etc.
post the content of your shared.lua
This usually happens if there is a code error preventing a file from loading. Post the contents, I'm guessing you didn't update the | pipes to the GM13 way of doing it for NPC capabilities... Which would be bit.bor( ..., ..., ..., ... ) or ... + ... + ... + ... Addition works on certain ENUMs which are set up for it. Using this method on ENUMs that are set up as 1,2,3,4,5,6,7 etc will not yield proper results, while doing it with ENUMs set up such as 1,10,100,1000, etc will.
Aren't npc's still broken even if you make the above correction? something about ai.GetTaskId always returning nil?
[QUOTE=Acecool;39227240]This usually happens if there is a code error preventing a file from loading. Post the contents, I'm guessing you didn't update the | pipes to the GM13 way of doing it for NPC capabilities... Which would be bit.bor( ..., ..., ..., ... ) or ... + ... + ... + ... Addition works on certain ENUMs which are set up for it. Using this method on ENUMs that are set up as 1,2,3,4,5,6,7 etc will not yield proper results, while doing it with ENUMs set up such as 1,10,100,1000, etc will.[/QUOTE] I've tried using other entities now and making them spawn instead however I still get the same error. Do I need to declare or initialize every entity as the gamemode starts up or something? That's what I was thinking [I]might[/I] be the problem however when looking through the files of other gamemodes to see if they do that they don't seem to.
Are you sure there is no errors on your server startup? GMod won't initialize the entity if there is an error in any of the code.
I'm having the same problem and I'm pretty sure I have no errors on startup
working snpc cl_init [CODE] include( 'shared.lua' ) ENT.RenderGroup = RENDERGROUP_BOTH function ENT:Draw( ) self.Entity:DrawModel( ) end [/CODE] shared.lua [CODE] ENT.Base = "base_ai" ENT.Type = "ai" ENT.PrintName = "" ENT.Author = "" ENT.Contact = "" ENT.Purpose = "" ENT.Instructions = "" ENT.AutomaticFrameAdvance = true function ENT:SetAutomaticFrameAdvance( bUsingAnim ) self.AutomaticFrameAdvance = bUsingAnim end [/CODE] init [CODE] AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include( 'shared.lua' ) function ENT:Initialize( ) self:SetModel( "models/odessa.mdl" ) self:SetHullType( HULL_HUMAN ) self:SetUseType( SIMPLE_USE ) self:SetHullSizeNormal( ) self:SetSolid( SOLID_BBOX ) self:CapabilitiesAdd( CAP_MOVE_GROUND, CAP_OPEN_DOORS, CAP_ANIMATEDFACE, CAP_USE_SHOT_REGULATOR, CAP_TURN_HEAD, CAP_AIM_GUN ) self:SetMaxYawSpeed( 5000 ) local PhysAwake = self.Entity:GetPhysicsObject( ) if PhysAwake:IsValid( ) then PhysAwake:Wake( ) end end function ENT:OnTakeDamage( dmg ) return false end [/CODE] and on your entity are you setting the base entity
Sorry, you need to Log In to post a reply to this thread.