Jump to content

[Solved]KDR with 3 decimals


ManeXi

Recommended Posts

I've made a kdr script, and it's working properly, but i've got the problem that it's showing with infinite decimals and it's annoying, i want to show it with just 3 decimals. I will leave below everything related kdr script.

function setkdr ( player ) 
    local dea = getElementData(player,"Deaths") 
    local kil = getElementData(player,"Kills") 
    setElementData(player,"K/D Ratio", kil/dea) 
    local acc = getPlayerAccount(player) 
    if not isGuestAccount(acc) then 
        setAccountData(acc,"K/D Ratio",kil/dea) 
    end 
end 

function player_Wasted ( ammo, attacker, weapon, bodypart ) 
    if ( attacker ) then 
        giveKill(attacker) 
        setkdr(attacker) 
        triggerClientEvent(source,"startRespawnShow",source,attacker,weapon) 
        giveDeath(source) 
        setkdr(source) 
        setCameraTarget(source,attacker) 
    else 
        triggerClientEvent(source,"startRespawnShow",source,source,0) 
        giveDeath(source) 
        setkdr(source) 
    end 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), player_Wasted ) 

On login:

                local kdr = getAccountData(acc,"K/D Ratio" ) 
                if not kdr then 
                    setAccountData(acc,"K/D Ratio",0) 
                    kdr = 0 
                end 
                setElementData(source,"K/D Ratio",kdr) 

Edited by Guest
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...