I have to set a player ragdoll's head bone scaled down to 0 from the server.

I know that most of the methods I’ll have to use are client side, that’s why I am asking.


target:Kill()
local ragdoll = target:GetRagdollEntity()
for k, v in ipairs (player.GetAll()) do
v:SendLua("local bone = Entity(" .. ragdoll:EntIndex() .. "):GetBoneMatrix(6); bone:Scale(Vector(0, 0, 0)); Entity(" .. ragdoll:EntIndex() .. "):SetBoneMatrix(6, bone)")
end

It says the entity is NULL.

Just a heads up:

[lua]for k, v in ipairs (player.GetAll()) do[/lua]

oh I missed it on this topic, but I have it in the original code xD

Player.GetRagdollEntity
Returns the ragdoll entity of a (dead or not if you used Player.CreateRagdoll()) player

It’s returning NULL because you’re trying to use it on something that doesn’t exist in the world. Try going in sandbox and suiciding then run your code if it’s correct.

Did you see this? “target:Kill()”

Did you see this?
“for k, v in ipairs (player.GetAll()) do”

You’re sending it to all players on the server so some of them can be alive.
[lua]
target:Kill()
local ragdoll = target:GetRagdollEntity()
if ValidEntity(ragdoll) then
target:SendLua(“local bone = Entity(” … ragdoll:EntIndex() … “):GetBoneMatrix(6); bone:Scale(Vector(0, 0, 0)); Entity(” … ragdoll:EntIndex() … “):SetBoneMatrix(6, bone)”)
end
[/lua]

Genius, like that only the guy that dies will be able to see his ragdoll with the head scaled down.

The way I did it

target:Kill()
local ragdoll = target:GetRagdollEntity()
for k, v in ipairs (player.GetAll()) do
v:SendLua(“local bone = Entity(” … ragdoll:EntIndex() … “):GetBoneMatrix(6); bone:Scale(Vector(0, 0, 0)); Entity(” … ragdoll:EntIndex() … “):SetBoneMatrix(6, bone)”)
end

Explaination:

target:Kill()
-----Kill the target

local ragdoll = target:GetRagdollEntity()
-----Get target’s ragdoll

for k, v in ipairs (player.GetAll()) do
v:SendLua(“local bone = Entity(” … ragdoll:EntIndex() … “):GetBoneMatrix(6); bone:Scale(Vector(0, 0, 0)); Entity(” … ragdoll:EntIndex() … “):SetBoneMatrix(6, bone)”)
end
-----Get ALL the players to see the target ragdoll’s head completely deflated.

However, gmod says “Attempted to index a NULL Entity”

I know exactly what your code does. If you can explain it you should be able to solve it by yourself.

Oh my god, you’re a di–

Just because this Sir: Razor can explain it doesn’t mean that it fixes the problem of the NULL Entity in Garry’s Mod, this is truly a semi-dificult problem to fix, and would need less arguing to fix it.

._. And where the hell did you pop out from?

I’m just kidding, I don’t anything about coding, but seriously Razor is experienced it seems, yet he’ll just need the information on how to fix the NULL Entity on Gmod. Kthbai.

Spam bot or retard.

The fuck? Did you just make an account and reply to it or have a friend make one and then reply to him?
No, just no.

Did you try Brandon’s code or not? Did you get the same error from it?

What?

And no I didn’t try his code, I don’t see how could checking if the entity is valid resolve the null entity problem.

I’m about to test it myself once I can update Steam.
Also, too obvious.

Because you’re checking if the ragdoll entity is valid…?

valid != null

What is obvious?

What is Brandon’s Code?

I know for a fact that it is valid because, (I didn’t put the code here but) I also did some more stuff to the ragdoll entity before wanting to deflate the head, and it worked.

[editline]22nd August 2012[/editline]

What is love