Replication trouble: can't access config variable on client

Discussions about Coding and Scripting

Replication trouble: can't access config variable on client

Postby Dizzy » Mon Jan 14, 2019 2:08 am

I'm trying to make the following UWindow dialog work properly:
Image

Notice the checkbox - when users tick this, a variable "bHasReadMessage=True" should be written to a UWindowExampleActor.ini file on their machine.

The problem is this config file is not being created on the client at all.

The variable is defined inside UWindowExampleActor.uc:
Code: Select all
class UWindowExampleActor expands Mutator config(UWindowExampleActor);
   
var config bool bHasReadMessage;
var PlayerPawn PP;

replication {
   reliable if(Role < ROLE_Authority)
      bHasReadMessage;
}

// [Stuff removed]

simulated function MarkAsRead() {

   bHasReadMessage = True;

   PP = PlayerPawn(Owner);
   PP.Say("DEBUG from UWindowExampleActor MarkAsRead())");
   PP.Say("bHasReadMessage: " $ string(bHasReadMessage));

   SaveConfig();

}


In ClientWindow.uc I am attempting to access the variable from the client's machine, and/or set it if the client has ticket the check box:
Code: Select all
class A_ClientWindow expands UMenuDialogClientWindow;

var UWindowExampleActor UWin;

// [Stuff removed]

simulated function MarkAsRead() {

   GetPlayerOwner().Say("DEBUG FROM A_ClientWindow MarkAsRead()");

   UWin.MarkAsRead();

}

simulated static function bool HasReadMessage() {
   return UWin.bHasReadMessage;
}

function Notify(UWindowDialogControl C, byte E) {

   local bool bRead;

   bRead = HasReadMessage();

   Super.Notify(C, E);

   switch(E) {

      case DE_Click:
          switch(C) {
            case CloseButton:
               GetPlayerOwner().Say("DEBUG from A_ClientWindow:");
               GetPlayerOwner().Say("UWin.bHasReadMessage: " $ string(bRead));
               GetPlayerOwner().Say("CheckBox.bChecked: " $ string(CheckBox.bChecked));

               if (CheckBox.bChecked) {
                  MarkAsRead();
               }

               ParentWindow.ParentWindow.Close();
            break;
         }
      break;

   }

}


I know I'm probably doing something completely wrong. Can somebody tell me what, please?

The code:
https://github.com/bunnytrack/UWindowEx ... er/Classes
Image
Join our UT Discord chat server: https://www.bunnytrack.net/discord
User avatar
Dizzy
Experienced
 
Posts: 95
Joined: Tue May 21, 2013 3:57 pm
Personal rank: Oaf

Re: Replication trouble: can't access config variable on cli

Postby Dizzy » Mon Jan 14, 2019 4:14 am

With the kind help of PrinceOfFunky I was able to get this working (I think!).

I believe my fault was not actually spawning my "UWindowExampleActor" class from within "A_ClientWindow" before attempting to use it. I thought that simply defining it in a variable ("var UWindowExampleActor UWin;") at the top of the class was enough to instantiate an object of it, but it wasn't.

Also I added a few more "simulated" keywords to make some functions work on the client-side.

Thank you to PrinceOfFunky for helping painfully debug this.

I'll write a tutorial about creating a UWindow and post it here later so the next person who wants to create a simple message box doesn't have to go through all my pain.
Image
Join our UT Discord chat server: https://www.bunnytrack.net/discord
User avatar
Dizzy
Experienced
 
Posts: 95
Joined: Tue May 21, 2013 3:57 pm
Personal rank: Oaf


Return to Coding, Scripting

Who is online

Users browsing this forum: No registered users and 0 guests