Can't detect when players talk - mutator

Discussions about Coding and Scripting
Post Reply
iloveut99
Skilled
Posts: 231
Joined: Mon Aug 16, 2010 10:25 pm

Can't detect when players talk - mutator

Post by iloveut99 »

I can't detect when players talk, I am trying to add some new option commands but it is not working, can somebody look at this tiny code and find what's wrong?

Code: Select all

class commands extends Mutator;

function CheckMessage(String Msg, Actor Sender) {
	  if (Sender.IsA('TournamentPlayer') && (TeamGamePlus(Level.Game)!=None && !TeamGamePlus(Level.Game).bNoTeamChanges)){
		if (Msg ~= "!R") {
			log("tried change to red");
			return;
		}
                 }
}

// Catch messages from spectators:
function bool MutatorBroadcastMessage( Actor Sender, Pawn Receiver, out coerce string Msg, optional bool bBeep, out optional name Type ){
  if (Sender == Receiver && Sender.IsA('Spectator')) { // Only process the message once.
    // Spectator messages start with the extra "<nick>:".  We remove this.
    CheckMessage(Mid(Msg,InStr(Msg,":")+1), Sender);
  }
  return Super.MutatorBroadcastMessage(Sender,Receiver,Msg,bBeep,Type);
}

// Catch messages from players:
function bool MutatorTeamMessage( Actor Sender, Pawn Receiver, PlayerReplicationInfo PRI, coerce string S, name Type, optional bool bBeep ){
log ("i got here"); //this isn't working
  if (Sender == Receiver) { // Only process the message once.
    CheckMessage(S, Sender);
	log ("i got here x2"); //this isn't working
  }
  return Super.MutatorTeamMessage(Sender,Receiver,PRI,S,Type,bBeep);
}
Thanks, I'm getting mad with this. :)
User avatar
Sp0ngeb0b
Adept
Posts: 376
Joined: Wed Feb 13, 2008 9:16 pm
Location: Cologne
Contact:

Re: Can't detect when players talk - mutator

Post by Sp0ngeb0b »

Make sure you are registered as a messageMutator.

Add this above your code:

Code: Select all

function PreBeginPlay() {

   // Register mutator
  Level.Game.BaseMutator.AddMutator(self);
  Level.Game.RegisterMessageMutator(Self);
}
Website, Forum & UTStats

Image
******************************************************************************
Nexgen Server Controller || My plugins & mods on GitHub
******************************************************************************
iloveut99
Skilled
Posts: 231
Joined: Mon Aug 16, 2010 10:25 pm

Re: Can't detect when players talk - mutator

Post by iloveut99 »

Sp0ngeb0b wrote:Make sure you are registered as a messageMutator.

Add this above your code:

Code: Select all

function PreBeginPlay() {

   // Register mutator
  Level.Game.BaseMutator.AddMutator(self);
  Level.Game.RegisterMessageMutator(Self);
}
Hey dude, work awesome! :mrgreen:

You don't know but I have passed half day trying to get this working just because that line. Thanks, sometimes a bit push like that helps a lot. :)
Post Reply