• Player Ragdoll can't respawn after ragdolize.
    9 replies, posted
Hi ! I work on ragdoll code and the only thing I can do with this is to make the player turn into ragdoll but to make it spawn again( with ATTACK Key) to turn normal it wont work, what wrong ? [lua]if CLIENT then end if SERVER then function PlyRagodlize( ply, ent ) local ent = ents.Create( "prop_ragdoll" ) if ent:IsValid() then ent:SetModel( ply:GetModel() ) ent:SetKeyValue( "origin", ply:GetPos().x .. " " .. ply:GetPos().y .. " " .. ply:GetPos().z ) ent:Spawn() ent:Activate() ent:SetVar("ragdollname",ply:Nick().."") ply:DrawViewModel(false) ply:Spectate( OBS_MODE_CHASE ) ply:SpectateEntity( ent ) ply:StripWeapons() ply.curweapons = {} for num, weapon in pairs(ply:GetWeapons()) do ply.curweapons[num] = weapon:GetClass() end else if( input.IsKeyDown ( ATTACK ) ) then ply:SetModel( ent:GetModel() ) ent:Remove() ply:SetAngles( ent:GetAngles() ) ply:DrawViewModel(true) ply:DrawWorldModel(true) ply:UnSpectate() ply:UnLock() ply:Spawn() ply:SetPos( ent:GetPos() + Vector(0, 0, 100) ) ply:SetVelocity(ply:GetPhysicsObject():GetVelocity()) end end end concommand.Add("Ragdollize", PlyRagodlize) end[/lua]
lol [highlight](User was banned for this post ("Why reply?" - Greeman))[/highlight]
Could be because you removed the entity, and then called it's position after. Also, lemmiwinkz, contribute, or get out.
[QUOTE=HeavyMtl123;22394422]Could be because you removed the entity, and then called it's position after. Also, lemmiwinkz, contribute, or get out.[/QUOTE] I'm not sure about what do you mean, but I tried to put ent:Remove() at the end but nothing happening. Maybe my KeyInput is wrong ?
Let me check on the wiki for a solution, I will be back with an answer hopefully
Ok cool thanks, I tried something on the fly but the In_Key function seem to be broken ? [lua]if CLIENT then function KPress() local players = player.GetAll() for _, player in ipairs( players ) do if( player:KeyPressed( IN_ATTACK ) ) then Msg( "You pressed the forward key!\n" ) end end end hook.Add("KeyDown","Keys", KPress ) end[/lua] Edit: Ok the one you gave me seem to work [code] Lotus006 pressed 1 [/code]
[URL]http://wiki.garrysmod.com/?title=Player.KeyPressed[/URL] You beat me to it, fucking ninja :ninja: [editline]06:16PM[/editline] But try this as well [url]http://wiki.garrysmod.com/?title=Gamemode.KeyPress[/url] [editline]06:18PM[/editline] Also, are the special links for the wiki pages broken for you? [B][URL="http://wiki.garrysmod.com/?title=Gamemode.KeyPress"]Gamemode.KeyPress [img][/URL][URL="http://wiki.garrysmod.com/favicon.ico%5B/img%5D%5B/url%5D%5B/b%5D"]http://wiki.garrysmod.com/favicon.ico[/img][/URL] [/B]Areyou getting this when copy and pasting the links just above the Example?
The wiki pages seem to work well but the last paste below is just in example for testing but for now have you an idea how I can set it with LocalPlayer():Spawn() ?
[lua]if CLIENT then function KPress(ply) local players = player.GetAll() local pos = ply:GetPos() for _, player in ipairs( players ) do if( player:KeyPressed( IN_ATTACK ) ) then ply:Spawn(pos) end end end hook.Add("KeyDown","Keys", KPress ) end[/lua] I'm not entirely sure if the ply:Spawn is correct, because I have only used it as ply:Spawn without any arguments.
Nah, this won't work, you cannot call it on the client ;) also no argument for Spawn!
Sorry, you need to Log In to post a reply to this thread.