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