How to use GUIPlayer in this code

You can talk about ManiaScript for ManiaPlanet here

Moderator: English Moderator

User avatar
alividerci
Posts: 363
Joined: 11 Feb 2012, 07:03

Re: How to use GUIPlayer in this code

Post by alividerci »

Code: Select all

// Spawn players
if (G_PlayerSpawnQueue.count > 0 && LastSpawnTime + (S_SpawnInterval * 1000) < Now) {
	UpdateBlockSpawnQueue();
	SpawnPlayers();
	LastSpawnTime = Now;
	UIManager.UIAll.BigMessageSound = CUIConfig::EUISound::StartRound;
	UIManager.UIAll.BigMessage = _("Spawning players...");
	LastMessageTime = -1;
	UIManager.UIAll.CountdownEndTime =  LastSpawnTime + (S_SpawnInterval * 1000);
	LayerUpdated = Layers::Update("SpawnQueue", UpdateLayerSpawnQueue());
	///Update weapons
	foreach(Player in Players) {

	declare UI <=> UIManager.GetUI(Player);
	if (UI != Null) {
	declare AmmoMax for Player = C_AmmoMax;

	declare netwrite Integer		Net_Combo_AmmoUpdate	for UI;
	declare netwrite Integer[Text]	Net_Combo_AmmoMax		for UI;
	Net_Combo_AmmoUpdate = Now;
	Net_Combo_AmmoMax = AmmoMax;}
	}
}
and how continue i am not understand(but it is code on client side if i am right :) )
User avatar
TGYoshi
Posts: 795
Joined: 15 Mar 2011, 16:59

Re: How to use GUIPlayer in this code

Post by TGYoshi »

That's server-sided.
If you edit your mode through F12: all code shown there is server-sided.
=3
User avatar
alividerci
Posts: 363
Joined: 11 Feb 2012, 07:03

Re: How to use GUIPlayer in this code

Post by alividerci »

Code: Select all

declare Player <=> UIManager.GetUI(_Player);
	if (Player != Null) {
		declare netwrite Integer		Net_Combo_AmmoUpdate	for Player;
		declare netwrite Integer[Text]	Net_Combo_AmmoMax		for Player;
		Net_Combo_AmmoUpdate = Now;
		Net_Combo_AmmoMax = AmmoMax;
	}
it is baguette
Eole wrote: So in your case you must use a netwrite for Player.
Last edited by alividerci on 06 May 2013, 11:50, edited 3 times in total.
User avatar
steeffeen
Translator
Translator
Posts: 2463
Joined: 14 Oct 2012, 16:22
Location: Germany

Re: How to use GUIPlayer in this code

Post by steeffeen »

it's not possible in a title pack, just in the Storm, Canyon & Stadium bases
    Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

    ManiaControl, FancyManiaLinks
    User avatar
    alividerci
    Posts: 363
    Joined: 11 Feb 2012, 07:03

    Re: How to use GUIPlayer in this code

    Post by alividerci »

    Eole, if you are not hard to explain it to me like the last time here is an example that you showed me

    Code: Select all

    #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>
    """;
    }
    same i want to see how to solve this
    ok i am give some photos
    player
    http://img839.imageshack.us/img839/355/36368637.png
    GUIPlayer( :? )
    http://img607.imageshack.us/img607/9279/91160824.png
    i think your understand what i want to do
    problem..thx...I really tried different methods but achieved nothing :(

    it wiil be very cool if you write example... :)
    User avatar
    TGYoshi
    Posts: 795
    Joined: 15 Mar 2011, 16:59

    Re: How to use GUIPlayer in this code

    Post by TGYoshi »

    We, or at least I, don't even know what you're trying to achieve since the use of GUIPlayer in your code makes no sense.
    =3
    User avatar
    Eole
    Nadeo
    Nadeo
    Posts: 1265
    Joined: 26 Apr 2011, 21:08

    Re: How to use GUIPlayer in this code

    Post by Eole »

    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.
    Contribute to the ManiaPlanet documentation on GitHub
    A question about ManiaScript? Ask it here!
    User avatar
    steeffeen
    Translator
    Translator
    Posts: 2463
    Joined: 14 Oct 2012, 16:22
    Location: Germany

    Re: How to use GUIPlayer in this code

    Post by steeffeen »

    TGYoshi wrote:We, or at least I, don't even know what you're trying to achieve since the use of GUIPlayer in your code makes no sense.
    same here :|
    my guess: showing the amount of ammunition of the currently spectated player
    that would be nice actually

    @Eole: good explanation :thumbsup:
    i seem to have failed at explaining the same.. if he can't understand your summary, we can't help him at all i guess ...
      Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

      ManiaControl, FancyManiaLinks
      User avatar
      alividerci
      Posts: 363
      Joined: 11 Feb 2012, 07:03

      Re: How to use GUIPlayer in this code

      Post by alividerci »

      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)
      Post Reply

      Return to “ManiaScript”

      Who is online

      Users browsing this forum: No registered users and 1 guest