Announcement

Collapse
No announcement yet.

Controller Class --> is Player ?

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

    Controller Class --> is Player ?

    ok, i got this so far:

    Code:
    class DeathRatioClass extends GameRules;
    
    function ScoreKill(Controller Killer, Controller Killed)
    {
         if ( Killer.bIsPlayer )
         {
            log("DeathRatio Triggered...");
         }
    
         if ( NextGameRules != None )
              NextGameRules.ScoreKill(Killer,Killed);
    }
    even so it didnt work as i liked it to. what i want it to do is only trigger if the player (eg, the guy controlling the computer ( not all players )) is the killer.

    thx

    #2
    Code:
    if( Killer.IsA('PlayerController') )

    Comment


      #3
      Originally posted by Grzech
      Code:
      if( Killer.IsA('PlayerController') )
      ok thx. and that only triggers for the player that controls that computer right ? not all players.

      Comment


        #4
        Originally posted by Grzech
        Code:
        if( Killer.IsA('PlayerController') )
        hmm. well. just tired that. but now it doesnt trigger at all.

        Comment


          #5
          Try this:
          Code:
          p = Level.GetLocalPlayerController( );
          That will return the PlayerController for the person actually sitting at the keyboard, but be careful as it will also return something for spectators too.

          Comment


            #6
            Originally posted by the Adster
            Try this:
            Code:
            p = Level.GetLocalPlayerController( );
            That will return the PlayerController for the person actually sitting at the keyboard, but be careful as it will also return something for spectators too.
            Code:
            class DeathRatioClass extends GameRules;
            
            function ScoreKill(Controller Killer, Controller Killed)
            {
                 p = Level.GetLocalPlayerController( );
                 if ( Killer == p )
                 {
                    playsound(Sound'scorefrag');
                    log("DeathRatio Triggered...");
                 }
            
                 if ( NextGameRules != None )
                      NextGameRules.ScoreKill(Killer,Killed);
            }
            Code:
            Analyzing...
            Parsing MutDeathRatio
            Parsing DeathRatioClass
            Compiling MutDeathRatio
            Compiling DeathRatioClass
            C:\UT2004\MutDeathRatio\Classes\DeathRatioClass.uc(5) : Error, 'p': Bad command
            or expression
            Compile aborted due to errors.
            Failure - 1 error(s), 0 warning(s)

            Comment


              #7
              Originally posted by GuntiNDDS
              Analyzing...
              Parsing MutDeathRatio
              Parsing DeathRatioClass
              Compiling MutDeathRatio
              Compiling DeathRatioClass
              C:\UT2004\MutDeathRatio\Classes\DeathRatioClass.uc (5) : Error, 'p': Bad command
              or expression
              Compile aborted due to errors.
              Failure - 1 error(s), 0 warning(s)
              ROFLMAO

              Sorry about the above, but it did make me chuckle.  I'd have thought you'd have spotted that the code I posted was a function that returns a value, so you have to set up a variable to accepts the returned value.

              You'll just need to add:
              Code:
              local p PlayerController;
              This code should be placed just after the first { of your ScoreKill function.

              Hope that helps more.

              Comment


                #8
                thanks.

                now, do i need to use

                if ( Killer == p ) or something like...
                if ( PlayerController(Killer) == p )

                as Killer is a Controller while p is of PlayerController ..

                ? thanks

                Comment


                  #9
                  Originally posted by GuntiNDDS
                  ok thx. and that only triggers for the player that controls that computer right ? not all players.
                  Code:
                  function ScoreKill(Controller Killer, Controller Killed)
                  {
                       if ( Killer.IsA('PlayerController') )
                       {
                          log("DeathRatio Triggered...");
                       }
                       if ( NextGameRules != None )
                            NextGameRules.ScoreKill(Killer,Killed);
                  }
                  This should trigger for all human players (and not for bots), and if I understand correctly that's what you wanted.

                  Originally posted by Adster
                  Try this:
                  Code:
                  p = Level.GetLocalPlayerController( );
                  That will return the PlayerController for the person actually sitting at the keyboard, but be careful as it will also return something for spectators too.
                  Bad idea, since ScoreKill is not simulated (run only in server) in case of dedicated sever GetLocalPlayerController( ) will always return none. Will work in funny way on listen server (only for person who host server, lol) .

                  Comment


                    #10
                    Originally posted by Grzech
                    This should trigger for all human players (and not for bots), and if I understand correctly that's what you wanted.



                    Bad idea, since ScoreKill is not simulated (run only in server) so in case of dedicated sever GetLocalPlayerController( ) will always return none. Will work in funny way on listen server (only for person who host server, lol) .
                    allright. well. what i want to achive is this:

                    if the player scores a kill and did kill an emeny, and not himself, and not a teammate of his team. eg : if he scores a "good" kill, i want to play that sound, and increase variable of mine. now, once the player dies, or kills himself, or kills a teammate of his team, that variable should reset to 0.

                    maybe you can tell he how to modify the code to archive that.

                    lateron i want to show the value of that variable in the hud, but that is another task.

                    Comment


                      #11
                      I assume You extend TeamGame?
                      Code:
                      function ScoreKill(Controller Killer, Controller Killed)
                      {
                           if ( Killer.GetTeamNum()!=Killed.GetTeamNum() )
                           {
                              log("DeathRatio Triggered...");
                           }
                           else //killed teammate or himself
                           {
                              log("Bad Boy/Girl...");
                           }
                           if ( NextGameRules != None )
                                NextGameRules.ScoreKill(Killer,Killed);
                      }
                      If my assumption is wrong and you need this code also in deathmatch then use this:
                      Code:
                      function ScoreKill(Controller Killer, Controller Killed)
                      {
                           if ( Killer.GetTeamNum()!=Killed.GetTeamNum() || (Killer!=Killed && Killer.GetTeamNum()==255) )
                           {
                              log("DeathRatio Triggered...");
                           }
                           else //killed teammate or himself
                           {
                              log("Bad Boy/Girl...");
                           }
                           if ( NextGameRules != None )
                                NextGameRules.ScoreKill(Killer,Killed);
                      }

                      Comment


                        #12
                        If my assumption is wrong and you need this code also in deathmatch then use this:
                        Code:
                        function ScoreKill(Controller Killer, Controller Killed)
                        {
                             if ( Killer.GetTeamNum()!=Killed.GetTeamNum() || (Killer!=Killed && Killer.GetTeamNum()==255) )
                             {
                                log("DeathRatio Triggered...");
                             }
                             if ( NextGameRules != None )
                                  NextGameRules.ScoreKill(Killer,Killed);
                        }
                        [/B][/QUOTE]

                        ok. so this will only trigger if the player makes a kill, and not trigger if the (human) enemey of the player makes a kill, right ?

                        so could i extend it like this to archive my goal:
                        Code:
                             if ( Killer.GetTeamNum()!=Killed.GetTeamNum() || (Killer!=Killed && Killer.GetTeamNum()==255) )
                             {
                                FragsSinceLastDeath+=1;
                             }
                             else {
                                FragsSinceLastDeath=0;
                             }

                        Comment


                          #13
                          No one said anything about servers, just 'How do I get the player sitting at the keyboard?'.

                          Comment


                            #14
                            Originally posted by GuntiNDDS
                            ok. so this will only trigger if the player makes a kill, and not trigger if the (human) enemey of the player makes a kill, right ?

                            so could i extend it like this to archive my goal:

                            Code:
                            if ( Killer.GetTeamNum()!=Killed.GetTeamNum() || (Killer!=Killed && Killer.GetTeamNum()==255) )
                                 {
                                    FragsSinceLastDeath+=1;
                                 }
                                 else {
                                    FragsSinceLastDeath=0;
                                 }
                            your english seems to be terrible I don't know what you want to achieve :weird: ,lol :sulk:
                            Right now code above you increase a variable everytime some player does a good "kill" and reset it anytime some player does "bad" kill; (player here is either bot or human)

                            if you want to remember "FragsSinceLastDeath" for every player u need to make a table or list for all players and count it for every player independently.

                            it is already done:
                            search code for killing sprees is realized. Killer.pawn.GetSpree() gives you kills from last death of that pawn (if thats what you want... )

                            Comment


                              #15
                              Originally posted by Grzech
                              your english seems to be terrible I don't know what you want to achieve :weird: ,lol :sulk:
                              Right now code above you increase a variable everytime some player does a good "kill" and reset it anytime some player does "bad" kill; (player here is either bot or human)

                              if you want to remember "FragsSinceLastDeath" for every player u need to make a table or list for all players and count it for every player independently.

                              it is already done:
                              search code for killing sprees is realized. Killer.pawn.GetSpree() gives you kills from last death of that pawn (if thats what you want... )
                              thanks, what GetSree returns is what i want. now i just have to make it display that in the hud. but i also want to play a sound, when the player kills an enemy and offcourse only that player should hear it, and not the enemy player. how would i do that ? thanks.

                              Comment

                              Working...
                              X