Announcement

Collapse
No announcement yet.

Hello World to in-game Chat?

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

    Hello World to in-game Chat?

    Hello,

    I've been lookin around the net for a few weeks trying to figure out how to create a mutator that will send a "Hello World" message to individual clients as they join a net game.

    I can make it go to the Log, but I can't figure out how to make it appear in the player chat.

    I can't seem to find a clear example of this. As I am trying to get it to only be sent to the player that joins, and not to everyone.

    Can anyone help? it is for UT2004.

    #2
    This is the code i use to advertise server side actors I make (it's in the tick function). It puts the text in the center of the players screen
    if you have clinet side access (ex via a mutator) there is an easier way, plus you can actually put the text in the player chat part of the screen, but I don't have any examples off hand
    Code:
        //Advertise self to new players
        if (bAdvertise)
        {
            bMessaged = False;
    
            ii=min(4, sAdvertiseString.Length);
    
            foreach DynamicActors(class'PlayerController', PC)
            {
                if (PC != None)
                {
                    for (i=0;i<aPC.Length;i++)
                        if(aPC[i] == PC)
                            bMessaged = True;
    
                    //If player controller was not already saved, message player, save controller
                    if (!bMessaged)
                    {
                        if(bCEGDebug)
                            log(sIDTag$"Messaging player");
    
                        PC.ClearProgressMessages();
                        PC.SetProgressTime(fAdvertiseTime);
                        for (iii=0;iii<ii;iii++)
                            PC.SetProgressMessage(iii, sAdvertiseString[iii], cAdvertiseColor);
    
                        aPC[aPC.Length] = PC;
                    }
                }
            }
        }
    Any questions about the above just ask

    Comment


      #3
      How about using IsRelevant() to see when a PlayerController has been created and put it in an array. Then use Tick() to see if each PlayerControllers in it has a PlayerReplicationInfo and if it does, monitor the PlayerReplicationInfo until bReceivedPing is true. Then use PlayerController.ReceivedLocalizedMessage(class'My MessageClass');

      Comment


        #4
        Thank you for the replys

        Originally posted by Jrubzjeknf View Post
        How about using IsRelevant() to see when a PlayerController has been created and put it in an array. Then use Tick() to see if each PlayerControllers in it has a PlayerReplicationInfo and if it does, monitor the PlayerReplicationInfo until bReceivedPing is true. Then use PlayerController.ReceivedLocalizedMessage(class'My MessageClass');
        This sounds perfect. But I don't understand the "class'MyMessageClass" bit. I'm guessing I can't just put a string of text in there?

        I have seen some people specify strings in the default properties at the bottom of a mutator. like this maybe...

        default
        {
        someString="Hello";
        }


        can that be used to replace "class'MyMessageClass", like this "PlayerController.ReceivedLocalizedMessage(default .someString);"?

        Or am I completely on the wrong?


        Thanks for any help, much appreciated!!!

        Comment


          #5
          Look at who ReceivedLocalizedMessage is used.

          Comment


            #6
            Level.Game.Broadcast() outputs to the chat text. You'd have to figure out some way to only make it run locally for the player that just joined.

            Comment


              #7
              Hello again,,

              If i do this .... Level.Game.Broadcast(none, "Hello World", 'Say' );

              it outputs it to the player chat, but it adds a ":" to the end of it, so it displays it as "Hello World:"

              Is there anyway to remove the : from teh end of it? As I just can't seem to get my head around the "ReceivedLocalizedMessage()" function.

              cheers

              Comment


                #8
                I can't remember a ":". Perhaps that is added because you supply none as sender.

                Comment

                Working...
                X