Announcement

Collapse
No announcement yet.

Simple question PRI => Pawn

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Simple question PRI => Pawn

    I'm currently doing:
    for (playercount=0;playercount<(GRI.PRIArray.Length);p layercount++) {
    Name = GRI.PRIArray[playercount].PlayerName;
    }


    I want to get their location. How can I do this? Is there a way to get the Pawn from the GRI.PRIArray[playercount]? If I had the pawn, the location is simply Pawn.Location. If I try GRI.PRIArray[playercount].Location it compiles okay, but it marks the location at the middle of the map for every Player, not the location of the actual players.

    Thanks for any tips. Is it possible to do something similar to thePawn = Pawn(Owner);?

    #2
    A quick browse through PlayerReplicationInfo class turns up no pawn. Why do you need to use the PRI array? Why cant you use Level.ControllerList or something? Or are you just trying to make it harder? If you need a pawn that matches the PRI, check if the Pawn.PRI == yourPRI.

    Comment


      #3
      If you're doing this serverside the following should work:

      Controller(PlayerReplicationInfo.Owner).Pawn

      Comment


        #4
        I'm using this in the interaction class. The only way I've found to list all names in an interaction class is using the PRIArray[#].playername. If you use "foreach ViewportOwner.Actor.DynamicActors(class'Pawn', P) {" and get the name from the Pawns there, you only get the ones visible, or behind a wall or 2. Those across a big map never get listed this way. Using:

        for (playercount=0;playercount<(GRI.PRIArray.Length);p layercount++) {
        Name = GRI.PRIArray[playercount].PlayerName;
        }


        I'm able to list all players no matter where they are. Still inside the interaction class, I would like to get the locations of each player. What is the best way to get the location of each player while still in an interaction class?

        Comment


          #5
          Basically you'll need an object that exists both server- and clientside which can be used to either replicate a function call or the location variable itself.

          The first method would use a function call that is replicated client->server and which finds the location by the above method and arrange to send this value back (by another function call or a replicated variable since replicated functions can't have return values).
          The second would simply declare the location as a replicated variable and use a function such as Tick() to keep it regularly updated.

          Comment


            #6
            I use the following to match pawns to PRI's

            Code:
            local int i;
            local xPawn xP;
            
            for (i=0;i<Level.GRI.PRIArray.Length;i++)
                foreach DynamicActors(class='xPawn', xP)
                    if ((xP.Controller !=None) && (xP.Controller.PlayerReplicationInfo != None) && (xP.Controller.PlayerReplicationInfo == Level.GRI.PRIArray[i]))
                    {
                        //Do Stuff
                    }
            It for sure detects all non bot players and matches the xPanw to the PRI (and should detect all bots, I was not able to make it work in my usage of it, but that was at the end of game and I'm pretty sure the bot controller is severed from the xPawn at that time)

            Comment


              #7
              Hmm, well, first off, here is the code I tried:
              PHP Code:
                      for (playercount=0;playercount<(GRI.PRIArray.Length);playercount++) {
                          
              PRI GRI.PRIArray[playercount];
                          
              Controller(PRI.Owner).Pawn;
                          
              viewportowner.Actor.Pawn.ClientMessage("PRI.PlayerName="$PRI.PlayerName);
                          
              viewportowner.Actor.Pawn.ClientMessage("P.PRI.PlayerName="$P.PlayerReplicationInfo.PlayerName);
                      } 
              The Controller(PRI.Owner).Pawn command works well for myself, but that's it. The output in game has all the PRI.PlayerName= names listed followed by the P.PRI.PlayerName names being "" except for my own which shows up fine.

              I say again also that I cannot get any Level.attributes to work, as it does not seem Level can be used in an interaction class. If it could I would simply iterate with the "for ( C = level.controllerlist; c!=nonoe;C=C.nextController) {" Maybe there's a way but I don't know it.

              For now what I have works great if the pawns are nearby, far away ones do not list, but here is my current code:
              PHP Code:
              foreach ViewportOwner.Actor.DynamicActors(class'Pawn'P) {
                  
              viewportowner.Actor.Pawn.ClientMessage(string(P.Location));

              Comment


                #8
                what about:

                Code:
                ( C = ViewportOwner.Actor.level.controllerlist; c!=none;C=C.nextController) 
                { 
                       C.ClientMessage(C.Pawn.Location); 
                }
                That should give you access to the controller list.

                Comment


                  #9
                  PHP Code:
                          for ( ViewportOwner.Actor.level.controllerlistc!=none;C=C.nextController)
                          {
                                 
                  viewportowner.Actor.Pawn.ClientMessage("Location:"$C.Pawn.Location);
                                 
                  playercount++;
                          }
                          
                  viewportowner.Actor.Pawn.ClientMessage("playercount:"$playercount); 

                  prints "playercount:0" over and over and over.

                  Comment


                    #10
                    Originally posted by bushbomb
                    The Controller(PRI.Owner).Pawn command works well for myself, but that's it. The output in game has all the PRI.PlayerName= names listed followed by the P.PRI.PlayerName names being "" except for my own which shows up fine
                    That's because Interactions are clientside. The PRI owner is not replicated to the client so you need to get this info serverside.

                    Originally posted by bushbomb
                    I say again also that I cannot get any Level.attributes to work, as it does not seem Level can be used in an interaction class. If it could I would simply iterate with the "for ( C = level.controllerlist; c!=nonoe;C=C.nextController) {" Maybe there's a way but I don't know it.
                    There is no LevelInfo in Interaction, therefore you need to include a reference in your class (extending Interaction) to a LevelInfo (or an object which does have a LevelInfo reference) and set it upon creating the Interaction.

                    Originally posted by Bonehed316

                    ... ControllerList example ...
                    I'm pretty sure that only works serverside too, because the controller list is not replicated.

                    Comment


                      #11
                      Ah, I see. I didnt know the controller list wasnt replicated. Makes sense, actually.

                      Maybe he should just use a ReplicationInfo class (or some other replicated actor) to get the info from. It can be spawned by the Interaction, and will exist on both client and server, and have access to those variables as well as the interaction (with some coding for this, of course).

                      Comment


                        #12
                        Any tips on how to spawn the class and get the info clientside?

                        At this point, I'm fine leaving my code the way it was, only showing those mostly visible, but I'd still like to set it up and get it working just for the knowledge.

                        Comment

                        Working...
                        X