• ScalePlayerDamage not working?
    2 replies, posted
I coded this little script at around 3AM in the morning. I wake up this morning to test it and it doesn't work. [CODE] HM = {} function HM.WhenPlayerSpawns(ply) ply:SetNWInt("Head", 100) ply:SetNWInt("LArm", 100) ply:SetNWInt("RArm", 100) ply:SetNWInt("LLeg", 100) ply:SetNWInt("RLeg", 100) ply:SetNWInt("Gear", 100) ply:SetNWInt("Chest", 100) ply:SetNWInt("Stomach", 100) print ("Player "..ply.." Has been spawned with full attributes!/n") end hook.Add("PlayerLoadout", "HMSpawn", HM.WhenPlayerSpawns) function HM.ScalePlayerDamage( ply, hitgroup, dmginfo ) if (hitgroup == HITGROUP_HEAD) then ply:SetNWInt("Head", ply:GetNWInt("Head") - dmginfo.GetDamage * 2) elseif (hitgroup == HITGROUP_LEFTARM) then ply:SetNWInt("LArm", ply:GetNWInt("LArm") - dmginfo.GetDamage * 0.5) elseif (hitgroup == HITGROUP_RIGHTARM) then ply:SetNWInt("RArm", ply:GetNWInt("RArm") - dmginfo.GetDamage * 0.5) elseif (hitgroup == HITGROUP_LEFTLEG) then ply:SetNWInt("LLeg", ply:GetNWInt("LLeg") - dmginfo.GetDamage * 0.25) elseif (hitgroup == HITGROUP_RIGHTLEG) then ply:SetNWInt("RLeg", ply:GetNWInt("RLeg") - dmginfo.GetDamage * 0.25) elseif (hitgroup == HITGROUP_GEAR) then ply:SetNWInt("Gear", ply:GetNWInt("Gear") - dmginfo.GetDamage) elseif (hitgroup == HITGROUP_CHEST) then ply:SetNWInt("Chest", ply:GetNWInt("Chest") - dmginfo.GetDamage) elseif (hitgroup == HITGROUP_STOMACH) then ply:SetNWInt("Stomach", ply:GetNWInt("Stomach") - dmginfo.GetDamage) end dmginfo:ScaleDamage(0.001) HM.RunHMCheck(ply) end hook.Add("ScalePlayerDamage", "HM.ScaleDamage", HM.ScalePlayerDamage) [/CODE] HM.RunHMCheck(ply) just prints all the NWInts defined in the OnPlayerSpawned function, Only to test if it's working, of course. However each time I spawn a combine soldier or something and have him fire some shots at me, the NWInts don't change from 100, they all stay at 100. Any ideas?
This is the hook you need , PlayerShouldTakeDamage , it's called whenever a player takes damage , not the one you have now. If i'm wrong don't blame me , half asleep , good night.
GetDamage is a function and you're using it as a variable. Call the function. [lua]dmginfo.GetDamage()[/lua] This is of course, not your issue, but it will cause you problems when the code does execute. I'm assuming it didn't execute because you didn't get an error from it. Print the hitgroup to the console, maybe it's not passing a correct hitgroup.
Sorry, you need to Log In to post a reply to this thread.