Announcement

Collapse
No announcement yet.

Getting player info in Tick

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

    Getting player info in Tick

    hi,

    i'm trying to get the player's info in Tick( info like position, rotation) and also the right-click event when he/she is in a copter. So wonder if there's anyway to do so.

    Thank you

    #2
    Re: Getting player info in Tick

    I take it that with "copter" you mean Raptor, and with "right-click" you mean altfire.

    A vehicle's Driver is the model sitting in it. Driver.Location and Driver.Rotation give you the location and rotation (obviously). Driver.RelativeLocation and Driver.RelativeRotation will give you the location and rotation relative to the Raptor. I'd expect Driver.RelativeLocation to be identical to DrivePos (the configurable defaultproperty).

    Altfire has a function called AltFire, which gets called when a missile is fired. There is also a function called AttemptFire, which is called before anything is fired to see if the Raptor is ready to fire.

    Comment


      #3
      Driver

      so i wonder how can i get the "Driver" var, is there any function that return the list of vehicle in the scene, or the Driver or ideally myself.

      Comment


        #4
        Re: Driver

        To answer your question with a question: From where?

        I cannot provide a specific answer unless I know where from you are trying to access the driver.

        Driver is simply a property of Vehicle.

        There's a list of vehicles in the game/level info somewhere... not exactly sure where, but if you open up ONSAttackCraftGun you should find a bit of code where the weapon decides which flying/hover vehicle to lock with a missile. That bit of code uses the vehicle list, if I remember correctly.

        Comment


          #5
          DeathMatch

          i have a function tick in a class extends from xDeathMatch. In the Tick Function, i would like to access "myself" and check if i'm in helicopter, when i'm shooting,etc...

          Comment


            #6
            Re: DeathMatch

            That's interesting... I'm not really sure how to get a reference to "myself". I believe there's some sort of GetLocallyAuthoritativePlayer function.

            I'm sure other people can answer this better. I have no experience with this but it doesn't sound that complicated.

            Comment


              #7
              Solution?!

              hi,

              manage to find a solution for this, though may not be the best way.

              Foreach AllActors( class'xPlayer', xPlayer1 )
              {
              Log( "Name : " $ xPlayer1.Name );
              }

              Comment


                #8
                Level.GetLocalPlayerController()

                Comment


                  #9
                  Code:
                  local PlayerController PC;
                  local Vehicle V;
                  
                  PC = Level.GetLocalPlayerController();
                  
                  if ( PC != None )
                  {
                  	for ( V=Level.Game.VehicleList; V!=None; V=V.NextVehicle )
                  	{
                  		if ( V.Controller != None && PlayerController(V.Controller) != None && PlayerController(V.Controller) == PC )
                  		{
                  			// Do stuff
                  		}
                  	}
                  }
                  For network games, you would probably need to search thru the controller list and compare them with the vehicle controllers. Which honestly would be better... if you look up GetLocalPlayerController, it searches thru all dynamic actors to find PlayerControllers ( doing this in tick is bad ), whereas searching thru the ConrollerList is just searching thru an array.

                  and wassup Angel_Mapper

                  Comment


                    #10
                    Well hello there Mr. Lurker.
                    Originally posted by MadNad
                    For network games, you would probably need to search thru the controller list and compare them with the vehicle controllers. Which honestly would be better... if you look up GetLocalPlayerController, it searches thru all dynamic actors to find PlayerControllers ( doing this in tick is bad ), whereas searching thru the ConrollerList is just searching thru an array.
                    I thought it only searched through all actors if it didn't already have a reference to the local controller:
                    Code:
                    simulated function PlayerController GetLocalPlayerController()
                    {
                    	local PlayerController PC;
                    
                    	if ( Level.NetMode == NM_DedicatedServer )
                    		return None;
                    	if ( LocalPlayerController != None )  // Right here
                    		return LocalPlayerController;
                    
                    	ForEach DynamicActors(class'PlayerController', PC)
                    	{
                    		if ( Viewport(PC.Player) != None )
                    		{
                    			LocalPlayerController = PC;
                    			break;
                    		}
                    	}
                    	return LocalPlayerController;
                    }

                    Comment


                      #11
                      very true, but the server cannot access it

                      if ( Level.NetMode == NM_DedicatedServer )
                      return None;

                      Comment

                      Working...
                      X