MasterOX 水
MasterOX 水3mo ago

keep track of score

how do i keep track of each player's score on a leaderboard?
19 Replies
kapa.ai
kapa.ai3mo ago
Hi @MasterOX 水. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To keep track of each player's score in NormalVR, you can use the RealtimeDictionary collection. This collection works similarly to a Dictionary<uint, ModelType>. It is commonly used to represent a model that can have fields that are dynamically added or removed at runtime. For example, if you need to store the score for N players, you could create a ScoreModel and store instances of it in a RealtimeDictionary using each player's clientID as the key. This way, you can easily manage and update the scores for each player in real-time. Here is the relevant documentation for more details: RealtimeDictionary (https://normcore.io/documentation/room/collections#non-transactional-collections) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3mo ago
<@758040514678489279> kapa.ai is still learning and improving, please let us know how it did by reacting below
MasterOX 水
MasterOX 水3mo ago
and do i sync the dictionary like any other variable? oh thank you
Mechabit
Mechabit3mo ago
a dictionary is a collection of models but one thing to keep in mind is that you don't get update events for changes to the contents of the collection an easy way around that is to add an int property next to the collection which you increment when you change the score of a player if you need updates
MasterOX 水
MasterOX 水3mo ago
ty also pretty unrelated but
MasterOX 水
MasterOX 水3mo ago
why do i get this every now and then?
No description
Mechabit
Mechabit3mo ago
you called is unowned self before the model is ready
MasterOX 水
MasterOX 水3mo ago
havent used that method tho i probably requested client id tho
Mechabit
Mechabit3mo ago
instantiated prefabs are ready at start, scene views are ready when on model replaced is called or allComponentModelsReplaced event is called
MasterOX 水
MasterOX 水3mo ago
is it because of this?
Mechabit
Mechabit3mo ago
any model related stuff you can also use model==null to test
MasterOX 水
MasterOX 水3mo ago
i mean
MasterOX 水
MasterOX 水3mo ago
thats the only thing that could cause it
No description
MasterOX 水
MasterOX 水3mo ago
and it does have model == null
Mechabit
Mechabit3mo ago
dunno, you'll have to debug it to find out
MasterOX 水
MasterOX 水3mo ago
i added it in startgame as well couldve been bcuz of that actually
Mechabit
Mechabit3mo ago
you can disable scripts until it stops happening and then add a code break where you think it might happen then you can view the values of each property in your IDE
MasterOX 水
MasterOX 水3mo ago
oke, but it does happen right before i activate the start game method, and now that i think about it, most of the time i click on start game as fast as possible. so its most likely because of that