Jump to content

Scoreboard money


Norhy

Recommended Posts

Posted

Hey guys, i want to make the money that the player has to appear in the Scoreboard under the collum "money". How do i do that?

Posted

Create a column with the exported function: "scoreboardAddColumn", then make a timer which refreshes "money" element data every some seconds for every player.

Posted

Client Side

  
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 ) )  ---- set Player Money in the Data 
            starttick =  getTickCount() 
        end 
    end 
) 
function updateMoney() 
    for k, v in ipairs(getElementsByType('player')) do 
        local money = getPlayerMoney(v)  --- get the money for all player 
        setElementData(v,"Money",money )  --- then put in data 
    end 
end 
setTimer(updateMoney, 1000000, 0) 
  
  
  
  
  

Server Side

  
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), 
    function() 
        call(getResourceFromName("scoreboard"),"addScoreboardColumn","Money") --Add it to scoreboard 
    end 
) 
  
  
  

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