Jump to content

Bleeding script Error


iNsanex

Recommended Posts

Posted

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 

Posted

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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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

Posted

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 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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

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