Usable Ragdoll

Hi

For some reason this script doesn’t work. It’s supposed to print “hi” when “E” is pressed on a ragdoll.




function PlayerUseRagdoll( ent, key )
 
 if key == KEY_E then
 
 if ent:GetClass() == ("prop_ragdoll") then
 
		print ("hi" )
 
	end
	end
end
hook.Add("KeyRelease", "KeyReleasedHook", PlayerUseRagdoll)



The first argument of that hook is not ent, but player.

[editline]16th September 2014[/editline]

Use this hook instead:

[editline]16th September 2014[/editline]

You see, wiki solves your problem, if only you would give enough cares to look into it.

That made like no difference…

The hooks didnt even work btw, and I did look into it, I went on that page and used the code already. Guess what? still didnt work.

Add some debug messages.

  1. See if the hook is called
  2. See what ent:GetClass prints
    etc. etc.

And make sure your lua file is included :stuck_out_tongue:

Where do you put the code?

I already did. It works when key is pressed if I remove the if ent:getClass code but stops working when its in, even when I press “E” on ragdolls.

Print what ent:GetClass() returns to see if it’s actually a prop_ragdoll you’re looking at.

Its in a autorun file

[editline]16th September 2014[/editline]

lemme try that now…

And make sure you use PlayerUse and not KeyRelease as KeyRelease doesn’t have an “ent” parameter.

Its not working at all now.

But you do run it server-side right?

It’s a serverside hook.

Well its in the autorun folder