Page 1 of 1

MMShowMessage

PostPosted: Fri Dec 29, 06 8:45 pm
by Alex
Since MainMan requested for the source, I decided to just post it here.
Code: Select all
//=============================================================================
// MessageMutator Made by Alex ~ http://www.dxalpha.com/
//=============================================================================
class MessageMutator extends Mutator;

replication
{
   reliable if (Role == ROLE_Authority)
      _ShowMessage;
}

simulated function PostBeginPlay()
{
  Level.Game.BaseMutator.AddMutator(Self);
}

function Mutate (String S, PlayerPawn Player)
{
  local DeusExPlayer          _Player;
  local DeusExPlayer          _CurPlayer;
  local string             _Message;
  _Player = DeusExPlayer(Player);
  if(_Player != None && _Player.bAdmin)
  {
    if(Left(S,16) ~= "game.showmessage" && (Left(S,17) ~= "game.showmessage " || Left(S,17) ~= "game.showmessage"))
    {
      _Message = Right(S,Len(S)-17);
      if(Len(_Message) > 0)
      {
        Log(_Player.PlayerReplicationInfo.PlayerName@"shows a message with ShowMessage:"@_Message);
        _Message = "|p1"$_Message;
        ForEach AllActors(class 'DeusExPlayer', _CurPlayer)
        {
          if(_CurPlayer != None)
          {
            SetOwner(_CurPlayer);
            _ShowMessage(_CurPlayer,_Message);
          }
        }
      }
      else
      {
        _Player.ClientMessage("|p3<MiniMachina> Usage: Mutate Game.ShowMessage [Message]");
      }
    }   
  }   
  Super.Mutate(S,Player);
}

simulated function _ShowMessage(DeusExPlayer _Player, string _Message)
{
  local HUDMissionStartTextDisplay    _HUD;
  if ((_Player.RootWindow != None) && (DeusExRootWindow(_Player.RootWindow).HUD != None))
  {
    _HUD = DeusExRootWindow(_Player.RootWindow).HUD.startDisplay;
  }
  if(_HUD != None)
  {
    _HUD.shadowDist = 0;
    _HUD.Message = "";
    _HUD.charIndex = 0;
    _HUD.winText.SetText("");
    _HUD.winTextShadow.SetText("");
    _HUD.displayTime = 5.50;
    _HUD.perCharDelay = 0.30;
    _HUD.AddMessage(_Message);
    _HUD.StartMessage();
  }
}

defaultproperties
{
  bHidden=True
}


For the rest; Enjoy.

Re: MMShowMessage

PostPosted: Fri Dec 29, 06 10:04 pm
by MainMan
Ah so you use the MOTD window to display it? That's clever!

LOL at the amount of protection in there :wink:


Thanks for sharing :)


EDIT: Btw, is there any way for a player to not receive this? I.e. is there a way for a player to disable MOTD? (like you can disable help messages)

PostPosted: Sat Dec 30, 06 8:10 pm
by Alex
Eeh, of course, just make sure it skips you from the ForEach loop. So when it checks if _CurPlayer != None, make sure it does some other check aswell ;)

PostPosted: Sat Dec 30, 06 10:52 pm
by MainMan
No, I didn't mean that - I don't want people to miss the message - I want everyone to receieve it. I was just wondering if there was some option the client could set to disable the message (like bHelpMessages) - which is something that I don't want, and I would need to prevent it.

PostPosted: Sat Dec 30, 06 10:53 pm
by Alex
My help messages are always deactivated. I hate them. Still see the showmessage though.

PostPosted: Sat Dec 30, 06 10:57 pm
by MainMan
Yeah I hate them too lol. It's like "omg you killed t3h teammate!11"

PostPosted: Tue Mar 13, 07 5:34 am
by Ayleth
Alex, can i use this source to create a serveractor that says "Incoming player" or something when a player starts to join a server (thus explaining possible lag)?

Edit: probably will keep the mutator/actor seperate, but within the same mod file, and just have the actor call the mutator internally, so that if the ShowMessage mod isn't installed on the server, there is no problems.
I don't think i will change showmessage if i don't have to. Might slim it down a bit... :S

Edit: Edit: Uh... Is what i want Possible?? I messed around and couldn't get an actor to trigger anything when a player prelogins or logins :S. Tried an event prelogin and event playerpawn login override, but no luck... IDK?

PostPosted: Sat Jan 05, 08 8:48 pm
by Dae
thank you very much for the source