Jump to content

[help] scores script


Nas

Recommended Posts

Posted

hi

can anyone help me

i have script save [ kills, deaths, Ratio]

my problim

kills is work and good

deaths no work if kill with weapons :(

if kill me with admin panel or [F1 Freeroam] he let me +1 deaths

sorry for my english :P

code

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

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

Try that.

Posted

Well, you were checking if there was a killer, if there was, don't increment deaths. That's why it worked with the admin panel and freeroam, because there was no killer.

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