Announcement

Collapse
No announcement yet.

Controller Class --> is Player ?

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

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

    Leave a comment:


  • replied
    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;
         }

    Leave a comment:


  • replied
    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);
    }

    Leave a comment:


  • replied
    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.

    Leave a comment:


  • replied
    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) .

    Leave a comment:


  • replied
    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

    Leave a comment:


  • replied
    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.

    Leave a comment:


  • replied
    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)

    Leave a comment:


  • replied
    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.

    Leave a comment:


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

    Leave a comment:


  • replied
    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.

    Leave a comment:


  • replied
    Code:
    if( Killer.IsA('PlayerController') )

    Leave a comment:


  • started a topic Controller Class --> is Player ?

    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
Working...
X