Ok guys, so basicly I got this code here
Init.lua (ent) :
[lua]
function ENT:Initialize()
self.DieTime = CurTime() + 9
local pl = self.Entity:GetOwner()
local aimvec = pl:GetAimVector()
self.Entity.Team = pl:Team()
self.Entity:SetPos(pl:GetShootPos() + pl:GetAimVector() * 30)
self.Entity:SetAngles(pl:GetAimVector():Angle()* math.random(1,45))
self.Entity:SetModel("models/weapons/w_knife_t.mdl")
self.Entity:PhysicsInit(SOLID_VPHYSICS)
self.Entity:SetCollisionGroup(COLLISION_GROUP_INTERACTIVE)
local phys = self.Entity:GetPhysicsObject()
if phys:IsValid() then
phys:SetMass(200)
end
self.Touched = {}
self.OriginalAngles = self.Entity:GetAngles()
end
[/lua]
And the shared.lua (basic weapon)
[lua]
if SERVER then
concommand.Add("Shootknife", function(ply)
if ply:IsUserGroup("owner") or ply:IsUserGroup("coleader") or ply:IsUserGroup("thirdleader") then
local Knife = ents.Create("knifettt")
ply:EmitSound(ShootSound)
Knife:SetPos(ply:EyePos()+ ply:GetAimVector()* 16)
Knife:SetAngles(ply:EyeAngles())
Knife:SetPhysicsAttacker(ply)
Knife:SetOwner(ply)
Knife:Spawn()
Knife:GetPhysicsObject():ApplyForceCenter(ply:GetAimVector():GetNormalized()* math.pow(ply:GetEyeTrace().HitPos:Length(), 3))
Knife:GetPhysicsObject():ApplyForceOffset(VectorRand()* math.Rand(10000,30000), ply:GetShootPos()+ VectorRand()* math.Rand(0.5,1.5))
end
end)
end
[/lua]
But now when I shoot the knife it goes spin around like crazy, I wanted it like, its still affected by gravity but the spinning needs to stop and the sharp side of the knife goes forward.
Thanks ^^
Sorry, you need to Log In to post a reply to this thread.