So I've recently want to make my server's deagle to remove the ragdolls or people head by headshot and this is what i use and still didnt worked though :
[CODE]function SWEP:PrimaryAttack(worldsnd)
self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
if not self:CanPrimaryAttack() then return end
if not worldsnd then
self.Weapon:EmitSound( self.Primary.Sound, self.Primary.SoundLevel )
elseif SERVER then
sound.Play(self.Primary.Sound, self:GetPos(), self.Primary.SoundLevel)
end
self:ShootBullet( self.Primary.Damage, self.Primary.Recoil, self.Primary.NumShots, self:GetPrimaryCone() )
self:TakePrimaryAmmo( 1 )
local owner = self.Owner
if not IsValid(owner) or owner:IsNPC() or (not owner.ViewPunch) then return end
local trace = self.Owner:GetEyeTrace();
if( trace.Entity:IsPlayer() or trace.Entity:IsNPC() == "ValveBiped.Bip01_Head1") then
trace:ManipulateBoneScale(tr.Entity:LookupBone("ValveBiped.Bip01_Head1"), Vector(0, 0, 0))
end
owner:ViewPunch( Angle( math.Rand(-0.2,-0.1) * self.Primary.Recoil, math.Rand(-0.1,0.1) *self.Primary.Recoil, 0 ) )
end
if CLIENT then
function SWEP:ResetViewModelBones(onlyscale)
local MySelf = LocalPlayer()
if not self:IsValid() or not IsValid(MySelf) or MySelf:GetActiveWeapon() ~= self then return end
local vm = MySelf.GetViewModel and MySelf:GetViewModel()
if IsValid(vm) then
local v = Vector(1, 1, 1)
if onlyscale then
for i=0, vm:GetBoneCount() - 1 do
vm:ManipulateBoneScale(i, v)
end
else
local a = Angle(0, 0, 0)
for i=0, vm:GetBoneCount() - 1 do
vm:ManipulateBoneScale(i, v)
vm:ManipulateBoneAngles(i, a)
vm:ManipulateBonePosition(i, vector_origin)
end
end
end
end
function SWEP:BuildBonePositions()
if self.v_bonemods and self:IsValid() and LocalPlayer():GetActiveWeapon() == self then
local vm = LocalPlayer():GetViewModel()
if IsValid(vm) then
self:ResetViewModelBones()
for k, v in pairs( self.v_bonemods ) do
local boneid = vm:LookupBone(k)
if boneid then
vm:ManipulateBoneScale(boneid, v.scale)
vm:ManipulateBoneAngles(boneid, v.angle)
vm:ManipulateBonePosition(boneid, v.pos)
end
end
end
end
end
function SWEP:Think()
self:BuildBonePositions()
self:CreateModels(self.VElements)
self:CreateModels(self.WElements)
end
SWEP.vRenderOrder = nil
function SWEP:ViewModelDrawn()
local vm = self.Owner:GetViewModel()
if !IsValid(vm) then return end
if (!self.VElements) then return end
if (self.ShowViewModel == nil or self.ShowViewModel) then
vm:SetColor(color_white)
else
// we set the alpha to 1 instead of 0 because else ViewModelDrawn stops being called
vm:SetColor(Color(255,255,255,1))
end
if (!self.vRenderOrder) then
// we build a render order because sprites need to be drawn after models
self.vRenderOrder = {}
for k, v in pairs( self.VElements ) do
if (v.type == "Model") then
table.insert(self.vRenderOrder, 1, k)
elseif (v.type == "Sprite" or v.type == "Quad") then
table.insert(self.vRenderOrder, k)
end
end
end
for k, name in ipairs( self.vRenderOrder ) do
local v = self.VElements[name]
if (!v) then self.vRenderOrder = nil break end
local model = v.modelEnt
local sprite = v.spriteMaterial
if (!v.bone) then continue end
local pos, ang = self:GetBoneOrientation( self.VElements, v, vm )
if (!pos) then continue end
if (v.type == "Model" and IsValid(model)) then
model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
ang:RotateAroundAxis(ang:Up(), v.angle.y)
ang:RotateAroundAxis(ang:Right(), v.angle.p)
ang:RotateAroundAxis(ang:Forward(), v.angle.r)
model:SetAngles(ang)
model:SetModelScaleVector(v.size)
if (v.material == "") then
model:SetMaterial("")
elseif (model:GetMaterial() != v.material) then
model:SetMaterial( v.material )
end
if (v.skin and v.skin != model:GetSkin()) then
model:SetSkin(v.skin)
end
if (v.bodygroup) then
for k, v in pairs( v.bodygroup ) do
if (model:GetBodygroup(k) != v) then
model:SetBodygroup(k, v)
end
end
end
if (v.surpresslightning) then
render.SuppressEngineLighting(true)
end
render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
render.SetBlend(v.color.a/255)
model:DrawModel()
render.SetBlend(1)
render.SetColorModulation(1, 1, 1)
if (v.surpresslightning) then
render.SuppressEngineLighting(false)
end
elseif (v.type == "Sprite" and sprite) then
local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
render.SetMaterial(sprite)
render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
elseif (v.type == "Quad" and v.draw_func) then
local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
ang:RotateAroundAxis(ang:Up(), v.angle.y)
ang:RotateAroundAxis(ang:Right(), v.angle.p)
ang:RotateAroundAxis(ang:Forward(), v.angle.r)
cam.Start3D2D(drawpos, ang, v.size)
v.draw_func( self )
cam.End3D2D()
end
end
end
SWEP.wRenderOrder = nil
function SWEP:DrawWorldModel()
if (self.ShowWorldModel == nil or self.ShowWorldModel) then
--self:DrawModel()
end
if (!self.WElements) then return end
if (!self.wRenderOrder) then
self.wRenderOrder = {}
for k, v in pairs( self.WElements ) do
if (v.type == "Model") then
table.insert(self.wRenderOrder, 1, k)
elseif (v.type == "Sprite" or v.type == "Quad") then
table.insert(self.wRenderOrder, k)
end
end
end
if (IsValid(self.Owner)) then
bone_ent = self.Owner
else
// when the weapon is dropped
bone_ent = self
end
for k, name in pairs( self.wRenderOrder ) do
local v = self.WElements[name]
if (!v) then self.wRenderOrder = nil break end
local pos, ang
if (v.bone) then
pos, ang = self:GetBoneOrientation( self.WElements, v, bone_ent )
else
pos, ang = self:GetBoneOrientation( self.WElements, v, bone_ent, "ValveBiped.Bip01_R_Hand" )
end
if (!pos) then continue end
local model = v.modelEnt
local sprite = v.spriteMaterial
if (v.type == "Model" and IsValid(model)) then
model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
ang:RotateAroundAxis(ang:Up(), v.angle.y)
ang:RotateAroundAxis(ang:Right(), v.angle.p)
ang:RotateAroundAxis(ang:Forward(), v.angle.r)
model:SetAngles(ang)
model:SetModelScaleVector(v.size)
if (v.material == "") then
model:SetMaterial("")
elseif (model:GetMaterial() != v.material) then
model:SetMaterial( v.material )
elseif (v.material ~= "") then
model:SetMaterial( v.material )
end
if (v.skin and v.skin != model:GetSkin()) then
model:SetSkin(v.skin)
end
if (v.bodygroup) then
for k, v in pairs( v.bodygroup ) do
if (model:GetBodygroup(k) != v) then
model:SetBodygroup(k, v)
end
end
end
if (v.surpresslightning) then
render.SuppressEngineLighting(true)
end
render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
render.SetBlend(v.color.a/255)
model:DrawModel()
render.SetBlend(1)
render.SetColorModulation(1, 1, 1)
if (v.surpresslightning) then
render.SuppressEngineLighting(false)
end
elseif (v.type == "Sprite" and sprite) then
local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
render.SetMaterial(sprite)
render.DrawSprite
Are you getting any actual errors? Or is it just not working?
[QUOTE=Fortune11709;43410890]Are you getting any actual errors? Or is it just not working?[/QUOTE]
It's just not working, the ragdolls still does not remove their head by headshot.
I don't think you can manipulate the bones of standard corpses... however I do know that it's possible to override the ragdolling on player death, from there you could probably create a client side ragdoll and then manipulate the bones of that.
[QUOTE=BFG9000;43415254]I don't think you can manipulate the bones of standard corpses... however I do know that it's possible to override the ragdolling on player death, from there you could probably create a client side ragdoll and then manipulate the bones of that.[/QUOTE]
It's perfectly possible, he's just setting the scale of the living player's head. The corpse of the player is a separate entity so it's doing basically nothing.
Sorry, you need to Log In to post a reply to this thread.