commands

Discussions about Coding and Scripting
Post Reply
User avatar
>@tack!<
Adept
Posts: 338
Joined: Sat Apr 17, 2010 4:51 pm
Personal rank: lol?

commands

Post by >@tack!< »

Hey i wonder how its done with !r or !red and !b and !blue or !s and !spec and stuff with ASC or Nexgen, i cant find the source of ASC and nexgen is so huge and complicated i can only find that its somehow done with MutatorTeamMessage. Can anyone explain me how to make command with say messages instead of mutate [string]?
User avatar
Sp0ngeb0b
Adept
Posts: 376
Joined: Wed Feb 13, 2008 9:16 pm
Location: Cologne
Contact:

Re: commands

Post by Sp0ngeb0b »

First register your mutator as a message mutator:

Code: Select all

function PreBeginPlay() {
Level.Game.RegisterMessageMutator(Self);
}
Now your mutator will be notified each time a player says something. You can handle it this way:

Code: Select all

function bool MutatorTeamMessage(Actor Sender, Pawn Receiver, PlayerReplicationInfo PRI, coerce string S, name Type, optional bool bBeep) {

  // Only proceed if the command has been sent by a real player and make sure the process will only be called once
  if(Sender.IsA('TournamentPlayer') && Sender == Receiver) {
    if(S ~= "!MyCommand") {
      // Do stuff here
    }
  }
	
  // Allow other message mutators to do their job.
  if (nextMessageMutator != none) {
    return nextMessageMutator.mutatorTeamMessage(sender, receiver, pri, s, type, bBeep);
  } else {
    return true;
  }
}
Website, Forum & UTStats

Image
******************************************************************************
Nexgen Server Controller || My plugins & mods on GitHub
******************************************************************************
User avatar
>@tack!<
Adept
Posts: 338
Joined: Sat Apr 17, 2010 4:51 pm
Personal rank: lol?

Re: commands

Post by >@tack!< »

ah i did the lower code but not the upper, i guess that was the problem thanks alot :tu:
User avatar
>@tack!<
Adept
Posts: 338
Joined: Sat Apr 17, 2010 4:51 pm
Personal rank: lol?

Re: commands

Post by >@tack!< »

Now it works only sometimes i cant say anything at all and then i can and then i cant?! and i did register the thing.
here is the code

Code: Select all

function bool MutatorTeamMessage( Actor Sender, Pawn Receiver, PlayerReplicationInfo PRI, coerce string S, name Type, optional bool bBeep )
{
local int index;

	if(Sender.IsA('TournamentPlayer') && Sender == Receiver)
	{
		index = getplayerindex(PlayerPawn(Sender));
		if(S~= "!MySpawnpoint" || S~= "!MySp")
			SpawnToggle(PlayerPawn(Sender),index);
		else if((S~= "!NextSpawnPoint" || S~= "!nsp") && PI[index].SCConfig.MyChoice)
			SetSpawnPoint(PlayerPawn(Sender),index);
			
	}
	if ( NextMessageMutator != None )
		return NextMessageMutator.MutatorTeamMessage( Sender, Receiver, PRI, S, Type, bBeep );
	else
		return true;
	
}
User avatar
Sp0ngeb0b
Adept
Posts: 376
Joined: Wed Feb 13, 2008 9:16 pm
Location: Cologne
Contact:

Re: commands

Post by Sp0ngeb0b »

Code looks okay. What do you mean with "sometimes I can't say anything"? Does the say message not appear, or does it appear but nothing happens? And does that happen randomly or for a whole map and changes after mapchange?
Website, Forum & UTStats

Image
******************************************************************************
Nexgen Server Controller || My plugins & mods on GitHub
******************************************************************************
User avatar
>@tack!<
Adept
Posts: 338
Joined: Sat Apr 17, 2010 4:51 pm
Personal rank: lol?

Re: commands

Post by >@tack!< »

I type something and press enter but no msg is shown. sometimes it happens or i want to say one of the cmds and nothing happens also the command is not shown in the msgbox
iloveut99
Skilled
Posts: 231
Joined: Mon Aug 16, 2010 10:25 pm

Re: commands

Post by iloveut99 »

check autoteambalance and sendto codes it may help you.
Post Reply