Announcement

Collapse
No announcement yet.

Can you temp. switch which pawn to control?

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

    #16
    love the gun idea

    Comment


      #17
      This is what I currently use, works okay, certainly serves my purpose as an admin of moving players exploiting or camping, then giving them control back. Does not work with the weapons....and we only play UT2004RPG. Some stuff I code works fine in regular, but in RPG it doesn't work correctly.
      Code:
      function ControlPawn(PlayerController sender, string target){
          local Controller C;
          local int namematch;
          local Pawn p;
      
          if (!bControllingAnotherPawn) {
              P = verifyTarget(sender, target);
          	if (P == none){
           		return;
          	}
              bControllingAnotherPawn = true;
              adminController = sender;
              adminPawn = sender.pawn;
              admininv = sender.pawn.Inventory;
      
              for( C = Level.ControllerList; C != None; C = C.nextController ) {
                  if( C.IsA('PlayerController') || C.IsA('xBot')) {
              		namematch = InStr( Caps(C.PlayerReplicationInfo.PlayerName), Caps(target));
              		if (namematch >=0) {
                          targetController = C;
                          targetPawn = C.Pawn;
                          targetinv = C.Pawn.Inventory;
                      }
              	}
             	}
      
      //  targetController.bVehicleTransition = true;
      //  adminController.bVehicleTransition = true;
      //  targetController.UnPossess();
      //  adminController.UnPossess();
      //  targetPawn.SetOwner(adminController);
      ////  adminPawn.SetOwner(targetController);
      //  adminController.Possess(targetPawn);
      ////  targetController.Possess(adminPawn);
      ////  targetController.bVehicleTransition = false;
      //  adminController.bVehicleTransition = false;
      
              adminController.bGodMode = true;
              adminPawn.UnPossessed();
              targetPawn.UnPossessed();
              adminController.UnPossess();
              targetController.UnPossess();
              adminController.Possess(targetPawn);
              adminController.Pawn.PlayerReplicationInfo.Team.TeamIndex = targetPawn.PlayerReplicationInfo.Team.TeamIndex;
              adminController.Pawn.ClientMessage("Now controlling "$targetcontroller.PlayerReplicationInfo.PlayerName);
              Log("Now controlling "$targetcontroller.PlayerReplicationInfo.PlayerName);
      
          } else {
              bControllingAnotherPawn = false;
      
      //  targetController.bVehicleTransition = true;
      //  adminController.bVehicleTransition = true;
      //  targetController.UnPossess();
      //  adminController.UnPossess();
      //  targetPawn.SetOwner(targetController);
      //  adminPawn.SetOwner(adminController);
      //  adminController.Possess(adminPawn);
      //  targetController.Possess(targetPawn);
      //  targetController.bVehicleTransition = false;
      //  adminController.bVehicleTransition = false;
      
              targetPawn.DropFlag();
              adminPawn.DropFlag();
              adminPawn.UnPossessed();
              targetPawn.UnPossessed();
              adminController.UnPossess();
              targetController.UnPossess();
              targetController.Possess(targetPawn);
      		adminController.Possess(adminPawn);
      		adminController.UnPossess();
      		adminController.Possess(adminPawn);
              adminController.Pawn.PlayerReplicationInfo.Team.TeamIndex = adminPawn.PlayerReplicationInfo.Team.TeamIndex;
              adminController.bGodMode = false;
              adminController.Pawn.clientMessage("Now controlling self.");
      
          }
      
      }
      Thanks for any tips, and I did try the code posted above, didn't work any better, so just commented it out.

      Comment

      Working...
      X