iNsanex Posted June 12, 2012 Share Posted June 12, 2012 Hello, I've been working on this script trying to make it so when your shot by a gun you bleed slowly, All of the features work except for if your punched aswell you begin to bleed, How can I fix this? Code: function startBleeding(attacker, weapon, bodypart) local health = getElementHealth(source) local bleeding = getElementData(source, "bleeding") if (health<=100) and (health>1) and (bleeding<=1) then exports['anticheat- system']:changeProtectedElementDataEx(source, "bleeding", 1, false) exports.global:sendLocalMeAction(source, "starts to bleed.") setTimer(bleedPlayer, 5000, 1, source, getPlayerName (source)) end end addEventHandler("onPlayerDamage", getRootElement(), startBleeding) function bleedPlayer(thePlayer, playerName) if (isElement(thePlayer)) then -- still logged in & playing if (playerName==getPlayerName(thePlayer)) then -- make sure they havent changed character local health = getElementHealth(thePlayer) if ( bodypart >= 1 and loss >= 9 ) then setElementHealth(thePlayer, health-2) setTimer(bleedPlayer, 5000, 1, thePlayer, playerName) else exports['anticheat- system']:changeProtectedElementDataEx(thePlayer, "bleeding", 0, false) end end end end Link to comment
Castillo Posted June 12, 2012 Share Posted June 12, 2012 That must be because you're checking if the player lost 9% or higher health, btw what is this? if ( bodypart >= 1 and loss >= 9 ) then The "loss" argument is not defined anywhere. Link to comment
iNsanex Posted June 12, 2012 Author Share Posted June 12, 2012 Ahhhh. That could be one issue, But is there a check i can add in that checks if they was hit by a gun? I figured it'd be something along the lines of weapon >= 22 since 22 is a colt 45, the lowest gun ID Link to comment
Castillo Posted June 12, 2012 Share Posted June 12, 2012 You can try this: function startBleeding ( attacker, weapon, bodypart ) local health = getElementHealth ( source ) local bleeding = getElementData ( source, "bleeding" ) if ( health <= 100 ) and ( health > 1 ) and ( bleeding <= 1 ) and ( weapon >= 22 ) and ( bodypart >= 1 ) then exports [ 'anticheat-system' ]:changeProtectedElementDataEx ( source, "bleeding", 1, false ) exports.global:sendLocalMeAction ( source, "starts to bleed." ) setTimer ( bleedPlayer, 5000, 1, source, getPlayerName ( source ) ) end end addEventHandler ( "onPlayerDamage", getRootElement(), startBleeding ) function bleedPlayer ( thePlayer, playerName ) if ( isElement ( thePlayer ) ) then -- still logged in & playing if ( playerName == getPlayerName ( thePlayer ) ) then -- make sure they havent changed character local health = getElementHealth ( thePlayer ) setElementHealth ( thePlayer, health - 2 ) setTimer ( bleedPlayer, 5000, 1, thePlayer, playerName ) exports [ 'anticheat-system' ]:changeProtectedElementDataEx ( thePlayer, "bleeding", 0, false ) end end end Link to comment
micheal1230 Posted June 12, 2012 Share Posted June 12, 2012 Hello, I've been working on this script trying to make it so when your shot by a gun you bleed slowly, All of the features work except for if your punched aswell you begin to bleed, How can I fix this? Code: function startBleeding(attacker, weapon, bodypart) local health = getElementHealth(source) local bleeding = getElementData(source, "bleeding") if (health<=100) and (health>1) and (bleeding<=1) then exports['anticheat- system']:changeProtectedElementDataEx(source, "bleeding", 1, false) exports.global:sendLocalMeAction(source, "starts to bleed.") setTimer(bleedPlayer, 5000, 1, source, getPlayerName (source)) end end addEventHandler("onPlayerDamage", getRootElement(), startBleeding) function bleedPlayer(thePlayer, playerName) if (isElement(thePlayer)) then -- still logged in & playing if (playerName==getPlayerName(thePlayer)) then -- make sure they havent changed character local health = getElementHealth(thePlayer) if ( bodypart >= 1 and loss >= 9 ) then setElementHealth(thePlayer, health-2) setTimer(bleedPlayer, 5000, 1, thePlayer, playerName) else exports['anticheat- system']:changeProtectedElementDataEx(thePlayer, "bleeding", 0, false) end end end end Why are you making a bleeding script, roleplay scripts already have it Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now