• Cloaking someone when they use a entity?
    8 replies, posted
How would you make it so when someone uses a entity they get cloaked for 15 seconds. I'm assuming you would use timer.create but, I don't know how to make someone invisible. If someone could show me a example and explain it that would be great.
Untested: [code] ENT:SetUseType(SIMPLE_USE) function ENT:Use(activator) local Col=activator:GetColor() local CloakedColor=Col CloakedColor.a=0 timer.Create("uncloak"..activator:EntIndex(),15,1,function() activator:SetColor(Col) end) activator:SetColor(CloakedColor) end [/code]
I get this error when I try to spawn it: lua\entities\cloaking\init.lua:23: attempt to call method 'SetUseType' (a nil value) Here's my Init.Lua [LUA] AddCSLuaFile("shared.lua") include("shared.lua") AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include('shared.lua') function ENT:Initialize() self.Entity:SetModel( "models/props_junk/shoe001a.mdl" ) self.Entity:PhysicsInit( SOLID_VPHYSICS ) self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) self.Entity:SetSolid( SOLID_VPHYSICS ) local phys = self.Entity:GetPhysicsObject() if (phys:IsValid()) then phys:Wake() end end ENT:SetUseType(SIMPLE_USE) function ENT:Use(activator) local Col=activator:GetColor() local CloakedColor=Col CloakedColor.a=0 timer.Create("uncloak"..activator:EntIndex(),15,1,function() activator:SetColor(Col) end) activator:SetColor(CloakedColor) end function ENT:SpawnFunction( ply, tr ) if ( !tr.Hit ) then return end local ent = ents.Create("cloaking") ent:SetPos( tr.HitPos + tr.HitNormal * 16 ) ent:Spawn() ent:Activate() return ent end function ENT:Think() end [/LUA]
Probably because you are missing the set use type. Try adding this to line 10. self.Entity:SetUseType(SIMPLE_USE)
I still get the same error when I try to spawn it. Any other ideas?
I think you put the entity use type in ENT:Initialise as you do with the physics, model etc.
self:SetUseType(SIMPLE_USE)
[QUOTE=Winter;45643093]self:SetUseType(SIMPLE_USE)[/QUOTE] Wow You bumped a FOUR years old thread. Like seriously, the thread was made 3 years before your account was even made. Congratulations man, I think you're the first :)
[QUOTE=JasonMan34;45643115]Wow You bumped a FOUR years old thread. Like seriously, the thread was made 3 years before your account was even made. Congratulations man, I think you're the first :)[/QUOTE] Good Job, you can count years. This was one of the first results by google, so I answered it for anyone who wanted to know.
Sorry, you need to Log In to post a reply to this thread.