I can't figure out why this won't make the target ragdoll to simulate a knockout. Any help?
if (SERVER) then ent:CreateRagdoll() end
Where is the code being ran?
In my addons folder. Here is the rest of the code.
AddCSLuaFile()
SWEP.Author = "DriedSponge"
SWEP.Base = "weapon_base"
SWEP.Category = "DriedSponge's SWEPS"
SWEP.PrintName = "Knock Out Baton"
SWEP.Instructions = [[Left-Click: Knocks out the target fir 30 seconds]]
SWEP.ViewModel = "models/weapons/v_stunbaton.mdl"
SWEP.ViewModelFlip = false
SWEP.UseHands = true
SWEP.WorldModel = "models/weapons/w_stunbaton.mdl"
SWEP.SetHoldType = "melee"
SWEP.Weight = 5
SWEP.AutoSwitchTo = true
SWEP.AutoSwitchFrom = false
SWEP.Slot = 1
SWEP.SlotPos = 1
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = false
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Ammo = "none"
SWEP.Primary.Automatic = false
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Ammo = "none"
SWEP.Secondary.Automatic = false
SWEP.ShouldDropOnDie = false
local SwingSound = Sound( "Weapon_Crowbar.Single" )
local HitSound = Sound( "Weapon_Crowbar.Melee_Hit" )
function SWEP:Initialize()
self:SetWeaponHoldType( "melee" )
end
function SWEP:PrimaryAttack()
local ply = self:GetOwner()
ply:LagCompensation( true )
local shootpos = ply:GetShootPos()
local endshootpos = shootpos + ply:GetAimVector() * 70
local tmin = Vector( 1, 1, 1) * -10
local tmax = Vector( 1, 1, 1) * 10
local tr = util.TraceHull( {
start = shootpos,
endpos = endshootpos,
filter = ply,NPC,
mask = MASK_SHOT_HULL,
mins = tmin,
maxs = tmax } )
local ent = tr.Entity
if ( IsValid( ent ) && ( ent:IsPlayer() || ent:IsNPC() ) ) then
self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER )
ply:SetAnimation( PLAYER_ATTACK1 )
if (CLIENT) then ply:EmitSound( HitSound ) end
if (SERVER) then ent:CreateRagdoll() end
end
ply:LagCompensation( false )
end
https://files.facepunch.com/forum/upload/290512/691800e3-c379-4f93-8b6b-212c1bff88b9/image.png
https://files.facepunch.com/forum/upload/290512/8a39ede7-3437-45c8-b7f6-de7219595fd4/image.png
https://files.facepunch.com/forum/upload/290512/21081a2a-8dfa-44ce-896e-f4316020225b/image.png
Try to test it on bot , remove IsNPC check.
When I tested it on a bot it just spawned the players ragdoll version of their current model and the bot itself stays moving around.
Sorry, you need to Log In to post a reply to this thread.