Announcement

Collapse
No announcement yet.

Custom HUD message (solved)

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

    Custom HUD message (solved)

    I'd like to display various messages on the HUD, similar to the "You have the flag" and "Blue PowerNode under attack" messages. The messages need to be visible to only one player. I do not know in advance what the text will be. I would like to be able to call a function like this:
    Code:
    ShowMessage(Controller, "Random die roll: " $ Rand(6);
    I don't care about localization or network performance (unless really significant).

    How?

    LocalMessage seems to need you to feed it either a preprogrammed line or an Object from which to read the text. Great for if you need to publish your stuff in three different languages... but I only want English.

    I can't be the first one to wonder about this. Any ideas?

    #2
    Do you mean:
    PlayerConroller(C).ReceiveLocalizedMessage( Class'MyLocalMessage );
    you can make it display like others, Like the headshot one or ons one or whatever, the class would look like:
    Code:
    class MyLocalMessageextends LocalMessage;
    
    static function string GetString(
    	optional int Switch,
    	optional PlayerReplicationInfo RelatedPRI_1,
    	optional PlayerReplicationInfo RelatedPRI_2,
    	optional Object OptionalObject
    	)
    {
    	return "My BLAH String!";
    }
    
    defaultproperties
    {
        bIsUnique=True
        bFadeMessage=True
        StackMode=2
        PosY=0.24
        FontSize=1
    }
    Or so.

    the switches are for multiplye messages in one class:
    Code:
    static function string GetString(
    	optional int Switch,
    	optional PlayerReplicationInfo RelatedPRI_1,
    	optional PlayerReplicationInfo RelatedPRI_2,
    	optional Object OptionalObject
    	)
    {
        if( Switch == 0 )
    	return "My BLAH String 0!";
        if( Switch == 1 )
    	return "My BLAH String 1!";
    }

    Comment


      #3
      That is what I was referring to as "preprogrammed lines", and that is what I don't want. I'd have to edit the message class every single time I need a new message, and I wouldn't be able to display any variables in the text. I want a message that I can pass the actual string to as a variable.

      Comment


        #4
        There has to be a way to mod the class dynamically or call the function speparatly but im a lil buzy wit sumtin at the time being

        Comment


          #5
          I tried SetPropertyText(MessageString, "blah"), but that won't work since SetPropertyText is only available in instantiated objects, not in static code.

          I also tried using a string constant ("blah") for the OptionalObject, but that's not considered an "Object" in UScript. :sour:

          Comment


            #6
            maybe you could, uh how i put this, i just confuzzled my self 1 sec..

            ok trace the recieve BLAH message and see how it gets the msg text and rerite it and call the inner functiosn your self?

            Comment


              #7
              Riped off the PlayerController:
              Code:
              simulated event ReceiveLocalizedMessage( class<LocalMessage> Message, optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2, optional Object OptionalObject )
              {
              	// Wait for player to be up to date with replication when joining a server, before stacking up messages
              	if ( Level.NetMode == NM_DedicatedServer || GameReplicationInfo == None )
              		return;
              
                  Message.Static.ClientReceive( Self, Switch, RelatedPRI_1, RelatedPRI_2, OptionalObject );
              	if ( Message.static.IsConsoleMessage(Switch) && (Player != None) && (Player.Console != None) )
              		Player.Console.Message(Message.Static.GetString(Switch, RelatedPRI_1, RelatedPRI_2, OptionalObject),0 );
              }

              Comment


                #8
                That function uses the GetString() function to get the message string, which has to be preprogrammed into the message class, and does not leave any room for a variable message.

                I suppose I could h4x0r PlayerController, but that'd be even more "unclean" than making tons of custom LocalMessage classes with preprogrammed lines.

                Comment


                  #9
                  no no no, im saying you could call those functions and take out the GetString and replace it with whatever

                  [EDIT]
                  wait it gets complicated, it goes into the HUD and has a long function under HUDBase, starting on like 429

                  Message.Static.ClientReceive( Self, Switch, RelatedPRI_1, RelatedPRI_2, OptionalObject );
                  os the fucntion where this hud is called look into the LocalMessage class to see wat else it calls and the if checks.

                  Comment


                    #10
                    Eventually, the text always comes from GetString. There is no way I can make GetString return anything that wasn't already programmed into it.

                    Comment


                      #11
                      Like this:
                      Player.Console.Message(Message.Static.GetString(Sw itch, RelatedPRI_1, RelatedPRI_2, OptionalObject),0 )
                      TO
                      Player.Console.Message("BLAH",0 );

                      but then you need to find out how to call the hud like in the localmessage class

                      Comment


                        #12
                        I don't need console messages, I need them to appear in big text near the center of the screen.

                        I can already spam messages to the chat like this:
                        Code:
                        PlayerController(Controller).ClientMessage("This is a ClientMessage.");
                        I don't want to mutate any classes the game already uses, such as PlayerController or HUD.

                        Maybe I need to make an Object that can hold a string... and make another function to instantiate the object with the custom string in the message function call.

                        Comment


                          #13
                          In the HUDBase class in XInterface, there is a variable, LocalMessages[8] and you may beable to just add one remotly into the PlayerController.myHUD.LocalMessages[8] is wat i was on track to, i was just giving an example of some sort

                          Comment


                            #14
                            the following puts text to the screen where it tells you "the flag was taken etc... (and it can be any text you want)

                            Code:
                            function SomeFunction()
                            {
                                local PlayerController PC;
                            
                                SomeFunctionTogettPCYouWishToMessage();
                            
                                PC.ClearProgressMessages(); //erases what's on screen
                                PC.SetProgressTime(float time); //The time for the next message to stay on screen
                               PC.SetProgressMessage(int line, string message, color color); //line is the line to display it on, I belive their are 4 in total (0-3), string is the message, and color is the message color (go figure)
                            }

                            Comment


                              #15
                              Thanks, that was interesting! Almost perfect. I just can't get the Line thing to work. All messages appear in the center of the screen, where they're kind of in the way if you're trying to shoot stuff. Did you get it to work?

                              Comment

                              Working...
                              X