No announcement yet.

Bring a variable into an interaction class...

  • Filter
  • Time
  • Show
Clear All
new posts

    Bring a variable into an interaction class...

    In my ini I have

    In my mutator I have
    var config string tmpString;

    In the mutator,
    (tmpString == "testing1testing")
    returns true.

    I have an interaction class, I want to do something if
    (tmpString == "testing1testing")

    the mutator runs serverside and the interation runs clientside from my understanding. Any help would be greatly appreciated.

    Replication. Your interaction needs a reference to the mutator (which should exist clientside as well, but not necessarily have the same values as the server since it loads the ini value from the clientside ini). So you need to have the server side mutator call a replicated function on the clientside mutator to send the value to the client, and then access it from your interaction. Sounds hard, it isnt (once you get the hang of it, which IS hard).


      Hmmmm, haven't tried it yet, but something like this?....

      In the mutator
      replication {
          reliable if (Role == ROLE_Authority)
      and then in the interaction
      if (package.class.tmpString == "testing1testing") {
 "Interaction.tmpString correct");


        I copied the carlauncher mutator but that returns bad or missing expression in condition.

        	reliable if ( Role == ROLE_Authority )
        simulated function Tick(float DeltaTime) {
            local PlayerController PC;
            if (bHasInteraction)
            PC = Level.GetLocalPlayerController();
            if ( PC != None )
                PC.Player.InteractionMaster.AddInteraction("bushbombsRPG019.bushbombInteraction", PC.Player);
                bushbombInteraction(PC).tmpAdmin = tmpAdmin;
                bHasInteraction = True; // Set the variable so this lot isn't called again

        This replication works in the carlauncher mutator from the mutator to "class CarLauncher extends TransLauncher", perhaps it does not work to the interaction class? Any more details would be greatly appreciated.


          hmmm, getting closer, I got the variable to replicate from the mutator to the interaction just after I spawn the interaction (in a tick function) but at that time, the var config string tmpadmin; has not yet been read from the ini file, so it's still the default value.

          Anyone know how I can enumerate through the interactions a player has?

          bushbombInteraction(interactionhere).tmpAdmin = tmpAdmin replicates the value correctly to the interaction class.
          When I spawn the interaction I did:
          interactionhere = PC.Player.InteractionMaster.AddInteraction("bushbo mbsRPG019.bushbombInteraction", PC.Player);

          so that's how it had the interaction. I guess my first question is really, in what function can I set the interaction variable so that it is POST setting the variable from the ini?

          2ndly, (also asked above) how can I iterate through interactions to find the bushbombInteraction class for each playercontroller?

          I'll post again if I figure any of that part out.


            PostNetBeginPlay is the first function called where replicated variables should exist. Anything after that should be adequate, or set it explicitly via the mutator with a replicated function in the interaction itself.

            As for your second question, since interactions are clientside, and the controller list is serverside, there is no way to iterate through all interactions on the server (and definately not from the client, which is dangerous to begin with). However, if you explicitly save a reference to your interactions for each player, you will have them.

            You can do this via a tick, or wherever you are spawning the interaction. Just set the interaction to a severside array to keep track of it. You only need 32 elements for this array, since thats the max number of players. I hope I'm being clear, its a vague concept.

            Basically, on the server:

            MyInteraction = Spawn(class'whatever',aPawn);
            SomeArrayOfInteractions[PlayerIndex] = MyInteraction;

            Find PlayerIndex with some helper functions in your mutator, keep the array updated as players come and go, etc. Its a pain in the butt, heh.


              Strange. If I have tmpAdmin="something" in the defaultvalues of the mutator, then doing something like:

              aninteraction = spawn(bushbombinteraction, pc.player);
              bushbombinteraction(aninteraction).tmpAdmin = tmpAdmin;

              will have the tmpAdmin var in the mutator and the interaction be "something"

              If I have the value in the ini of "otherthing" then the mutator's tmpAdmin is "otherthing" and the interaction's tmpAdmin is "something".

              If I remove the defaultvalue from the mutator, interaction.tmpAdmin = "" and mutator.tmpAdmin = "otherthing"

              I spawn the interaction in the tick, which is enabled by default. Once it spawns the interaction, i have it disable tick. Is it possible that the tick executes and creates the interaction before the ini file is read to replace the defaultvalue tmpAdmin?


                It's more likely that you are not replicating the variable to your interaction class. The variable you want to access is the one that needs to be replicated, like above. Since it is the serverside mutator (I believe) that is spawning the interaction on the client, you need to replicate the variable in the interaction to the client.

                It's really difficult to know what is happening where, so you probably need to experiment a little bit with it.


                  for summary, the mutator spawns the interaction in a tick.

                  In The Mutator:
                  theinteraction.tmpAdmin = tmpAdmin;

                  In the Interaction:
                  replication {
                  reliable if (role == role_authority)

                  didn't check exact code for spelling, but is that the correct layout to use?


                    Yes, if my guess is correct.