• Can't create Player ragdoll?
    7 replies, posted
Sorry if this is a stupid question, but I'm trying to develop a gamemode and for some reason, I can't seem to get a Player ragdoll to spawn on death with GM:CreateEntityRagdoll(ply,ply) or ply:CreateRagdoll(), I've tried both methods but none have given anything. I've only just touched gamemodes and I'm quite oblivious to how some of this works. So, here's the code: [lua]function GM:DoPlayerDeath() RagdollCreate(pl) end function RagdollCreate(pl) return GM:CreateEntityRagdoll(pl,pl) end[/lua] And here's the error when using GM:CreateEntityRagdoll() (CreateRagdoll did nothing): [QUOTE] [ERROR] gamemodes/impulse/gamemode/player.lua:59: attempt to index global 'GM' (a nil value) 1. RagdollCreate - gamemodes/impulse/gamemode/player.lua:59 2. unknown - gamemodes/impulse/gamemode/player.lua:55[/QUOTE] . So, this worked yesterday, and now, all of a sudden... bam, doesn't spawn anything and gives me an error, I'm not sure on what to do with "GM", because if I change it, something else will most likely screw up... so, any ideas? It is probably the simplest answer and I'm too thick to realize, it wouldn't be the first time...
I assume this is a server side file.
[CODE] function GM:DoPlayerDeath() RagdollCreate(pl) end [/CODE] Try instead [CODE] hook.Add("DoPlayerDeath", "name", function() RagdollCreate(pl) end) [/CODE] Since your problem seems to be the GM Maybe at least. I have no idea what do about Gamemodes.
[QUOTE=vegasx;41841642][CODE] function GM:DoPlayerDeath() RagdollCreate(pl) end [/CODE] Try instead [CODE] hook.Add("DoPlayerDeath", "name", function() RagdollCreate(pl) end) [/CODE] Since your problem seems to be the GM Maybe at least. I have no idea what do about Gamemodes.[/QUOTE] I probably should've added, the GM problem occurs on: return GM:CreateEntityRagdoll(pl,pl), It'll still return a nil value... thanks anyway. [QUOTE=kila58;41841499]I assume this is a server side file.[/QUOTE] I've tried it server and client but none have worked, I'm assuming you mean the file I actually used it on, rather than the actual function.
[CODE] function GM:DoPlayerDeath(pl) RagdollCreate(pl) end [/CODE] It could be having a rough time defining "pl", so add it to the syntax.
[QUOTE=vegasx;41849034][CODE] function GM:DoPlayerDeath(pl) RagdollCreate(pl) end [/CODE] It could be having a rough time defining "pl", so add it to the syntax.[/QUOTE] Seems to have done nothing, sorry. I don't think "pl" is relevant to the error.
You have to use GAMEMODE instead of GM, GM is only used for building the GAMEMODE object/table and can't be used after the first tick. [CODE]function GM:DoPlayerDeath(pl) RagdollCreate(pl) end function RagdollCreate(pl) return GAMEMODE:CreateEntityRagdoll(pl,pl) end [/CODE]
[QUOTE=syl0r;41850735]You have to use GAMEMODE instead of GM, GM is only used for building the GAMEMODE object/table and can't be used after the first tick. [CODE]function GM:DoPlayerDeath(pl) RagdollCreate(pl) end function RagdollCreate(pl) return GAMEMODE:CreateEntityRagdoll(pl,pl) end [/CODE][/QUOTE] I just tried it, no error but it rather did nothing... seems that everything that SHOULD work is infact failing... Guess I should just make the player explode in to a few particle effects on death...
Sorry, you need to Log In to post a reply to this thread.