Jump to content

Bleeding script Error


iNsanex

Recommended Posts

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

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...