Wondering if its possible to make a ragdoll register damage and transfer it to the owner of the ragdoll, i have tried using damage hooks and dmg info but it dosent work, Is it even possible and if not do you have any alternatives?
local function adddamage( target, dmg )
local t = v.sleepspawninfo
if (target:IsRagdoll() and target.isslept) then
t.health = (t.health - dmg:GetDamage())
end
end
hook.Add( "EntityTakeDamage", "ragdolldmg", adddamge )
So you want to do:
Player shoots Ragdoll
Player who spawned the ragdoll takes that damage
Player is ragdolled and when they get shot in ragdoll form they still take damage.
Bump
Assuming you used Player/CreateRagdoll, you can apply damage directly to the ragdoll owner. Example:
hook.Add("EntityTakeDamage", "ragdolldmg", function(pTarget, dmg)
-- Ragdoll was damaged
if (pTarget:IsRagdoll() and pTarget.isslept) then
local pPlayer = pTarget:GetRagdollOwner()
if (pPlayer:IsValid()) then
pPlayer:TakeDamageInfo(dmg)
end
end
end)
Currently using:
local sleepingmodel = ents.Create( "prop_ragdoll" )
sleepingmodel:SetPos( v:GetPos() )
local velocity = Vector( 0,0,0 )
sleepingmodel:SetAngles( v:GetAngles() )
sleepingmodel:SetModel( v:GetModel() )
sleepingmodel:Spawn()
sleepingmodel:Activate()
v:SetParent( sleepingmodel )
v.isslept = true
to create the users ragdoll, its a similar code as what is used in the ulx ragdoll command.
You'll have to manually store the ragdoll entity on the user then and retrieve it in the hook instead of using GetRagdollOwner.
How would I do that, because I'm guessing at the moment when it's asking if the ragdoll is slept that it has no data since the ragdoll is the player.
Just like you stored the isslept variable to the player, you can store a separate variable for the ragdoll.
would using Entity/GetParent do the same thing?
No, and you shouldn't parent the player to the ragdoll.
Why not? im trying to get the player to be the ragdoll as if the person has collapsed or something.
Just make the player spectate the ragdoll then - players weren't meant to be parented to anything and can cause physics issues.
Sorry, you need to Log In to post a reply to this thread.