Blueman Posted June 15, 2011 Share Posted June 15, 2011 I'm not sure what this is about but I get a bad argument error when using the following. textDisplayAddObserver ( score, source ) The text display score is added perfectly but showing it fails. Link to comment
Castillo Posted June 15, 2011 Share Posted June 15, 2011 Well, we can't really help you if you don't post your full script, with just one line we can't know what you did wrong. Link to comment
JR10 Posted June 15, 2011 Share Posted June 15, 2011 Post your whole code, Are you sure that the source are defined, And post the errors or warnings, Did you add text item to the text display? Link to comment
Blueman Posted June 15, 2011 Author Share Posted June 15, 2011 Ok my code is: function score () score2 = 0 score1 = 0 local score = textCreateDisplay() local csscore1 = textCreateTextItem ( "Terrorist: " .. score1 .. " |" , 0.5, 0.5 ) local csscore2 = textCreateTextItem ( "Resistance: " .. score2 .. " |" , 0.5, 0.5 ) textDisplayAddText ( score, csscore1 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), score ) function showscore() textDisplayAddObserver ( score, source ) end addEventHandler ( "onPlayerSpawn", getRootElement(), showscore ) It's not finished and I am aware that csscore 1 and 2 are overlapping. Images: Link to comment
Castillo Posted June 15, 2011 Share Posted June 15, 2011 Try this: function score () score2 = 0 score1 = 0 scoreDisplay = textCreateDisplay() local csscore1 = textCreateTextItem ( "Terrorist: " .. score1 .. " |" , 0.5, 0.5 ) local csscore2 = textCreateTextItem ( "Resistance: " .. score2 .. " |" , 0.5, 0.5 ) textDisplayAddText ( scoreDisplay, csscore1 ) textDisplayAddText ( scoreDisplay, csscore2 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), score ) function showscore() textDisplayAddObserver ( scoreDisplay, source ) end addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn ) Link to comment
Blueman Posted June 15, 2011 Author Share Posted June 15, 2011 Try this: addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn ) Ok and I made some last minute changes that you didn't catch. Works perfectly Link to comment
Castillo Posted June 15, 2011 Share Posted June 15, 2011 Well... just make these changes to the new code I gave you. 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