• SWEP not working, may GetAimVector defect?
    2 replies, posted
Hey everybody. Got a very silly problem. i scripted a wepaon a month ago. It always worked, but now, after I ported it to an dedicated server(before i always tried it in a mp-server out of gmod), it wont work correctly. Normally it should shoot a entity in the direction you look. As i said before the portation it worked, but now it shoots very randomly. Its kinda depressing. Here the codepart of the weapon: [lua] local ply = self.Owner local ang = ply:GetAimVector() local right = ply:GetAngles():Right() local spawnpos = ply:GetShootPos()+(ang*64)+(right*20) if SERVER then local ent = ents.Create("stunner_big_pulse") ent:SetPos(spawnpos) ent:SetOwner(ply) ent:Spawn() ent:SetVelocity(ply:GetAimVector()*7500) ent:SetColor(200,200,255,50) end [/lua] Has anybody an idea why it doesnt work correctly? Edit: May the initialize code of the entity is important. The entity only uses Initialize and touch hook: [lua] function ENT:Initialize() self.Entity:PhysicsInitSphere(32,"metal") self.Entity:SetCollisionBounds(Vector()*-12,Vector()*12) self.Entity:SetCollisionGroup(COLLISION_GROUP_PROJECTILE) self.Entity:SetMoveType(MOVETYPE_FLY) self.Entity:DrawShadow(false) self.Phys = self.Entity:GetPhysicsObject() if(self.Phys and self.Phys:IsValid()) then self.Phys:SetMass(1) end end [/lua]
maybe it's the swep itself's code
How do you mean?
Sorry, you need to Log In to post a reply to this thread.