Jump to content

textDisplayAddObserver error


Blueman

Recommended Posts

Posted

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.

Posted

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?

Posted

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:

23.bmp

Posted

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 ) 

Posted
Try this:
  
addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn ) 

Ok and I made some last minute changes that you didn't catch.

Works perfectly :)

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