ManeXi Posted July 10, 2015 Share Posted July 10, 2015 (edited) 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 July 10, 2015 by Guest Link to comment
GTX Posted July 10, 2015 Share Posted July 10, 2015 function round(num, idp) return tonumber(string.format("%." .. (idp or 0) .. "f", num)) end Usage: round(kil/dea, 3) Link to comment
ManeXi Posted July 10, 2015 Author Share Posted July 10, 2015 Thank you much it worked perfectly this can be set a solved Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now