Jump to content

deaths count


BorderLine

Recommended Posts

Hi everyone, Well i found this on comunity. its a script called totalkillsdeaths

this make a count when you kill players and when you die

But just count when for example, i write /kill command then count 1 more to my deaths

But if some player kill me dont count.

This is the script

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 
)       
addEventHandler( "onPlayerLogin",root, 
    function( thePreviousAccount, theCurrentAccount, autoLogin ) 
        local account = getPlayerAccount ( source ) 
        if not getAccountData( account,"totalkillsdeaths.Kills" ) and not getAccountData( account,"totalkillsdeaths.Deaths" ) then 
            setAccountData( account,"totalkillsdeaths.Kills",0 ) 
            setAccountData( account,"totalkillsdeaths.Deaths",0 ) 
        end 
        setElementData( source,"Deaths",tonumber( getAccountData( account,"totalkillsdeaths.Deaths" ) or 0 ) ) 
        setElementData( source,"Kills",tonumber( getAccountData( account,"totalkillsdeaths.Kills" ) or 0 ) ) 
 end 
 ) 
addEventHandler( "onResourceStart",resourceRoot, 
    function( ) 
        outputDebugString( "add Total Kills to scoreboard Return: "..tostring( 
            call( getResourceFromName("Bio_Scoreboard"), "addScoreboardColumn", "Kills",root,2, 0.06 ) 
        ) ) 
        outputDebugString( "add Total Deaths to scoreboard Return: "..tostring( 
            call( getResourceFromName("Bio_Scoreboard"), "addScoreboardColumn", "Deaths",root,3, 0.06 ) 
        ) ) 
    end 
) 
  

If someone know what i need change .

Thanks to all for your time :)

(all credits to csmit195. This is the script

https://community.multitheftauto.com/index.php?p= ... =3472)

Link to comment
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        outputDebugString( "add Total Kills to scoreboard Return: "..tostring( 
            call( getResourceFromName("Bio_Scoreboard"), "addScoreboardColumn", "Kills",root,2, 0.06 ) 
        ) ) 
        outputDebugString( "add Total Deaths to scoreboard Return: "..tostring( 
            call( getResourceFromName("Bio_Scoreboard"), "addScoreboardColumn", "Deaths",root,3, 0.06 ) 
        ) ) 
    end 
) 
  
addEventHandler ( "onPlayerLogin",root, 
    function( _, account ) 
        if ( not getAccountData ( account, "totalkillsdeaths.Kills" ) and not getAccountData ( account, "totalkillsdeaths.Deaths" ) ) then 
            setAccountData ( account, "totalkillsdeaths.Kills", 0 ) 
            setAccountData ( account, "totalkillsdeaths.Deaths", 0 ) 
        end 
        setElementData ( source,"Deaths",tonumber ( getAccountData ( account,"totalkillsdeaths.Deaths" ) or 0 ) ) 
        setElementData ( source,"Kills",tonumber ( getAccountData ( account,"totalkillsdeaths.Kills" ) or 0 ) ) 
    end 
) 
  
addEventHandler ( "onPlayerWasted", root, 
    function( totalAmmo, killer, killerWeapon, bodypart, stealth ) 
        if ( killer and killer ~= source ) then 
            local account = getPlayerAccount ( killer ) 
            setAccountData ( account, "totalkillsdeaths.Kills", tonumber ( getAccountData ( account,"totalkillsdeaths.Kills" ) ) or 0 + 1 ) 
            setElementData ( killer, "Kills", tonumber ( getAccountData( account,"totalkillsdeaths.Kills" ) ) ) 
        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 
) 

Seems to work.

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