• Knockout script not working
    5 replies, posted
Hey guys, I'm making a new gamemode with a bud of mine called LostRP. Anyways, I'm working on a knockout script and its not working. [CODE] function GM:ScalePlayerDamage( ply, hitgroup, dmginfo ) if ( hitgroup == HITGROUP_HEAD ) and ply:GetAttacker() and HasWeapon("weapon_fists") then ply:DrawMaterialOverlay( "models/props_c17/fisheyelens", -0.06 ) ply:IsRagdoll() if false then ply:CreateRagdoll( timer.Simple( 20, function() ply.RagDoll = false end ) ) end timer.Simple( 20, function() ply.KnockedOut = false end ) end end [/CODE] Anyone here know why? No errors, it just doesn't work.
try this: [code] function GM:ScalePlayerDamage( ply, hitgroup, dmginfo ) if ( hitgroup == HITGROUP_HEAD ) and ply:GetAttacker() and HasWeapon("weapon_fists") then if ply.KnockedOut then return end ply:DrawMaterialOverlay( "models/props_c17/fisheyelens", -0.06 ) if !ply:GetRagdollEntity() then ply:CreateRagdoll() end ply.KnockedOut = true timer.Simple(20, function() ply.KnockedOut = false ply:GetRagdollEntity():Remove() end) end end [/code]
[QUOTE=whitestar;48783292]try this: [code] function GM:ScalePlayerDamage( ply, hitgroup, dmginfo ) if ( hitgroup == HITGROUP_HEAD ) and ply:GetAttacker() and HasWeapon("weapon_fists") then if ply.KnockedOut then return end ply:DrawMaterialOverlay( "models/props_c17/fisheyelens", -0.06 ) if !ply:GetRagdollEntity() then ply:CreateRagdoll() end ply.KnockedOut = true timer.Simple(20, function() ply.KnockedOut = false ply:GetRagdollEntity():Remove() end) end end [/code][/QUOTE] Didn't work. No errors though. But still thank you
try using the playerhurt hook instead: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerHurt]GM/PlayerHurt[/url]
[CODE] function GM:ScalePlayerDamage( ply, hitgroup, dmginfo ) if( ply:IsPlayer() and dmginfo:GetAttacker():IsPlayer() and dmginfo:GetAttacker():GetActiveWeapon():GetClass("weapon_fists" ) ) then ply:CreateRagdoll() timer.Simple( 20, function() local ent = ply:GetRagdollEntity() local pos = ent:GetPos() ent:Remove() ply:Spawn() ply:SetPos( pos ) end ) end end hook.Add("ScalePlayerDamage", "Some Name", ScalePlayerDamage) [/CODE] Sorry to bump but I'm still having major problems to get this to work, I've tried prints, reworking the code, almost everything. Its still not working. It's in init.lua and I just can't get it to work. Anyone here know a fix? :)
You're calling Scale Player Damage twice here, by the way. don't use (hook.Add("ScalePlayerDamage", "Some Name", ScalePlayerDamage)) or remove the GM from your function and make it local V:
Sorry, you need to Log In to post a reply to this thread.