#Extends "Modes/ShootMania/ModeBase.Script.txt"
#Include "TextLib" as TL
#Include "Libs/Nadeo/Layers.Script.txt" as Layers
#Include "Libs/Nadeo/ShootMania/SM.Script.txt" as SM
#Const CompatibleMapTypes "MeleeArena"
#Const Version "2013-04-18"
***InitServer***
***
declare LayerAttached = False;
declare LayerDetached = False;
declare LayerUpdated = False;
declare LayerDestroyed = False;
***
***StartServer***
***
// Create the ArmorMax layer
// The first parameter of Create() is the name of the layer
// The second parameter is optionnal and allow to give the Manialink that will be used in the layer
declare LayerArmorMaxId = Layers::Create("ArmorMax", CreateLayerArmorMax());
// Display the ArmorMax layer to all the players
// The first parameter of Attach() is the name of the layer to display
// The second parameter is the Id of the player that will see the layer
// If we set it to NullId, then the layer is displayed to all the players
LayerAttached = Layers::Attach("ArmorMax", NullId);
***
***StartMap***
***
UIManager.UIAll.UISequence = CUIConfig::EUISequence::Playing;
StartTime = Now;
***
***PlayLoop***
***
foreach (Event, PendingEvents) {
if (Event.Type == CSmModeEvent::EType::OnShoot) {
if (Event.Shooter != Null) {
// Add one armor max each time the player respawns
Event.Shooter.ArmorMax += 100;
PassOn(Event);}
} else {
Event.Shooter.ArmorMax += 200;
PassOn(Event);
}
}
/* -------------------------------------- */
// Spawn players
foreach (Player in Players) {
if (Player.SpawnStatus == CSmPlayer::ESpawnStatus::NotSpawned && !Player.RequestsSpectate) {
SM::SpawnPlayer(Player, 0, SM::GetSpawn("Spawn", 0));
}
}
***
***EndMap***
***
StartTime = -1;
EndTime = -1;
***
***EndServer***
***
LayerDestroyed = Layers::Destroy("ArmorMax");
***
/* -------------------------------------- */
// Functions
/* -------------------------------------- */
Text CreateLayerArmorMax() {
return """
<label text="Armor max: 2" id="Label_ArmorMax" />
<script><!--
main() {
declare Label_ArmorMax <=> (Page.GetFirstChild("Label_ArmorMax") as CMlLabel);
declare PreviousArmorMax = 0;
while (True) {
yield;
// Skip the update if this UI is not visible
if (!PageIsVisible) continue;
// Skip the update if the UI is not displayed by a player
// InputPlayer represent the Player currently seeing the UI
if (InputPlayer == Null) continue;
// We can get the number of armor max of the player by simply accessing it from InputPlayer
if (PreviousArmorMax != InputPlayer.ArmorMax) {
PreviousArmorMax = InputPlayer.ArmorMax;
declare Message = "Armor max: "^(InputPlayer.ArmorMax/100);
Label_ArmorMax.SetText(Message);
}
}
}
--></script>
""";
}
Take a look on the code here and do a search on "Net_Combo_AmmoMax". It should help you to solve your problem.
Instead of declaring the number of ammo with a netread/netwrite on the UI you declare it on the Player. By doing this you can access to the max ammo of all the players directly in your manialink.
A manialink script executed on your computer can only access to one UI, your own. But it can access to all the players. So if you want to display the number of ammo of a specific player that is not you, you can't save it in his UI. Because you can't access it. Instead you save it directly in the player. And now from the manialink script you can access the number of ammo of GUIPlayer (the player you're spectating) but also the ammo of any other player on the server.
Eole wrote:Take a look on the code here and do a search on "Net_Combo_AmmoMax". It should help you to solve your problem.
Instead of declaring the number of ammo with a netread/netwrite on the UI you declare it on the Player. By doing this you can access to the max ammo of all the players directly in your manialink.
A manialink script executed on your computer can only access to one UI, your own. But it can access to all the players. So if you want to display the number of ammo of a specific player that is not you, you can't save it in his UI. Because you can't access it. Instead you save it directly in the player. And now from the manialink script you can access the number of ammo of GUIPlayer (the player you're spectating) but also the ammo of any other player on the server.
big thx i have done it (and i have got new experience)