Jump to content

death account


BorderLine

Recommended Posts

hi everyone.. well i found this on comunity, but is bug

the bug is, when im do /kill, my player dead, and the account give one more to scoreboard

but when some player killme, dont giveme one to death score.

I dont know if im explian.

here is the code

addEventHandler ( "onPlayerWasted", root, 
    function( totalAmmo, killer, killerWeapon, bodypart, stealth ) 
        if killer then 
            local account = getPlayerAccount ( killer ) 
            if killer ~= source then 
                setAccountData( account,"totalkillsdeaths.Kills",tonumber( getAccountData( account,"totalkillsdeaths.Kills" ) or 0 ) +1 ) 
                setElementData( killer, "Kills", tonumber( getAccountData( account,"totalkillsdeaths.Kills" ) ) ) 
            end  
        else 
            local accountSource = getPlayerAccount ( source ) 
            setAccountData( accountSource,"totalkillsdeaths.Deaths",tonumber( getAccountData(accountSource,"totalkillsdeaths.Deaths") or 0 ) +1 ) 
            setElementData( source, "Deaths", tonumber( getAccountData( accountSource,"totalkillsdeaths.Deaths" ) ) ) 
        end 
    end 
)  

if someone can found the error.

Link to comment

That's because you are checking if there's a "killer", and that's why it works when you do /kill but not when someone kills you.

addEventHandler ( "onPlayerWasted", root, 
    function ( totalAmmo, killer, killerWeapon, bodypart, stealth ) 
        if ( killer ) then 
            local account = getPlayerAccount ( killer ) 
            if ( killer ~= source ) then 
                setAccountData ( account, "totalkillsdeaths.Kills", tonumber ( getAccountData ( account, "totalkillsdeaths.Kills" ) or 0 ) +1 ) 
                setElementData ( killer, "Kills", tonumber ( getAccountData ( account, "totalkillsdeaths.Kills" ) ) ) 
            end 
        end 
        local accountSource = getPlayerAccount ( source ) 
        setAccountData ( accountSource, "totalkillsdeaths.Deaths", tonumber ( getAccountData ( accountSource, "totalkillsdeaths.Deaths" ) or 0 ) +1 ) 
        setElementData ( source, "Deaths", tonumber ( getAccountData ( accountSource, "totalkillsdeaths.Deaths" ) ) ) 
    end 
) 

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