Norhy Posted January 21, 2013 Share Posted January 21, 2013 So, i've created a scoreboard collum, "deaths". Now if a player dies, he gets +1 death. However the deaths don't show in the collum / scoreboard. Code: addEventHandler("onClientRender",getRootElement(), function() if not starttick then starttick = getTickCount() end currenttick = getTickCount() if currenttick - starttick >= 1000 then setElementData(player,"deaths", getElementData ( source, "deaths" ) ) starttick = getTickCount() end end ) function updateDeaths() for k, v in ipairs(getElementsByType('player')) do local deaths = tonumber ( getElementData ( v, "deaths" ) ) setElementData(v,"Deaths",deaths ) end end setTimer(updateDeaths, 1000000, 0) Full code: local starttick, currenttick local player = getLocalPlayer() addEventHandler("onClientRender",getRootElement(), function() if not starttick then starttick = getTickCount() end currenttick = getTickCount() if currenttick - starttick >= 1000 then setElementData(player,"Money",getPlayerMoney( player ) ) starttick = getTickCount() end end ) function updateMoney() for k, v in ipairs(getElementsByType('player')) do local money = getPlayerMoney(v) setElementData(v,"Money",money ) end end setTimer(updateMoney, 1000000, 0) addEventHandler("onClientRender",getRootElement(), function() if not starttick then starttick = getTickCount() end currenttick = getTickCount() if currenttick - starttick >= 1000 then setElementData(player,"deaths", getElementData ( source, "deaths" ) ) starttick = getTickCount() end end ) function updateDeaths() for k, v in ipairs(getElementsByType('player')) do local deaths = tonumber ( getElementData ( v, "deaths" ) ) setElementData(v,"Deaths",deaths ) end end setTimer(updateDeaths, 1000000, 0) Death, reward code: function killDeaths ( ) local deaths = tonumber ( getElementData ( source, "deaths" ) ) or 0 setElementData ( source, "deaths", deaths + 1 ) end addEventHandler ( "onPlayerWasted", getRootElement (), killDeaths ) Link to comment
Blaawee Posted January 21, 2013 Share Posted January 21, 2013 exports.scoreboard:addScoreboardColumn( "deaths" ) Link to comment
INVINCIBLE Posted January 29, 2013 Share Posted January 29, 2013 (edited) addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() call(getResourceFromName("scoreboard"), "addScoreboardColumn", "deaths") end) function scoreboardRefresh() deaths = getElementData(source,"deaths") setElementData(source, "deaths",deaths) end addEventHandler ( "onPlayerWasted", getRootElement(), scoreboardRefresh) Add to your file. Edited January 29, 2013 by Guest Link to comment
TAPL Posted January 29, 2013 Share Posted January 29, 2013 addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Deaths") end) function scoreboardRefresh() deaths = getElementData(source,"Deaths") setElementData(source, "Deaths",deaths) end addEventHandler ( "onPlayerWasted", getRootElement(), scoreboardRefresh) Add to your file. What is the point of getting the data and setting it again without any change? 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