Announcement

Collapse
No announcement yet.

How can I display a message on the hud?

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

    How can I display a message on the hud?

    Hi!
    I'm coding an adrenalin combo.. You aren't always allowed to do this combo. (if you aren't allowed, I set the duration of the combo to 0 and at the end of the combo i give the player his adrenalin back etc.)

    Nearly everything works, but i have a problem with the messages like "Berserk!" or "Speed!", that is displayed at top middle of the screen. I cannot use the ExecMessage variable, because i need 2 different messages: one, if the combo is allowed and one if not. But how can I display a message? I tried that for hours... please help!

    #2
    tried this yet?

    http://wiki.beyondunreal.com/wiki/Using_LocalMessages
    http://wiki.beyondunreal.com/wiki/LocalMessage

    Comment


      #3
      hm, i think my problem is getting a referance to the PlayerController...

      i tried this:

      Code:
      function StartEffect(xPawn P)
      {
                  P.Controller.ReceiveLocalizedMessage ( class'SloMoComboMessageDenied', 0,,, SloMoCombo );
      }
      Error, Unrecognized member 'ReceiveLocalizedMessage' in class 'Controller'

      Code:
      function StartEffect(xPawn P)
      {
          local PlayerController CP;
      
          CP=PlayerController(Owner);
      
          CP.ReceiveLocalizedMessage ( class'SloMoComboMessageDenied', 0,,, SloMoCombo );
      Error, call to 'ReceiveLocalizedMessage' Bad expression or missing ')'

      Comment


        #4
        You should check if CP != none before that last line, and I believe the space before the ( might be causing your error.

        Comment


          #5
          ReceiveLocalizedMessage is not in Controller, only in PlayerController. That is why the second example generates a different error. Use PlayerController(P.Controller) in the first example.

          The second example has a different problem. Maybe you used one comma too much, or one of the arguments is wrong. Are you sure you need all the extra stuff? You should only need the first argument, the class.

          Comment


            #6
            Here's how I display HUD messages. I can't guarantee that it works over the net.

            Code:
            //-----------------------------------------------------------
            // Generic localized message.
            //-----------------------------------------------------------
            class XS_Message extends LocalMessage;
            
            var(Message)    string          Message;
            
            var(Color)      color           ColorNone;
            var(Color)      color           ColorCream;
            var(Color)      color           ColorSky;
            var(Color)      color           ColorGold;
            var(Color)      color           ColorTan;
            var(Color)      color           ColorPistache;
            var(Color)      color           ColorSilver;
            
            /** Interface: Generic HUD message wrapper. */
            static function HUDMessage(Controller C, string NewMessage, optional float NewPosY, optional float NewLifeTime, optional color NewDrawColor)
            {
                if(C != none
                && PlayerController(C) != none)
                {
                    Setup(NewMessage, NewPosY, NewLifeTime, NewDrawColor);
            
                    // Send the message.
                    PlayerController(C).ReceiveLocalizedMessage(default.class);
                }
            }
            
            /** Setup: Initialize the class' defaults for the next time it'll be used...
                       which will be immediately. */
            static function Setup(string NewMessage, optional float NewPosY, optional float NewLifeTime, optional color NewDrawColor)
            {
                default.Message = NewMessage;
            
                if(NewPosY > 0)
                {
                    default.PosY = NewPosY;
                }
            
                if(NewLifeTime > 0)
                {
                    default.LifeTime = NewLifeTime;
                }
                
                if(NewDrawColor != default.ColorNone)
                {
                    default.DrawColor = NewDrawColor;
                }
            }
            
            /** Setup: Don't mess around with switches and objects and stuff, just use
                       whatever message was given. */
            static function string GetString(optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2, optional Object OptionalObject)
            {
                return default.Message;
            }
            
            defaultproperties
            {
                // Default must be overridden... if not, display the error message.
                Message="Oops... message error.  Contact the coder!"
            
                // Default: Gold.
                DrawColor=(R=255,G=215,B=90)
            
                ColorCream=(R=255,G=250,B=175)
                ColorGold=(R=255,G=215,B=90)
                ColorSky=(R=190,G=230,B=240)
                ColorTan=(R=255,G=190,B=140)
                ColorPistache=(R=220,G=230,B=135)
                ColorSilver=(R=245,G=240,B=240)
            
                bIsConsoleMessage=false
            
                //Lifetime=3
                bFadeMessage=true
            
                StackMode=SM_Down
                PosY=0.9
            
                FontSize=1
            }
            Call it like so:

            Code:
            function SomeFunction
            {
                HUDMessage("Hello Player!");
            }
            
            /** Message: Generic HUD message wrapper. */
            function HUDMessage(string Message, optional float NewPosY, optional float NewLifeTime, optional color NewDrawColor)
            {
                if(Message != ""
                && Controller != none)
                {
                    class'XS_Message'.static.HUDMessage(Controller, Message, NewPosY, NewLifeTime, NewDrawColor);
                }
            }

            Comment


              #7
              it was the PlayerController thanx!!

              Comment

              Working...
              X