Scores in written books don't work properly when on a server.
Example 1:
Join a server running 14w25b
1: /scoreboard objectives add test dummy
2: /scoreboard players set player test 1
3: /give @p written_book 1 0 {pages:["{score:{name:player,objective:test}}"]}
Open the book and you won't see anything
Example 2: (This one is very weired)
Join Singleplayer with 14w25b
1: /scoreboard objectives add test2 dummy
2: /scoreboard players set player test2 1
3: /give @p written_book 1 0 {pages:["{score:{name:player,objective:test2}}"]}
Open the book and you can see the score: "1"
Afterwards join a server running 14w25b
4: /give @p written_book 1 0 {pages:["{score:{name:player,objective:test2}}"]}
Even though the objective 'test2' hasn't been added on the server yet and player 'player' has no score, the book will show you a "1"
5: /scoreboard objectives add test2 dummy
6: /scoreboard players set player test2 2 <- the "2" is important!
7: /give @p written_book 1 0 {pages:["{score:{name:player,objective:test2}}"]}
Open the book and you will still see the "1" instead of the "2"
Comments 9
@Ezekiel Adding Quotes never fixes the problem. I can say that from experience. Do Example 1 like I showed above and you will see it works. There is just a bug on servers
@Bobby 'player' is an offline player. you can use those to display scores aswell
Can confirm. And no, quotation marks aren't required in the command's JSON in Minecraft, whether it's for the key or value.
Example 1 does not work, because you need to set the author and title tags of a book, otherwise it's considered invalid and won't render text.
Try:
/give @p written_book 1 0 {pages:["{score:{name:player,objective:test}}"],author:Searge,title:Test}
Same is true in Example 2.
Try:
/give @p written_book 1 0 {pages:["{score:{name:player,objective:test2}}"],title:Test,author:Searge}
The fact that clients show scores from the client when the objective does not exist on the server is a bug and will be fixed eventually, but as it works with properly defined books, it's not a high priority to fix it.
I didn't say they were required, nor did I say they were the problem. Also, Searge, you don't need to set an Author. It works fine without one.
POSSIBLY RELATED:
Do this in single player (1.8.1):
/scoreboard objectives add timeAlive stat.timeSinceDeath
/give @p written_book 1 0 {resolved:1b,title:"",author:"",pages:["{score:{name:\"setzke\",objective:\"timeAlive\"}}"]}
Then do the exact same thing in a multiplayer server 1.8.1, and the book will be blank.
On Single Player, the score is updated every time you open it. This is really frustrating because I designed something in SP. I move it to the server, and it's a major feature is now useless. Is there any way around this? (Also, @p instead of a static name doesn't work in this case where resolved:1b is used.)
While I acknowledge this isn't your problem (or at least, I don't think it is), your JSON isn't proper. You should be putting quotes around the key:value pairs, like this "key":"value"