Announcement

Collapse
No announcement yet.

Controller Class --> is Player ?

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

    #16
    http://www.ataricommunity.com/forums...hreadid=386389

    Comment


      #17
      from that thread:
      "I want to play sound from my mutator. I want it to be heard by every player (not localized sound)"
      that is not what i want. i want the sound only be heard by the player not every player. i allready know how to play a sound, what i dont know is the condition to make it only trigger if the player killed an emeny and not if the enemy killed the player. ( the same problem as i had before ).

      --
      for that hud thing, i tried:

      Code:
      class DeathRatioHUD extends ChallengeHUD;
      
      function PostRender(canvas C)
      {
      	Super.PostRender(C);
      
      	C.SetPos( 0, Canvas.ClipY/2 );
      	C.DrawColor.R = 255;
      	C.DrawColor.G = 0;
      	C.DrawColor.B = 0;
      	C.Font = MyFonts.GetBigFont( C.ClipX );
      	C.DrawText( PlayerOwner.PlayerReplicationInfo.GetSpree(), False );
      }
      which gave me:

      Code:
      Analyzing...
      Superclass ChallengeHUD of class DeathRatioHUD not found
      
      History: UMakeCommandlet::Main
      
      Exiting due to error
      ? thx

      Comment


        #18
        To play a sound to just one player try this:
        Code:
        PlayerController( killer ).ClientReliablePlaySound( Sound'MyCustomSound' );
        !ATTENTION!  You'll need to sort out the sound yourself, as if you try and use the code as it's posted you'll get an error.

        Importing a custom sound can be done in this way:
        Code:
        #exec AUDIO IMPORT FILE="Sounds\Whatever.wav" NAME="MyCustomSound"
        Hope that helps.

        Comment


          #19
          Originally posted by the Adster
          To play a sound to just one player try this:
          Code:
          PlayerController( killer ).ClientReliablePlaySound( Sound'MyCustomSound' );
          !ATTENTION!  You'll need to sort out the sound yourself, as if you try and use the code as it's posted you'll get an error.

          Importing a custom sound can be done in this way:
          Code:
          #exec AUDIO IMPORT FILE="Sounds\Whatever.wav" NAME="MyCustomSound"
          Hope that helps.
          thanks i wil try that. i know how to import sounds, so i think it gonna work. thanks.

          Comment


            #20
            umm kay. i want to do something slighty different now.
            what i want is that if your team scores a frag ( being it a bot from your team or a human player from your team), everyone from that team should hear a sound.

            i tried like this:

            Code:
            class TeamGameFragsoundClass extends GameRules;
            
            function ScoreKill(Controller Killer, Controller Killed)
            {
                 local Controller p;
            
                 if ( !Killer.SameTeamAs(Killed) ) 
                 {
            
                        for( p = Level.ControllerList; p != None; p = p.nextController )
                        {
            	         if( p.IsA( 'PlayerController' ) )
            	         {
            	          if ( PlayerController(p).sameteamas(PlayerController(Killer)))
                              {
                                   PlayerController(p).ClientReliablePlaySound(Sound'scorefrag');
                              }
                             }
                        }
                  }
            
            
                 if ( NextGameRules != None )
                      NextGameRules.ScoreKill(Killer,Killed);
            }
            using this and using showlog reveals something like:
            "MutTeamGameFragsound accessed 'None' Killer" ?
            ( being playing with bots when this occours + it works and not display that when i make a frag myself. so maybe the code above is not realy compatible with bots ? )

            thx

            Comment


              #21
              surely it isn't. what do you cast that poor killer to playercontroller for?
              get rid of that and it will work.

              Comment


                #22
                Originally posted by Grzech
                surely it isn't. what do you cast that poor killer to playercontroller for?
                get rid of that and it will work.
                hi. right that was unnesscary, but still it dont work. even if i only write:

                Code:
                class TeamGameFragsoundClass extends GameRules;
                
                function ScoreKill(Controller Killer, Controller Killed)
                {
                
                     if ( !Killer.SameTeamAs(Killed) ) 
                     {
                log("someone killed someone else");
                     }
                
                
                     if ( NextGameRules != None )
                          NextGameRules.ScoreKill(Killer,Killed);
                }
                even that raises the error and wont work... :bulb: ??

                Comment


                  #23
                  This code come from one of my projects (modified to your needs):
                  Code:
                  if( ( killed != killer )
                  	&& ( killer.PlayerReplicationInfo != None )
                  	&& ( killed.PlayerReplicationInfo != None )
                  	&& ( killed.PlayerReplicationInfo.Team != killed.PlayerReplicationInfo.Team )
                  	&& ( killed != None ) )
                  Try that.

                  Comment


                    #24
                    Originally posted by the Adster
                    This code come from one of my projects (modified to your needs):
                    Code:
                    if( ( killed != killer )
                    	&& ( killer.PlayerReplicationInfo != None )
                    	&& ( killed.PlayerReplicationInfo != None )
                    	&& ( killed.PlayerReplicationInfo.Team != killed.PlayerReplicationInfo.Team )
                    	&& ( killed != None ) )
                    Try that.
                    doesnt playerreplicationinfo only work with human players ?

                    Comment


                      #25
                      Originally posted by GuntiNDDS
                      doesnt playerreplicationinfo only work with human players ?
                      Err, no, it works for all Controller types; how do you think CTF flags are attached to non-human players?.  Why not spend the rest of the afternoon having a good look round all the standard classes you have on your machine?  You may be surprised by what you find out.

                      Comment


                        #26
                        Originally posted by the Adster
                        Err, no, it works for all Controller types; how do you think CTF flags are attached to non-human players?.  Why not spend the rest of the afternoon having a good look round all the standard classes you have on your machine?  You may be surprised by what you find out.
                        ok thanks. i will try that then lateron. but with my afternoon i have other plans than crawling to tons of code

                        Comment


                          #27
                          [edit]
                          -- i think i spottet the error now..
                          [/edit]

                          Comment


                            #28
                            ok. well, it works now.

                            my first code were indeed working, but the error i made was that in the other .uc file that extends the mutator class, i put a reference to my older Mutator ( eg MutFragSoundClass) instead of MutTeamGameFragsoundClass. now this being fixed it works wonderfull.

                            thanks to everyone contributing to this thread / problem.

                            Comment

                            Working...
                            X