[Fixed] CSmMlScriptIngame.GUIPlayer

You can talk about ManiaScript for ManiaPlanet here

Moderator: English Moderator

User avatar
steeffeen
Translator
Translator
Posts: 2463
Joined: 14 Oct 2012, 16:22
Location: Germany

[Fixed] CSmMlScriptIngame.GUIPlayer

Post by steeffeen »

hey there,

i stumbled upon a weird crash in my manialink script and i can't figure out why it happens...

Code: Select all

declare PlayerId = NullId;
if (InputPlayer != Null) {
	PlayerId = InputPlayer.Id;
} else {
	if (GUIPlayer != Null) {
		PlayerId = GUIPlayer.Id;
	}
}
my script crashes when accessing GUIPlayer.Id
See Screenshot
but GUIPlayer shouldn't be Null as i'm checking it beforehands

any help would be appreciated

thanks in advance
steff

//Edit: fixed
Last edited by steeffeen on 14 May 2013, 10:20, edited 1 time in total.
    Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

    ManiaControl, FancyManiaLinks
    User avatar
    steeffeen
    Translator
    Translator
    Posts: 2463
    Joined: 14 Oct 2012, 16:22
    Location: Germany

    Re: CSmMlScriptIngame.GUIPlayer

    Post by steeffeen »

    it seems like i was able to fix it:

    Code: Select all

    declare PlayerId = NullId;
    if (InputPlayer != Null && Players.exists(InputPlayer)) {
    	PlayerId = InputPlayer.Id;
    } else {
    	if (GUIPlayer != Null && Players.exists(GUIPlayer)) {
    		PlayerId = GUIPlayer.Id;
    	}
    }
    Edit: nope, that doesn't do the trick.. would have been strange anyways
    Last edited by steeffeen on 13 May 2013, 18:15, edited 1 time in total.
      Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

      ManiaControl, FancyManiaLinks
      User avatar
      Eole
      Nadeo
      Nadeo
      Posts: 1265
      Joined: 26 Apr 2011, 21:08

      Re: CSmMlScriptIngame.GUIPlayer

      Post by Eole »

      I had this bug a long time ago but never found a way to make it happen 100% of the time. So if you have the steps to reproduce it, it would be really helpful.
      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: CSmMlScriptIngame.GUIPlayer

      Post by steeffeen »

      Eole wrote:I had this bug a long time ago but never found a way to make it happen 100% of the time. So if you have the steps to reproduce it, it would be really helpful.
      it's quite hard to reproduce it.. :/
      for me it seems like it's only happening on non-local servers (in a multiplayer game or on a dedicated server hosted on my computer everything works fine, but on serious servers it crashes...), maybe it depends on the operating system.. i have windows and it only crashes on linux servers..

      anyway, how is it possible, that a null object passes the null check??

      Code: Select all

      if (GUIPlayer != Null) {
            PlayerId = GUIPlayer.Id;
      }
      the scripts crashes on accessing the Id property of the obviously not null object GUIPlayer because it happens to be null anyways -.-
        Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

        ManiaControl, FancyManiaLinks
        User avatar
        Slig
        Posts: 637
        Joined: 15 Jun 2010, 11:52
        Location: TraXicoLand

        Re: CSmMlScriptIngame.GUIPlayer

        Post by Slig »

        Then perhaps that Eole can reply to this one : are there other/external events on the server which can happen while the maniascript is executed (so races conditions would make possible to have the GUIPlayer modified between the test and the next line) ?
        User avatar
        Eole
        Nadeo
        Nadeo
        Posts: 1265
        Joined: 26 Apr 2011, 21:08

        Re: CSmMlScriptIngame.GUIPlayer

        Post by Eole »

        Slig wrote:are there other/external events on the server which can happen while the maniascript is executed
        No, the value of GUIPlayer can't change between the test and the next line if there's no yield, wait, sleep or instructions like that in between.

        Maybe what could happen is that the player you were spectating disconnected and the GUIPlayer value is not updated/cleaned right away. So the GUIPlayer is not null but try to access to something that doesn't exist anymore.
        Another hint could be that the client is not synchronized right away with the server and it creates some problems with the data accessible in the UI. That would explain why you don't encounter this error on a local 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: CSmMlScriptIngame.GUIPlayer

        Post by steeffeen »

        Eole wrote:
        Slig wrote:are there other/external events on the server which can happen while the maniascript is executed
        No, the value of GUIPlayer can't change between the test and the next line if there's no yield, wait, sleep or instructions like that in between.

        Maybe what could happen is that the player you were spectating disconnected and the GUIPlayer value is not updated/cleaned right away. So the GUIPlayer is not null but try to access to something that doesn't exist anymore.
        Another hint could be that the client is not synchronized right away with the server and it creates some problems with the data accessible in the UI. That would explain why you don't encounter this error on a local server.
        seems legit.
        now my question: how to fix it? :)
          Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

          ManiaControl, FancyManiaLinks
          User avatar
          Eole
          Nadeo
          Nadeo
          Posts: 1265
          Joined: 26 Apr 2011, 21:08

          Re: CSmMlScriptIngame.GUIPlayer

          Post by Eole »

          Well on your side I don't really see what you can do. We have to find how to solve the problem on our side.

          One thing you can try is to add this in your script loop:

          Code: Select all

          while (True) {
            if (InputPlayer == Null) continue;
          
            // Do things ...
          }
          
          When a player connect to a server he receives the manilinks and starts to execute the scripts inside it before the synchro between the server and the client is done. And so, some data are not the same between the UI and the server, maybe that'll help to avoid the error.
          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: CSmMlScriptIngame.GUIPlayer

          Post by steeffeen »

          Eole wrote:Well on your side I don't really see what you can do. We have to find how to solve the problem on our side.

          One thing you can try is to add this in your script loop:

          Code: Select all

          while (True) {
            if (InputPlayer == Null) continue;
          
            // Do things ...
          }
          
          When a player connect to a server he receives the manilinks and starts to execute the scripts inside it before the synchro between the server and the client is done. And so, some data are not the same between the UI and the server, maybe that'll help to avoid the error.
          Thanks, i will give it a try asap :thumbsup:
            Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

            ManiaControl, FancyManiaLinks
            User avatar
            steeffeen
            Translator
            Translator
            Posts: 2463
            Joined: 14 Oct 2012, 16:22
            Location: Germany

            Re: CSmMlScriptIngame.GUIPlayer

            Post by steeffeen »

            Tested it and it doesn't help :( :(
              Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

              ManiaControl, FancyManiaLinks
              Post Reply

              Return to “ManiaScript”

              Who is online

              Users browsing this forum: No registered users and 2 guests