Jump to content

Dxscoreboard Add Column


Recommended Posts

  
addEventHandler ( "onClientResourceStart", getRootElement(), 
function (resource) 
if resource == getThisResource() then 
        exports.scoreboard:scoreboardAddColumn ( "Gesellschaftsstatus" ) 
        exports.scoreboard:scoreboardAddColumn ( "Spielzeit" ) 
        setElementData ( getLocalPlayer ( ), "Gesellschaftsstatus", "Bauer" ) 
        setElementData(  getLocalPlayer ( ), "Spielzeit", ""..PlayedH..":"..PlayedM ) 
        end 
    end 
) 
  
 function refreshZeit() 
     local Zeit = ""..PlayedH..":"..PlayedM 
     setElementData( getLocalPlayer(), "Spielzeit", Zeit ) 
 end 
 setTimer( refreshZeit, 60000, 0 ) 

That's my code.

My Problem : It doesn't show the columns.

Where is my error?

Link to comment
  
addEventHandler ( "onClientResourceStart", getResourceRootElement(getResourceFromName("scoreboard")), 
function() 
        exports.scoreboard:scoreboardAddColumn ( "Gesellschaftsstatus" ) 
        exports.scoreboard:scoreboardAddColumn ( "Spielzeit" ) 
        setElementData ( getLocalPlayer ( ), "Gesellschaftsstatus", "Bauer" ) 
        setElementData(  getLocalPlayer ( ), "Spielzeit", ""..PlayedH..":"..PlayedM ) 
 end 
) 
  
 function refreshZeit() 
     local Zeit = ""..PlayedH..":"..PlayedM 
     setElementData( getLocalPlayer(), "Spielzeit", Zeit ) 
 end 
 setTimer( refreshZeit, 60000, 0 ) 

also, is PlayedH and PlayedM defined?

Link to comment

No they weren't, and it doesn't work (now it shows errors too)

:

addEventHandler ( "onClientResourceStart", getResourceRootElement(getResourceFromName("scoreboard")), 
function() 
        exports.scoreboard:scoreboardAddColumn ( "Gesellschaftsstatus" ) 
        exports.scoreboard:scoreboardAddColumn ( "Spielzeit" ) 
        setElementData ( getLocalPlayer ( ), "Gesellschaftsstatus", "Bauer" ) 
        setElementData(  getLocalPlayer ( ), "Spielzeit", ""..getElementData(source,"PlayedH")..":"..getElementData(source,"PlayedM") ) 
        end 
  
) 
  
 function refreshZeit() 
     local Zeit = ""..getElementData(source,"PlayedH")..":"..getElementData(source,"PlayedM") 
     setElementData( getLocalPlayer(), "Spielzeit", Zeit ) 
 end 
 setTimer( refreshZeit, 60000, 0 ) 

Link to comment

@Bin is server-side

@karlis defined them

Error : attempt to call global getLocalPlayer (a nil value)

And Warnings because he doesn't finde the resource. It isn't even a resource in my mode. It is in my normal gamemode folder (extracted)

Link to comment

OK. Then I would like to use the original scoreboard :

My Questions :

How do I color the team names and members

How do I add columns

My Client code :

local root = getRootElement() 
local player = getLocalPlayer() 
local gespielt = getElementData(source,"PlayedH")..":"..getElementData(source,"PlayedM") 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
    function() 
setElementData ( player, "Gesellschaftsstellung", "Bauer" ) 
setElementData ( player, "Spielzeit", gespielt ) 
setElementData ( player, "Nummer", "000" ) 
    end 
) 
  
  
 function refreshZeit() 
     setElementData( player(), "Spielzeit", gespielt ) 
 end 
 setTimer( refreshZeit, 60000, 0 ) 
  

In this Code the columns are shown but not the value -.-

Link to comment

You mean :

getElementData(source,"PlayedH")..":"..getElementData(source,"PlayedM")

If yes, than yes. They are defined both in another file :

setElementData(source,"PlayedM",tonumber(row[17]))

setElementData(source,"PlayedH",tonumber(row[18]))

But not just the "Spielzeit" with the getElementData doesn't work. Even those with plain text

Link to comment
exports.scoreboard:scoreboardAddColumn ( "Gesellschaftsstatus" )

exports.scoreboard:scoreboardAddColumn ( "Spielzeit" )

^ Should be done server-side as far as i know

I don't see why.. they can be used in the server/client side.

local root = getRootElement() 
local player = getLocalPlayer() 
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
function() 
local gespielt = tostring(getElementData(player,"PlayedH"))..":"..tostring(getElementData(player,"PlayedM")) 
setElementData ( player, "Gesellschaftsstellung", "Bauer" ) 
setElementData ( player, "Spielzeit", gespielt ) 
setElementData ( player, "Nummer", "000" ) 
end) 
  
  
function refreshZeit() 
local gespielt = tostring(getElementData(player,"PlayedH"))..":"..tostring(getElementData(player,"PlayedM")) 
setElementData( player, "Spielzeit", gespielt ) 
end 
setTimer( refreshZeit, 60000, 0 ) 

Link to comment

Basically you just have to make a script with the functions Spielzeit & Gesellschaftsstatus and then put

exports.scoreboard:scoreboardAddColumn ( "Gesellschaftsstatus" ) 
exports.scoreboard:scoreboardAddColumn ( "Spielzeit" ) 

these into the meta as far as i know.

Maybe a little off-topic but does someone knows where the 'race rank' & the 'checkpoint' Column are (in which script)?

Link to comment

Not just that.. look:

local root = getRootElement() 
local player = getLocalPlayer() 
local gespielt = getElementData(source,"PlayedH")..":"..getElementData(source,"PlayedM") -- You're using "source" when you should use "player", also this has to be into the function else it won't work. 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
    function() 
setElementData ( player, "Gesellschaftsstellung", "Bauer" ) 
setElementData ( player, "Spielzeit", gespielt ) 
setElementData ( player, "Nummer", "000" ) 
    end 
) 
  
  
 function refreshZeit() 
     setElementData( player(), "Spielzeit", gespielt ) -- You have an error here "()" after "player". 
 end 
 setTimer( refreshZeit, 60000, 0 ) 

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