Okay. To do that you need to learn something you new.
You can declare netwrite/netread variables for three types of objects:
- UI
- Player
- Team
Each one have different characteristics.
Lets say you have this code somewhere in your game mode script:
Code: Select all
declare I = 0;
foreach (Player in Players) {
I += 1;
// Declare a variable for UI
declare UI <=> UIManager.GetUI(Player);
if (UI != Null) {
declare netwrite Integer UI_Variable for UI;
UI_Variable = I;
}
// Declare a variable for Player
declare netwrite Integer Player_Variable for Player;
Player_Variable = 1000 + I;
}
// Declare a variable for team
declare netwrite Integer Team_Variable for Teams[0];
Team_Variable = -10;
And now you create an UI with this code inside it and send it to three players: Player1, Player2 and Player3
Code: Select all
declare netread Integer UI_Variable for UI;
log(UI_Variable);
Each UI will log something different. Player1 will log 1, Player2 -> 2 and player3 -> 3. Because you read a variable declared for UI and in a manialink script you can only access your own UI. You can't access to the value of UI_Variable for Player2 if you're Player1. You must use another method.
If you create an UI with this code:
Code: Select all
foreach (Player in Players) {
declare netread Integer Player_Variable for Player;
log(Player_Variable);
}
Then Player1 will log 1001,1002,1003. Player2 -> 1001,1002,1003. Player3: 1001,1002,1003. You can access to all the variables declared for a player from any UI.
Alternatively if you use this code:
Code: Select all
declare netread Integer Player_Variable for InputPlayer;
log(Player_Variable);
Player1 will log 1001, Player2 -> 1002 and Player3 -> 1003. InputPlayer represents yourself, so you access to the value of Player_Variable that you save in your player.
Code: Select all
declare netread Integer Player_Variable for GUIPlayer;
log(Player_Variable);
If Player1 spectates Player3 then it will logs 1003. If Player2 spectates Player1 it will logs 1001. Because GUIPlayer represents the player you're spectating.
And the last one with this code in your UI:
Code: Select all
declare netread Integer Team_Variable for Teams[0];
log(Team_Variable);
With this one the three UI will log the same value of -10.
To sum it up:
- declare netwrite MyVariable for UI -> only the player owning this UI can access this variable. If you change the value only one player will see something change. Use this if only you must have access to the value. Eg: My best time in a Time Attack mode.
- declare netwrite MyVariable for Player -> the UI can access to all the players and so access to any variable declared for Player. If you change the value of this variable it will be shared with all other players. Use this if you want a value specific to a player to be shared with all other players. Eg: My number of ammo.
- declare netwrite MyVariable for Teams[0] -> the UI can access this variable and it's shared between all players. Use this if you want to share a common value with all other players. Eg: The current score on the map.
So in your case you must use a netwrite for Player.