Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by paulonl · Nov 11, 2014 at 06:58 PM · scoreonlinescoreboard

How to make an online scoreboard

I have a multiplayer fish shoot game and i want that if you shooot a fish the other players see everbody's score go up i have now this script how can i make that if someone joins i see otherplayers score????

 #pragma strict 
 function OnGUI ()
  { 
 if(Network.isClient || Network.isServer)
  { 
 for (var players = 1; players < Network.connections.Length + 2; players++)
 {
  GUI.Label(new Rect(100, 100 + (50 * (players-1)), 150, 30), "Player " + players + " score = " + Score.Punten);
 }
 } 
 }

i am dutch and 14 years old so i could have some spelling errors

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ExtremePowers · Nov 11, 2014 at 07:18 PM

You would have to send the Score over the internet, you could make the server have a array with all the players scores in it.

 @RPC
 function SendScore(Score : int, Name : String) {
     if (Network.isServer) {
         p = new Player();
         p.Score = Score;
         p.Name = Name;
         Players.Add(p);
     }
 }
 
 var Players : List.<Player>[];
 
 var score : int;
 
 function Update() {
     if (Network.isServer) {
         Players = new List.<Player>[Network.connections.Length];
     }
     var name = PlayerPrefs.GetString("Username");
     networkView.RPC("SendScore", RPCMode.All, score, name);
 }
 
 class Player {
     var Score : int;
     var Name : int;
 }
 
 @RPC
 function RequestScoreboard(player : NetworkPlayer) {
     if (Network.isServer) {
         networkView.RPC("SendScoreboard", RPCMode.All, player, Players);
     }
 }
 
 @RPC
 function SendScoreboard(player : NetworkPlayer, SBoard : List.<Player>[]) {
     if (Network.player == player) {
         Players = SBoard;
     }
 }
 
 //Call RequestScoreboard like this:
 //networkView.RPC("RequestScoreboard", RPCMode.All, Network.player);
 
 //Then draw the GUI here.
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image paulonl · Nov 13, 2014 at 05:25 PM 0
Share

Thanks it is a very nice method I am surely going to use it is the best answer I imagined

regards Paul

avatar image paulonl · Nov 15, 2014 at 09:24 AM 0
Share

But Extremepowers i have used your code and unity says:

The name 'List' does not denote a valid type ('not found'). Did you mean 'UnityEngine.Light'?

can you please help me again XD

thanks in advance

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How can I keep a global score updatable from multiple GameObjects 1 Answer

How to create a HighScore using playerprefs based on passed time? 1 Answer

Saving game respectively my level, when I restart my game. 0 Answers

Saving travelled distance as a score 1 Answer

Scoreboard will not update 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges