• Entity errors
    7 replies, posted
When ever I try to spawn my entity via a gun, it says entities/firecan/cl_init.lua:6: function arguments expected near 'end' Folder = entities/firecan Couldn't register Scripted Entity firecan - the Type field is empty! Here is the code to the entity init.lua: [CODE]include ('shared.lua') function ENT:Draw() self.Entity:DrawModel end[/CODE] Thanks
[lua]self.Entity:DrawModel()[/lua] You missed the Brackets (or Parenthesis).
[QUOTE=NullPoint;19941203][lua]self.Entity:DrawModel()[/lua] You missed the Brackets (or Parenthesis).[/QUOTE] Oh lol thanks again. [editline]05:03PM[/editline] Now it says that I can't create my entity. I have this in my script "local fcan = ents.Create( "firecan" )" and it can't create the entity Firecan. How do I make it work?
When it tries to run that line do you get an error? Presumably there are lines after this to set its position, angle, velocity and most importantly fcan:Spawn() and fcan:Activate() to make sure it's fully up and running?
[QUOTE=MegaJohnny;19942114]When it tries to run that line do you get an error? Presumably there are lines after this to set its position, angle, velocity and most importantly fcan:Spawn() and fcan:Activate() to make sure it's fully up and running?[/QUOTE] Yeah it has fcan:Spawn() and fcan:Activate() as well as position, angles and velocity. [editline]06:02PM[/editline] Here the part where it skrew up: [code]function SWEP:SecondaryAttack() if (!self:CanSecondaryAttack()) then return end if !SERVER then return end local MyAngles = Angle(90, 0, 0) local fcan = ents.Create( "firecan" ) fcan:SetPos (self.Owner:EyePos() + (self.Owner:GetAimVector() * 16)); fcan:SetAngles(self.Owner:EyeAngles() + MyAngles) fcan:SetPhysicsAttacker(self.Owner) fcan:Spawn() fcan:Activate() local physx = fcan:GetPhysicsObject() physx:SetMass(15) physx:ApplyForceCenter(self.Owner:GetAimVector()*100000) self:ShootEffects () self:TakeSecondaryAmmo(1) cleanup.Add (self.Owner, "props", canF) undo.Create ("Fire Can") undo.AddEntity (firecan) undo.SetPlayer (self.Owner) undo.Finish() self.Weapon:SetNextSecondaryFire( CurTime() + self.Delay ) end[/code]
Well I can see your cleanup.Add and undo.AddEntity lines have the wrong name for the fire can variable, but obviously it's failing to even create the entity. What happens when you try to do the secondary attack, does it give you an error or simply do nothing?
[QUOTE=MegaJohnny;19943319]Well I can see your cleanup.Add and undo.AddEntity lines have the wrong name for the fire can variable, but obviously it's failing to even create the entity. What happens when you try to do the secondary attack, does it give you an error or simply do nothing?[/QUOTE] Oh yeah lol thanks for pointing that out, but it give the error.
Bump [editline]06:45PM[/editline] NVM worked it out, setammo doesn't work.
Sorry, you need to Log In to post a reply to this thread.