BriGhtx3 Posted May 21, 2011 Share Posted May 21, 2011 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
karlis Posted May 21, 2011 Share Posted May 21, 2011 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
BriGhtx3 Posted May 21, 2011 Author Share Posted May 21, 2011 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
BriGhtx3 Posted May 21, 2011 Author Share Posted May 21, 2011 I think I found one error : The Scoreboard isn't a resource! I haven't put it in the resource folder. I extracted it and put it in my gamemode and in my meta.xml Link to comment
BinSlayer1 Posted May 21, 2011 Share Posted May 21, 2011 exports.scoreboard:scoreboardAddColumn ( "Gesellschaftsstatus" ) exports.scoreboard:scoreboardAddColumn ( "Spielzeit" ) ^ Should be done server-side as far as i know Link to comment
karlis Posted May 21, 2011 Share Posted May 21, 2011 plus please define those 2 variables. Link to comment
BriGhtx3 Posted May 21, 2011 Author Share Posted May 21, 2011 @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
proracer Posted May 21, 2011 Share Posted May 21, 2011 The error is probably because you're script is serverside and it must be clientside... Link to comment
BriGhtx3 Posted May 21, 2011 Author Share Posted May 21, 2011 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
karlis Posted May 21, 2011 Share Posted May 21, 2011 does getElementData returns numbers/strings? Link to comment
BriGhtx3 Posted May 21, 2011 Author Share Posted May 21, 2011 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
Castillo Posted May 22, 2011 Share Posted May 22, 2011 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
Johnniey Posted May 22, 2011 Share Posted May 22, 2011 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
Castillo Posted May 22, 2011 Share Posted May 22, 2011 John, i don't know what do you mean, but he was adding the columns right. Btw, the rank/checkpoint columns are in race_server.lua, search for the keyword: scoreboard Link to comment
BriGhtx3 Posted May 22, 2011 Author Share Posted May 22, 2011 Thanks Solidsnake. It works! Could you please show me my error? Link to comment
Castillo Posted May 23, 2011 Share Posted May 23, 2011 Uhm... i can't remember what exactly, but, you had many, compare both codes, you may find it yourself . Link to comment
BriGhtx3 Posted May 23, 2011 Author Share Posted May 23, 2011 Yes I found it right now. The PlayedM and H didn't return something. You converted it into a string. Link to comment
Castillo Posted May 23, 2011 Share Posted May 23, 2011 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
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